/
fnmatch_test.go
41 lines (36 loc) · 864 Bytes
/
fnmatch_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
package editorconfig //nolint:testpackage
import (
"testing"
)
func TestTranslate(t *testing.T) {
t.Parallel()
tests := []struct {
pattern string
expected string
}{
{"a*e.c", `a[^/]*e\.c`},
{"a**z.c", `a.*z\.c`},
{"d/**/z.c", `d(?:/|/.*/)z\.c`},
{"som?.c", `som[^/]\.c`},
{"[\\]ab].g", `[\]ab]\.g`},
{"[ab]].g", `[ab]]\.g`},
{"ab[/c", `ab\[/c`},
{"*.{py,js,html}", `[^/]*\.(?:py|js|html)`},
{"{single}.b", `\{single\}\.b`},
{"{{,b,c{d}.i", `\{\{,b,c\{d\}\.i`},
{"{a\\,b,cd}", `(?:a,b|cd)`},
{"{e,\\},f}", `(?:e|}|f)`},
{"{a,{b,c}}", `(?:a|(?:b|c))`},
{"{{a,b},c}", `(?:(?:a|b)|c)`},
}
for _, test := range tests {
test := test
t.Run(test.pattern, func(t *testing.T) {
t.Parallel()
result := translate(test.pattern)
if result != test.expected {
t.Errorf("%s != %s", test.expected, result)
}
})
}
}