test array and string slices

pull/2558/head
Alexander Medvednikov 2019-10-27 01:37:29 +03:00
parent dd12a85429
commit ee51313e2c
2 changed files with 8 additions and 0 deletions

View File

@ -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() {

View File

@ -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'