Only convert iexclude & iinclude casing once

This commit is contained in:
Johannes Hertenstein
2019-01-19 11:04:53 +00:00
parent 879f6e0c81
commit deedc38129
3 changed files with 11 additions and 38 deletions
-9
View File
@@ -187,12 +187,3 @@ func List(patterns []string, str string) (matched bool, childMayMatch bool, err
return matched, childMayMatch, nil
}
// InsensitiveList is the same as List but case insensitive.
func InsensitiveList(patterns []string, str string) (matched bool, childMayMatch bool, err error) {
str = strings.ToLower(str)
for index, path := range patterns {
patterns[index] = strings.ToLower(path)
}
return List(patterns, str)
}
-27
View File
@@ -279,33 +279,6 @@ func ExampleList() {
// match: true
}
var filterInsensitiveListTests = []struct {
patterns []string
path string
match bool
}{
{[]string{"*.go"}, "/foo/bar/test.go", true},
{[]string{"test.go"}, "/foo/bar/test.go", true},
{[]string{"test.go"}, "/foo/bar/TEST.go", true},
{[]string{"BAR"}, "/foo/BAR/TEST.go", true},
}
func TestInsensitiveList(t *testing.T) {
for i, test := range filterInsensitiveListTests {
match, _, err := filter.InsensitiveList(test.patterns, test.path)
if err != nil {
t.Errorf("test %d failed: expected no error for patterns %q, but error returned: %v",
i, test.patterns, err)
continue
}
if match != test.match {
t.Errorf("test %d: filter.InsensitiveList(%q, %q): expected %v, got %v",
i, test.patterns, test.path, test.match, match)
}
}
}
func extractTestLines(t testing.TB) (lines []string) {
f, err := os.Open("testdata/libreoffice.txt.bz2")
if err != nil {