forked from paul-mannino/go-fuzzywuzzy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setoperations_test.go
48 lines (40 loc) · 1.08 KB
/
setoperations_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
package fuzzy
import (
"testing"
)
var equalsTestData = []struct {
set1 []string // input
set2 []string
equal bool // expected result
}{
{[]string{"alpha", "beta"}[:], []string{"beta", "alpha"}[:], true},
{[]string{"alpha", "beta", "gamma"}, []string{"beta", "alpha"}, false},
{[]string{"alpha"}, []string{"beta"}, false},
}
func TestEquals(t *testing.T) {
for _, testCase := range equalsTestData {
s1 := NewStringSet(testCase.set1)
s2 := NewStringSet(testCase.set2)
if s1.Equals(s2) != testCase.equal {
t.Fatal()
}
}
}
func TestDifference(t *testing.T) {
s1 := NewStringSet([]string{"ab", "bc", "cd"})
s2 := NewStringSet([]string{"bc", "cd", "de"})
expectedDiff := NewStringSet([]string{"ab"})
actualDiff := s1.Difference(s2)
if !actualDiff.Equals(expectedDiff) {
t.Fatal()
}
}
func TestIntersection(t *testing.T) {
s1 := NewStringSet([]string{"ab", "bc", "cd"})
s2 := NewStringSet([]string{"bc", "cd", "de"})
expectedIntersect := NewStringSet([]string{"bc", "cd"})
actualIntersect := s1.Intersect(s2)
if !actualIntersect.Equals(expectedIntersect) {
t.Fatal()
}
}