Share D&D cited source traversal

This commit is contained in:
2026-07-21 14:37:12 +00:00
parent 732b13669f
commit 07460341e3
11 changed files with 322 additions and 129 deletions

View File

@@ -0,0 +1,25 @@
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: "OrIn\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)
}
})
}
}