From ee51313e2c1eb26730945666138bed87a59abd5b Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sun, 27 Oct 2019 01:37:29 +0300 Subject: [PATCH] test array and string slices --- vlib/builtin/array_test.v | 6 ++++++ vlib/builtin/string_test.v | 2 ++ 2 files changed, 8 insertions(+) diff --git a/vlib/builtin/array_test.v b/vlib/builtin/array_test.v index 11104cbbaa..9863f5cef0 100644 --- a/vlib/builtin/array_test.v +++ b/vlib/builtin/array_test.v @@ -117,8 +117,11 @@ fn test_repeat() { fn test_right() { a := [1, 2, 3, 4] b := a.right(1) + c := a[1..a.len] assert b[0] == 2 assert b[1] == 3 + assert c[0] == 2 + assert c[1] == 3 } fn test_right_with_n_bigger_than_array_size() { @@ -138,8 +141,11 @@ fn test_right_with_n_bigger_than_array_size() { fn test_left() { a := [1, 2, 3] b := a.left(2) + c := a[0..2] assert b[0] == 1 assert b[1] == 2 + assert c[0] == 1 + assert c[1] == 2 } fn test_slice() { diff --git a/vlib/builtin/string_test.v b/vlib/builtin/string_test.v index 7619027940..e4c9b362d2 100644 --- a/vlib/builtin/string_test.v +++ b/vlib/builtin/string_test.v @@ -208,6 +208,8 @@ fn test_runes() { assert u.len == 6 assert s2.substr(1, 4).len == 3 assert s2.substr(1, 4) == 'riv' + assert s2[1..4].len == 3 + assert s2[1..4] == 'riv' assert u.substr(1, 4).len == 6 assert u.substr(1, 4) == 'рив' assert s2.substr(1, 2) == 'r'