Finish the D&D module cleanup
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user