1
0
Fork 0
golang-github-editorconfig-.../fnmatch_test.go
Daniel Baumann 2b08a89310
Adding upstream version 2.6.3.
Signed-off-by: Daniel Baumann <daniel@debian.org>
2025-05-18 22:58:26 +02:00

40 lines
849 B
Go

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 {
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)
}
})
}
}