Repair reversed D&D evidence ranges
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user