Finish the D&D module cleanup

This commit is contained in:
2026-07-25 13:30:23 +00:00
parent aeaaf44ae0
commit 29ee68824d
14 changed files with 76 additions and 366 deletions

View File

@@ -60,19 +60,22 @@ func TestSourceRefOrderCanonicalizePreservesRepresentationAndOwnership(t *testin
func TestSourceRefOrderSnapshotAndEarliestValid(t *testing.T) {
doc := unitRefSourceDocument(30, 10, 20)
order := NewSourceRefOrder(doc)
sourceID := doc.ID
index := source.NewDocumentIndex(doc)
order := NewSourceRefOrderFromIndex(index)
doc.ID = "changed"
doc.Units[0].ID, doc.Units[1].ID = 10, 30
refs := []source.SourceRef{
{SourceID: doc.ID, StartUnitID: 20, EndUnitID: 20},
{SourceID: doc.ID, StartUnitID: 10, EndUnitID: 10},
{SourceID: sourceID, StartUnitID: 20, EndUnitID: 20},
{SourceID: sourceID, StartUnitID: 10, EndUnitID: 10},
{SourceID: "other", StartUnitID: 1, EndUnitID: 1},
{SourceID: doc.ID, StartUnitID: 999, EndUnitID: 999},
{SourceID: doc.ID, StartUnitID: 20, EndUnitID: 30},
{SourceID: sourceID, StartUnitID: 999, EndUnitID: 999},
{SourceID: sourceID, StartUnitID: 20, EndUnitID: 30},
}
if position, ok := order.EarliestValid(refs); !ok || position != 1 {
t.Fatalf("EarliestValid() = %d, %t, want 1, true", position, ok)
}
if position, ok := order.EarliestValid([]source.SourceRef{{SourceID: doc.ID, StartUnitID: 20, EndUnitID: 30}}); ok || position != 0 {
if position, ok := order.EarliestValid([]source.SourceRef{{SourceID: sourceID, StartUnitID: 20, EndUnitID: 30}}); ok || position != 0 {
t.Fatalf("EarliestValid(invalid) = %d, %t, want 0, false", position, ok)
}
if position, ok := (SourceRefOrder{}).EarliestValid(refs); ok || position != 0 {