1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-12 08:42:29 +08:00

Slice: Add count func (#15)

Returns the count of matched elements
This commit is contained in:
donutloop
2022-01-06 13:32:14 +01:00
committed by GitHub
parent c7e961704d
commit 3905c0bde1
4 changed files with 37 additions and 0 deletions

View File

@@ -197,6 +197,19 @@ func TestGroupBy(t *testing.T) {
}
}
func TestCount(t *testing.T) {
nums := []int{1, 2, 3, 4, 5, 6}
evenFunc := func(i, num int) bool {
return (num % 2) == 0
}
c := Count(nums, evenFunc)
if c != 3 {
internal.LogFailedTestInfo(t, "Count", nums, 3, c)
t.FailNow()
}
}
func TestFind(t *testing.T) {
nums := []int{1, 2, 3, 4, 5}
even := func(i, num int) bool {