1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/vlib/arrays/arrays_test.v

29 lines
602 B
V
Raw Normal View History

2019-10-30 16:21:57 +03:00
import arrays
fn test_range() {
2019-12-25 15:52:27 +03:00
start_pos := 3
end_pos := 10
arr1 := arrays.range<int>(start_pos, end_pos)
assert arr1.len == end_pos - start_pos
for i, c in arr1 {
assert c == i + start_pos
}
arr2 := arrays.range<f32>(start_pos, end_pos)
assert arr2.len == end_pos - start_pos
for i, c in arr2 {
assert c == f32(i + start_pos)
}
arr3 := arrays.range<int>(start_pos, start_pos - 1)
assert arr3.len == 0
arr4 := arrays.range<int>(start_pos, start_pos)
assert arr4.len == 0
arr5 := arrays.range<int>(start_pos, start_pos + 1)
assert arr5.len == 1
assert arr5[0] == start_pos
}