Skip to content

Commit

Permalink
improve test
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Dec 3, 2024
1 parent 4ea4f9d commit bb8e035
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions vlib/v/tests/builtin_arrays/array_count_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,24 @@ fn test_zero() {
b := [10]int{init: index}
assert a.count(it == 1000) == 0
}

fn test_struct() {
struct Abc {
x int
y int
z string
}

a := [Abc{}, Abc{1, 2, 'abc'}, Abc{100, 2, 'def'}, Abc{0, 0, 'a'}]

assert dump(a.count(it.z.starts_with('a'))) == 2
assert dump(a.count(it.y == 2)) == 2
assert dump(a.count(it.z.len == 1)) == 1
assert dump(a.count(it.z.len < 3)) == 2

sa := ['aa', 'bb', 'ccc']
dump(sa)
assert dump(sa.count(it.len < 3)) == 2
assert dump(sa.count(it == 'aa')) == 1
assert dump(sa.count(it.len == 3)) == 1
}

0 comments on commit bb8e035

Please sign in to comment.