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

feat: add FindLast func

This commit is contained in:
dudaodong
2022-01-24 15:22:43 +08:00
parent 18ec73839b
commit 4eaa0a39d5
4 changed files with 50 additions and 6 deletions

View File

@@ -166,6 +166,20 @@ func TestFind(t *testing.T) {
assert.Equal(2, *res)
}
func TestFindLast(t *testing.T) {
nums := []int{2, 3, 4, 5}
even := func(i, num int) bool {
return num%2 == 0
}
res, ok := FindLast(nums, even)
if !ok {
t.Fatal("found nothing")
}
assert := internal.NewAssert(t, "TestFindLast")
assert.Equal(4, *res)
}
func TestFindFoundNothing(t *testing.T) {
nums := []int{1, 1, 1, 1, 1, 1}
findFunc := func(i, num int) bool {