Slice: Add none func (#13)

Returns true whether no elements of this slice match the provided predicate
func. Negated form of Every func
This commit is contained in:
donutloop authored and GitHub committed 2022-01-05 19:38:14 +08:00
1 parent 4752725dd6
commit 4aef9d6d22
4 files changed
+36

No files matched your search

+12
View File
@@ -108,6 +108,18 @@ func TestEvery(t *testing.T) {
}
}
func TestNone(t *testing.T) {
nums := []int{1, 2, 3, 5}
check := func(i, num int) bool {
return num%2 == 1
}
res := None(nums, check)
if res != false {
internal.LogFailedTestInfo(t, "Every", nums, false, res)
t.FailNow()
}
}
func TestSome(t *testing.T) {
nums := []int{1, 2, 3, 5}
isEven := func(i, num int) bool {