-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfind_last_test.go
53 lines (51 loc) · 978 Bytes
/
find_last_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package slices
import (
"reflect"
"testing"
)
func TestFindLast(t *testing.T) {
type args struct {
slice []int
condition func(item int, index int, slice []int) bool
}
tests := []struct {
name string
args args
want int
want1 bool
}{
{
name: "findNumber1",
args: args{
slice: []int{2, 3, 4, 4},
condition: func(item int, _ int, _ []int) bool {
return item == 14
},
},
want: 0,
want1: false,
},
{
name: "findNumber2",
args: args{
slice: []int{2, 3, 4, 4},
condition: func(item int, _ int, _ []int) bool {
return item == 4
},
},
want: 4,
want1: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, got1 := FindLast(tt.args.slice, tt.args.condition)
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("Find() got = %v, want %v", got, tt.want)
}
if got1 != tt.want1 {
t.Errorf("Find() got1 = %v, want %v", got1, tt.want1)
}
})
}
}