-
Notifications
You must be signed in to change notification settings - Fork 0
/
intersect_test.go
58 lines (56 loc) · 1 KB
/
intersect_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
54
55
56
57
58
package slice
import (
"reflect"
"testing"
)
func TestIntersect(t *testing.T) {
type args struct {
a []int
b []int
}
tests := []struct {
name string
args args
want []int
}{
{
name: "intersect_ints_should_succeed",
args: args{
a: []int{1, 1, 2, 3, 2, 3, 4},
b: []int{1, 2, 3},
},
want: []int{1, 1, 2, 3, 2, 3},
},
{
name: "intersect_empty_ints_a_should_succeed",
args: args{
a: []int{},
b: []int{1, 2, 3},
},
want: []int{},
},
{
name: "intersect_empty_ints_b_should_succeed",
args: args{
a: []int{1, 2, 2, 12, 3},
b: []int{},
},
want: []int{},
},
{
name: "intersect_ints_with_even_elements_should_succeed",
args: args{
a: []int{1, 1, 2, 3, 2, 3},
b: []int{1, 2},
},
want: []int{1, 1, 2, 2},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := Intersect(tt.args.a, tt.args.b); !reflect.DeepEqual(got, tt.want) {
t.Errorf("Intersect() = %v, want %v", got, tt.want)
}
})
}
}