Harden item occurrence grounding

This commit is contained in:
2026-08-06 13:37:21 +00:00
parent 8cf03a2a44
commit 4192aa8584
16 changed files with 152 additions and 121 deletions

View File

@@ -2,6 +2,32 @@ package shared
import "testing"
func TestComparisonKeyNormalizesDNDText(t *testing.T) {
if TextComparisonPolicy != "dnd.text_comparison.v1" {
t.Fatalf("TextComparisonPolicy = %q", TextComparisonPolicy)
}
for _, test := range []struct {
name string
input string
want string
}{
{name: "case", input: "Captain Vale", want: "captain vale"},
{name: "compatibility", input: "", want: "ally"},
{name: "whitespace", input: " Mira\u2003Thorn ", want: "mira thorn"},
{name: "apostrophes", input: "ORin and OʼRin", want: "o'rin and o'rin"},
{name: "unicode composition", input: " Cafe\u0301\u2003dOr ", want: "café d'or"},
} {
t.Run(test.name, func(t *testing.T) {
if got := ComparisonKey(test.input); got != test.want {
t.Fatalf("ComparisonKey(%q) = %q, want %q", test.input, got, test.want)
}
})
}
if ComparisonKey("Mira Thorn") == ComparisonKey("Mira Thorne") {
t.Fatal("different names received the same comparison key")
}
}
func TestContainsTokenSequence(t *testing.T) {
tests := []struct {
name string