mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
test array and string slices
This commit is contained in:
parent
dd12a85429
commit
ee51313e2c
@ -117,8 +117,11 @@ fn test_repeat() {
|
|||||||
fn test_right() {
|
fn test_right() {
|
||||||
a := [1, 2, 3, 4]
|
a := [1, 2, 3, 4]
|
||||||
b := a.right(1)
|
b := a.right(1)
|
||||||
|
c := a[1..a.len]
|
||||||
assert b[0] == 2
|
assert b[0] == 2
|
||||||
assert b[1] == 3
|
assert b[1] == 3
|
||||||
|
assert c[0] == 2
|
||||||
|
assert c[1] == 3
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_right_with_n_bigger_than_array_size() {
|
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() {
|
fn test_left() {
|
||||||
a := [1, 2, 3]
|
a := [1, 2, 3]
|
||||||
b := a.left(2)
|
b := a.left(2)
|
||||||
|
c := a[0..2]
|
||||||
assert b[0] == 1
|
assert b[0] == 1
|
||||||
assert b[1] == 2
|
assert b[1] == 2
|
||||||
|
assert c[0] == 1
|
||||||
|
assert c[1] == 2
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_slice() {
|
fn test_slice() {
|
||||||
|
@ -208,6 +208,8 @@ fn test_runes() {
|
|||||||
assert u.len == 6
|
assert u.len == 6
|
||||||
assert s2.substr(1, 4).len == 3
|
assert s2.substr(1, 4).len == 3
|
||||||
assert s2.substr(1, 4) == 'riv'
|
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).len == 6
|
||||||
assert u.substr(1, 4) == 'рив'
|
assert u.substr(1, 4) == 'рив'
|
||||||
assert s2.substr(1, 2) == 'r'
|
assert s2.substr(1, 2) == 'r'
|
||||||
|
Loading…
Reference in New Issue
Block a user