-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathrfc6125_test.go
73 lines (70 loc) · 1.1 KB
/
rfc6125_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
package main
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func TestWild(t *testing.T) {
cases := []struct {
expected bool
pattern string
target string
}{
{
expected: false,
pattern: "foo",
target: "bar",
},
{
expected: true,
pattern: "foo",
target: "foo",
},
{
expected: false,
pattern: "foo",
target: "foo.bar",
},
{
expected: false,
pattern: "foo.bar",
target: "foo",
},
{
expected: true,
pattern: "foo.bar",
target: "foo.bar",
},
{
expected: true,
pattern: "*",
target: "foo",
},
{
expected: true,
pattern: "*",
target: "foo.bar",
},
{
expected: true,
pattern: "*.bar",
target: "foo.bar",
},
{
expected: false,
pattern: "*.boo",
target: "foo",
},
{
expected: false,
pattern: "*.boo",
target: "foo.bar",
},
}
for _, case_ := range cases {
t.Run(fmt.Sprintf("%s/%s", case_.pattern, case_.target), func(t *testing.T) {
result := wildMatch(case_.pattern, case_.target)
assert.Equal(t, case_.expected, result)
})
}
}