From 910f350a2689a2b54145fcab585d74d0be01e43b Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 2 Aug 2019 10:20:59 +0300 Subject: [PATCH] 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 --- vlib/builtin/string_test.v | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vlib/builtin/string_test.v b/vlib/builtin/string_test.v index 0e0cef9740..38e63c3983 100644 --- a/vlib/builtin/string_test.v +++ b/vlib/builtin/string_test.v @@ -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' }