-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathglob_test.go
More file actions
40 lines (35 loc) · 945 Bytes
/
glob_test.go
File metadata and controls
40 lines (35 loc) · 945 Bytes
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
package main
import "testing"
var globTests = []struct {
pattern string
in string
expected bool
}{
{"", "", true},
{"", "file.txt", false},
{"file.txt", "file.txt", true},
{"*", "file.txt", true}, // matches everything
{"*", "", true}, // matches everything
{"*beta", "", false},
{"*beta", "beta", true},
{"*beta", "alphabeta", true},
{"beta*", "betaalpha", true},
{"beta*", "", false},
{"beta*", "beta", true},
{"beta*", "alphabeta", false},
{"*beta*", "", false},
{"*beta*", "alpha", false},
{"*beta*", "beta", true},
{"*beta*", "alphabeta", true},
{"*beta*", "betagamma", true},
{"*beta*", "alphabetagamma", true},
{"*beta*", "alpha/beta/gamma", true},
}
func TestGlobMatch(t *testing.T) {
for _, tt := range globTests {
actual := globMatch(tt.pattern, tt.in)
if actual != tt.expected {
t.Errorf("patternMatch(\"%s\", \"%s\") => %t, want %t", tt.pattern, tt.in, actual, tt.expected)
}
}
}