-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib_test.go
54 lines (44 loc) · 1.16 KB
/
lib_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
package set
import "testing"
func TestIntersectionWithTwoLists(t *testing.T) {
items1 := []string{"a", "b", "c"}
items2 := []string{"c", "d", "e"}
intersectionItems := Intersection([][]string{items1, items2})
want := 1
got := len(intersectionItems)
if got != want {
t.Errorf("%d != %d", got, want)
}
wantLetter := "c"
gotLetter := intersectionItems[0]
if got != want {
t.Errorf("%s != %s", gotLetter, wantLetter)
}
}
func TestIntersectionWithThreeLists(t *testing.T) {
items1 := []string{"a", "b", "c"}
items2 := []string{"b", "c", "d"}
items3 := []string{"c", "d", "e"}
intersectionItems := Intersection([][]string{items1, items2, items3})
want := 1
got := len(intersectionItems)
if got != want {
t.Errorf("%d != %d", got, want)
}
wantLetter := "c"
gotLetter := intersectionItems[0]
if got != want {
t.Errorf("%s != %s", gotLetter, wantLetter)
}
}
func TestUnionWithThreeLists(t *testing.T) {
items1 := []string{"a", "b", "c"}
items2 := []string{"b", "c", "d"}
items3 := []string{"c", "d", "e"}
unionItems := Union([][]string{items1, items2, items3})
want := 5
got := len(unionItems)
if got != want {
t.Errorf("%d != %d", got, want)
}
}