Slice: Add count func (#15)

Returns the count of matched elements
This commit is contained in:
donutloop authored and GitHub committed 2022-01-06 20:32:14 +08:00
1 parent c7e961704d
commit 3905c0bde1
4 files changed
+37

No files matched your search

+13
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 {