1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-11 16:22:26 +08:00

feat: add Find function in slice.go

This commit is contained in:
dudaodong
2021-12-09 17:54:16 +08:00
parent b7bb7c6ae0
commit 8c8f991390
2 changed files with 34 additions and 0 deletions

View File

@@ -137,6 +137,18 @@ func TestFilter(t *testing.T) {
}
func TestFind(t *testing.T) {
nums := []int{1, 2, 3, 4, 5}
even := func(i, num int) bool {
return num%2 == 0
}
res := Find(nums, even)
if res != 2 {
utils.LogFailedTestInfo(t, "Find", nums, 2, res)
t.FailNow()
}
}
func TestMap(t *testing.T) {
s1 := []int{1, 2, 3, 4}
multiplyTwo := func(i, num int) int {