mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
string_test: fix randomly failed test
* memory should be initialized with zeros before creating string * there is no string([]array) constructor, string(byteptr) does not count length correctly, using string(byteptr, len) to fix
This commit is contained in:
parent
ed3f1d315b
commit
910f350a26
@ -327,7 +327,7 @@ fn test_interpolation() {
|
||||
}
|
||||
|
||||
fn test_bytes_to_string() {
|
||||
mut buf := malloc(10)
|
||||
mut buf := calloc(10)
|
||||
buf[0] = `h`
|
||||
buf[1] = `e`
|
||||
buf[2] = `l`
|
||||
@ -336,5 +336,5 @@ fn test_bytes_to_string() {
|
||||
assert string(buf) == 'hello'
|
||||
assert string(buf, 2) == 'he'
|
||||
bytes := [`h`, `e`, `l`, `l`, `o`]
|
||||
assert string(bytes) == 'hello'
|
||||
assert string(bytes, 5) == 'hello'
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user