-
Notifications
You must be signed in to change notification settings - Fork 0
/
selector_test.go
107 lines (87 loc) · 2.29 KB
/
selector_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
102
103
104
105
106
107
package netmap
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestFilterIn(t *testing.T) {
f := FilterIn("abc", "def", "oh no")
require.True(t, f.Check("abc"))
require.True(t, f.Check("oh no"))
require.False(t, f.Check(""))
require.False(t, f.Check("abcd"))
require.True(t, f.Check("def"))
}
func TestFilterNotIn(t *testing.T) {
f := FilterNotIn("abc", "def", "oh no")
require.True(t, f.Check(""))
require.False(t, f.Check("abc"))
require.True(t, f.Check("abcd"))
require.False(t, f.Check("oh no"))
require.False(t, f.Check("def"))
}
func TestFilterEQ(t *testing.T) {
for _, s := range []string{"abcdef", "lul"} {
f := FilterEQ(s)
require.True(t, f.Check(s))
require.False(t, f.Check("not"))
}
}
func TestFilterNE(t *testing.T) {
for _, s := range []string{"abcdef", "lul"} {
f := FilterNE(s)
require.False(t, f.Check(s))
require.True(t, f.Check("not"))
}
}
func TestFilterGT(t *testing.T) {
var f *SimpleFilter
f = FilterGT(20)
require.False(t, f.Check("19"))
require.False(t, f.Check("20"))
require.True(t, f.Check("21"))
require.True(t, f.Check("nan"))
f = FilterGT(-11)
require.False(t, f.Check("-12"))
require.False(t, f.Check("-11"))
require.True(t, f.Check("0"))
require.True(t, f.Check("nan"))
}
func TestFilterGE(t *testing.T) {
var f *SimpleFilter
f = FilterGE(20)
require.False(t, f.Check("19"))
require.True(t, f.Check("20"))
require.True(t, f.Check("21"))
require.True(t, f.Check("nan"))
f = FilterGE(-11)
require.False(t, f.Check("-12"))
require.True(t, f.Check("-11"))
require.True(t, f.Check("0"))
require.True(t, f.Check("nan"))
}
func TestFilterLT(t *testing.T) {
var f *SimpleFilter
f = FilterLT(20)
require.True(t, f.Check("19"))
require.False(t, f.Check("20"))
require.False(t, f.Check("21"))
require.True(t, f.Check("nan"))
f = FilterLT(-11)
require.True(t, f.Check("-12"))
require.False(t, f.Check("-11"))
require.False(t, f.Check("0"))
require.True(t, f.Check("nan"))
}
func TestFilterLE(t *testing.T) {
var f *SimpleFilter
f = FilterLE(20)
require.True(t, f.Check("19"))
require.True(t, f.Check("20"))
require.False(t, f.Check("21"))
require.True(t, f.Check("nan"))
f = FilterLE(-11)
require.True(t, f.Check("-12"))
require.True(t, f.Check("-11"))
require.False(t, f.Check("0"))
require.True(t, f.Check("nan"))
}