github.com/egonelbre/exp@v0.0.0-20240430123955-ed1d3aa93911/fuzzy/fuzzytext/simple_test.go (about) 1 package fuzzytext_test 2 3 import ( 4 "testing" 5 6 "github.com/egonelbre/exp/fuzzy/fuzzytext" 7 ) 8 9 func TestMatchSimple(t *testing.T) { 10 var tests = []struct { 11 pattern, text string 12 match bool 13 }{ 14 {"", "fuzzy", false}, 15 {"fts", "", false}, 16 {"fts", "ft", false}, 17 {"fts", "fts", true}, 18 {"f", "fuzzy text search", true}, 19 {"ft", "fuzzy text search", true}, 20 {"fts", "fuzzy text search", true}, 21 {"ftsh", "fuzzy text search", true}, 22 {"fxz", "fuzzy text search", false}, 23 {"FTs", "fuzzy Text Search", true}, 24 } 25 26 for _, test := range tests { 27 matched := fuzzytext.MatchSimple(test.pattern, test.text) 28 if matched != test.match { 29 t.Errorf("MatchSimple(%q, %q) != %v", test.pattern, test.text, test.match) 30 } 31 } 32 }