26 lines
900 B
Go
26 lines
900 B
Go
|
|
package shared
|
|||
|
|
|
|||
|
|
import "testing"
|
|||
|
|
|
|||
|
|
func TestContainsTokenSequence(t *testing.T) {
|
|||
|
|
tests := []struct {
|
|||
|
|
name string
|
|||
|
|
value string
|
|||
|
|
query string
|
|||
|
|
want bool
|
|||
|
|
}{
|
|||
|
|
{name: "unicode apostrophe and case", value: "O’rIn\u2003ThOrN advances", query: "o'rin thorn", want: true},
|
|||
|
|
{name: "multiword sequence", value: "Mira Thorn watches", query: "mira thorn", want: true},
|
|||
|
|
{name: "nonconsecutive words", value: "Mira watches Thorn", query: "mira thorn", want: false},
|
|||
|
|
{name: "short name is not substring", value: "A cart rolls past", query: "art", want: false},
|
|||
|
|
{name: "empty query", value: "anything", query: " ", want: false},
|
|||
|
|
}
|
|||
|
|
for _, test := range tests {
|
|||
|
|
t.Run(test.name, func(t *testing.T) {
|
|||
|
|
if got := ContainsTokenSequence(test.value, test.query); got != test.want {
|
|||
|
|
t.Fatalf("ContainsTokenSequence(%q, %q) = %t, want %t", test.value, test.query, got, test.want)
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
}
|