Skip to content

Commit 4223e79

Browse files
author
Thomas von Dein
committed
add test cases for literal matching
1 parent 1bf5028 commit 4223e79

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

table/filter_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,3 +563,34 @@ func TestFuzzySubSequenceMatch_EmptyString(t *testing.T) {
563563
assert.False(t, fuzzySubsequenceMatch("", "a"), "non-empty needle should not match empty haystack")
564564
assert.True(t, fuzzySubsequenceMatch("", ""), "empty needle should match empty haystack")
565565
}
566+
567+
func TestFuzzyFilter_LiteralMatches(t *testing.T) {
568+
cols := []Column{
569+
NewColumn("name", "Name", 10).WithFiltered(true),
570+
NewColumn("city", "City", 10).WithFiltered(true),
571+
}
572+
row := NewRow(RowData{
573+
"name": "Acme",
574+
"city": "Stuttgart",
575+
})
576+
577+
type testCase struct {
578+
name string
579+
filter string
580+
shouldMatch bool
581+
}
582+
583+
testCases := []testCase{
584+
{"literal match", "'Stutt", true},
585+
{"failing literal match", "'Stutgar", false},
586+
{"combined literal match", "'Stut tat", true},
587+
}
588+
589+
for _, tc := range testCases {
590+
assert.Equal(t, tc.shouldMatch, filterFuncFuzzy(FilterFuncInput{
591+
Columns: cols,
592+
Row: row,
593+
Filter: tc.filter,
594+
}))
595+
}
596+
}

0 commit comments

Comments
 (0)