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:
parent
045d480c8c
commit
b40ad7c83f
@ -769,7 +769,7 @@ pub fn (s []string) join_lines() string {
|
||||
pub fn (s string) reverse() string {
|
||||
mut res := string {
|
||||
len: s.len
|
||||
str: malloc(s.len + 1)
|
||||
str: malloc(s.len)
|
||||
}
|
||||
|
||||
for i := s.len - 1; i >= 0; i-- {
|
||||
|
@ -293,3 +293,9 @@ fn test_all_after() {
|
||||
assert q == 'hello'
|
||||
}
|
||||
|
||||
fn test_reverse() {
|
||||
s := 'hello'
|
||||
assert s.reverse() == 'olleh'
|
||||
t := ''
|
||||
assert t.reverse() == t
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user