Add tests for insensitive variants of filter methods

This commit is contained in:
Johannes Hertenstein
2018-11-25 13:32:16 +01:00
committed by Alexander Neumann
parent c13f79da02
commit 5fe6de219d
2 changed files with 54 additions and 0 deletions
+27
View File
@@ -279,6 +279,33 @@ 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 {