-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrelations_test.go
50 lines (46 loc) · 1 KB
/
relations_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
package strset
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func TestSubsetOf(t *testing.T) {
testCases := []struct {
set1 Set
set2 Set
want bool
}{
{empty, empty, true},
{singleton, empty, false},
{empty, singleton, true},
{universe, even, false},
{even, universe, true},
{fibonacci, prime, false},
}
for _, tc := range testCases {
t.Run(fmt.Sprintf("%v.SubsetOf(%v) is %v", tc.set1, tc.set2, tc.want), func(t *testing.T) {
got := tc.set1.SubsetOf(tc.set2)
assert.Equal(t, tc.want, got)
})
}
}
func TestSupersetOf(t *testing.T) {
testCases := []struct {
set1 Set
set2 Set
want bool
}{
{empty, empty, true},
{singleton, empty, true},
{empty, singleton, false},
{universe, even, true},
{even, universe, false},
{fibonacci, prime, false},
}
for _, tc := range testCases {
t.Run(fmt.Sprintf("%v.SupersetOf(%v) is %v", tc.set1, tc.set2, tc.want), func(t *testing.T) {
got := tc.set1.SupersetOf(tc.set2)
assert.Equal(t, tc.want, got)
})
}
}