Reuse duplicate grouping for combat turns and spells

This commit is contained in:
2026-11-26 02:54:33 +00:00
parent f9dd53f4c2
commit 26da344f27
7 changed files with 84 additions and 88 deletions

View File

@@ -357,6 +357,20 @@ func TestNormalizeKeepsDistinctAndIneligibleCastsSeparate(t *testing.T) {
}
}
func TestDuplicateGroupingPreservesUnchangedSpellListStorage(t *testing.T) {
normalizer := newNormalizer(t)
index := source.NewDocumentIndex(sourceDocument(3))
for _, input := range []dnd.SpellList{{}, {SpellCasts: []dnd.SpellCast{}}, {SpellCasts: []dnd.SpellCast{{Spell: "Cure Wounds", Caster: "Aria", SourceRefs: []source.SourceRef{{SourceID: "source", StartUnitID: 1, EndUnitID: 1}}}}}} {
output, findings := collapseDuplicateSpellCasts(input, index, normalizer.effectiveCatalog)
if !reflect.DeepEqual(output, input) || findings != nil {
t.Fatalf("unchanged = %#v, %#v, want %#v", output, findings, input)
}
if len(input.SpellCasts) > 0 && &output.SpellCasts[0] != &input.SpellCasts[0] {
t.Fatal("unchanged list replaced its storage")
}
}
}
func TestNormalizeDoesNotCollapseAdjacentOrOverlappingEvidence(t *testing.T) {
doc := sourceDocument(8)
input := dnd.SpellList{SpellCasts: []dnd.SpellCast{