Repair reversed D&D evidence ranges

This commit is contained in:
2026-08-28 13:45:21 +00:00
parent a2610757cd
commit b178f1c684
36 changed files with 226 additions and 61 deletions

View File

@@ -58,6 +58,38 @@ func TestSourceRefOrderCanonicalizePreservesRepresentationAndOwnership(t *testin
}
}
func TestSourceRefOrderOrdersOnlyResolvableCurrentSourceEndpoints(t *testing.T) {
doc := unitRefSourceDocument(30, 10, 20)
order := NewSourceRefOrder(doc)
input := []source.SourceRef{
{SourceID: doc.ID, StartUnitID: 30, EndUnitID: 10},
{SourceID: doc.ID, StartUnitID: 20, EndUnitID: 30},
{SourceID: doc.ID, StartUnitID: 10, EndUnitID: 10},
{SourceID: "other", StartUnitID: 20, EndUnitID: 30},
{SourceID: doc.ID, StartUnitID: 999, EndUnitID: 30},
{SourceID: doc.ID, StartUnitID: 20, EndUnitID: 0},
}
want := []source.SourceRef{
{SourceID: doc.ID, StartUnitID: 30, EndUnitID: 10},
{SourceID: doc.ID, StartUnitID: 30, EndUnitID: 20},
{SourceID: doc.ID, StartUnitID: 10, EndUnitID: 10},
{SourceID: "other", StartUnitID: 20, EndUnitID: 30},
{SourceID: doc.ID, StartUnitID: 999, EndUnitID: 30},
{SourceID: doc.ID, StartUnitID: 20, EndUnitID: 0},
}
got := order.OrderEndpoints(input)
if !reflect.DeepEqual(got, want) {
t.Fatalf("OrderEndpoints() = %#v, want %#v", got, want)
}
got[0].StartUnitID = 999
if input[0].StartUnitID != 30 {
t.Fatal("OrderEndpoints() output aliases input")
}
if got := order.OrderEndpoints(nil); got != nil {
t.Fatalf("OrderEndpoints(nil) = %#v, want nil", got)
}
}
func TestSourceRefOrderSnapshotAndEarliestValid(t *testing.T) {
doc := unitRefSourceDocument(30, 10, 20)
sourceID := doc.ID