-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathcmp_test.go
101 lines (97 loc) · 1.61 KB
/
cmp_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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package yql
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestIntSetBelong(t *testing.T) {
var testData = []struct {
ina, inb []int64
out bool
}{
{
ina: []int64{3, 1, 2},
inb: []int64{5, 1, 4, 3, 2},
out: true,
},
{
ina: []int64{3, 1, 2},
inb: []int64{5, 1, 4, 3, 0},
out: false,
},
{
ina: []int64{3, 1, 2, 6, 8, 10, 11},
inb: []int64{5, 1, 4, 3, 0},
out: false,
},
{
ina: []int64{},
inb: []int64{1},
out: false,
},
{
ina: []int64{1},
inb: []int64{1},
out: true,
},
{
ina: []int64{},
inb: []int64{},
out: false,
},
}
ass := assert.New(t)
for _, tc := range testData {
ass.Equal(tc.out, intSetBelong(tc.ina, tc.inb), "ina=%+v||inb=%+v", tc.ina, tc.inb)
}
}
func TestIntSetInter(t *testing.T) {
var testData = []struct {
ina, inb []int64
out bool
}{
{
ina: []int64{3, 1, 2},
inb: []int64{5, 1, 4, 3, 2},
out: true,
},
{
ina: []int64{3, 1, 2},
inb: []int64{5, 1, 4, 3, 0},
out: true,
},
{
ina: []int64{3, 1, 2, 6, 8, 10, 11},
inb: []int64{5, 1, 4, 3, 0},
out: true,
},
{
ina: []int64{},
inb: []int64{1},
out: false,
},
{
ina: []int64{1},
inb: []int64{1},
out: true,
},
{
ina: []int64{},
inb: []int64{},
out: false,
},
{
ina: []int64{1, 3, 5, 7, 9},
inb: []int64{2, 4, 6, 8, 10, 5},
out: true,
},
{
ina: []int64{1, 3, 5, 7, 9},
inb: []int64{2, 4, 6, 8, 10, 12},
out: false,
},
}
ass := assert.New(t)
for _, tc := range testData {
ass.Equal(tc.out, intSetInter(tc.ina, tc.inb), "ina=%+v||inb=%+v", tc.ina, tc.inb)
}
}