-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathutils_test.go
53 lines (37 loc) · 1.13 KB
/
utils_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
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestFilter(t *testing.T) {
assert := assert.New(t)
str := "This is a topic string"
filters0 := []Filter{}
assert.True(filteredAny(str, filters0))
filters1 := []Filter{""}
assert.True(filteredAny(str, filters1))
filters2 := []Filter{"This"}
assert.True(filteredAny(str, filters2))
filters3 := []Filter{"this is"}
assert.True(filteredAny(str, filters3))
filters4 := []Filter{"this is", "topic"}
assert.True(filteredAny(str, filters4))
filters5 := []Filter{"this is", "other string"}
assert.True(filteredAny(str, filters5))
filters6 := []Filter{"not"}
assert.False(filteredAny(str, filters6))
filters7 := []Filter{"not", "appear"}
assert.False(filteredAny(str, filters7))
}
func TestContains(t *testing.T) {
assert := assert.New(t)
str1 := []string{"slack", "line"}
assert.True(contains(str1, "slack"))
assert.True(contains(str1, "line"))
assert.False(contains(str1, "telegram"))
str2 := []string{"slack"}
assert.True(contains(str2, "slack"))
assert.False(contains(str2, "line"))
str3 := []string{}
assert.False(contains(str3, "slack"))
}