forked from thoas/go-funk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
intersection_test.go
51 lines (34 loc) · 1.15 KB
/
intersection_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
package funk
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestIntersect(t *testing.T) {
is := assert.New(t)
r := Intersect([]int{1, 2, 3, 4}, []int{2, 4, 6})
is.Equal(r, []int{2, 4})
r = Intersect([]string{"foo", "bar", "hello", "bar"}, []string{"foo", "bar"})
is.Equal(r, []string{"foo", "bar"})
r = Intersect([]string{"foo", "bar"}, []string{"foo", "bar", "hello", "bar"})
is.Equal(r, []string{"foo", "bar", "bar"})
}
func TestIntersectString(t *testing.T) {
is := assert.New(t)
r := IntersectString([]string{"foo", "bar", "hello", "bar"}, []string{"foo", "bar"})
is.Equal(r, []string{"foo", "bar"})
}
func TestDifference(t *testing.T) {
is := assert.New(t)
r1, r2 := Difference([]int{1, 2, 3, 4}, []int{2, 4, 6})
is.Equal(r1, []int{1, 3})
is.Equal(r2, []int{6})
r1, r2 = Difference([]string{"foo", "bar", "hello", "bar"}, []string{"foo", "bar"})
is.Equal(r1, []string{"hello"})
is.Equal(r2, []string{})
}
func TestDifferenceString(t *testing.T) {
is := assert.New(t)
r1, r2 := DifferenceString([]string{"foo", "bar", "hello", "bar"}, []string{"foo", "bar"})
is.Equal(r1, []string{"hello"})
is.Equal(r2, []string{})
}