github.com/elek/golangci-lint@v1.42.2-0.20211208090441-c05b7fcb3a9a/pkg/packages/skip_test.go (about) 1 package packages 2 3 import ( 4 "regexp" 5 "strings" 6 "testing" 7 8 "github.com/stretchr/testify/assert" 9 ) 10 11 func TestPathElemRe(t *testing.T) { 12 matches := [][]string{ 13 {"dir"}, 14 {"root", "dir"}, 15 {"root", "dir", "subdir"}, 16 {"dir", "subdir"}, 17 } 18 noMatches := [][]string{ 19 {"nodir"}, 20 {"dirno"}, 21 {"root", "dirno"}, 22 {"root", "nodir"}, 23 {"root", "dirno", "subdir"}, 24 {"root", "nodir", "subdir"}, 25 {"dirno", "subdir"}, 26 {"nodir", "subdir"}, 27 } 28 for _, sep := range []rune{'/', '\\'} { 29 reStr := pathElemReImpl("dir", sep) 30 re := regexp.MustCompile(reStr) 31 for _, m := range matches { 32 assert.Regexp(t, re, strings.Join(m, string(sep))) 33 } 34 for _, m := range noMatches { 35 assert.NotRegexp(t, re, strings.Join(m, string(sep))) 36 } 37 } 38 }