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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user