1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

save a byteptr memory, add tests

This commit is contained in:
eulerkochy 2019-07-07 21:13:34 +05:30 committed by Alexander Medvednikov
parent 045d480c8c
commit b40ad7c83f
2 changed files with 7 additions and 1 deletions

View File

@ -769,7 +769,7 @@ pub fn (s []string) join_lines() string {
pub fn (s string) reverse() string { pub fn (s string) reverse() string {
mut res := string { mut res := string {
len: s.len len: s.len
str: malloc(s.len + 1) str: malloc(s.len)
} }
for i := s.len - 1; i >= 0; i-- { for i := s.len - 1; i >= 0; i-- {

View File

@ -293,3 +293,9 @@ fn test_all_after() {
assert q == 'hello' assert q == 'hello'
} }
fn test_reverse() {
s := 'hello'
assert s.reverse() == 'olleh'
t := ''
assert t.reverse() == t
}