Reuse canonical item occurrence evidence
This commit is contained in:
@@ -108,6 +108,14 @@ func TestLessAndExactEqualityCanonicalizeEvidence(t *testing.T) {
|
||||
if ExactIdentity(order, first) != ExactIdentity(order, second) {
|
||||
t.Fatal("ExactIdentity() differs for canonical duplicates")
|
||||
}
|
||||
canonicalFirst := first
|
||||
canonicalFirst.SourceRefs = order.Canonicalize(first.SourceRefs)
|
||||
if !CanonicalExactEqual(canonicalFirst, second) || CanonicalExactIdentity(canonicalFirst) != CanonicalExactIdentity(second) {
|
||||
t.Fatal("canonical helpers did not recognize canonical duplicates")
|
||||
}
|
||||
if CanonicalExactEqual(first, second) || CanonicalExactIdentity(first) == CanonicalExactIdentity(second) {
|
||||
t.Fatal("canonical helpers repaired noncanonical source references")
|
||||
}
|
||||
|
||||
quantity := 1
|
||||
differentQuantity := second
|
||||
@@ -132,6 +140,12 @@ func TestSourceReferenceHelpers(t *testing.T) {
|
||||
if ValidSourceRefs(source.NewDocumentIndex(doc), []source.SourceRef{{SourceID: "other", StartUnitID: 10, EndUnitID: 20}}) {
|
||||
t.Fatal("ValidSourceRefs() = true, want invalid source identifier rejection")
|
||||
}
|
||||
nilEvidence := dnd.ItemOccurrence{ItemID: "item"}
|
||||
emptyEvidence := nilEvidence
|
||||
emptyEvidence.SourceRefs = []source.SourceRef{}
|
||||
if CanonicalExactIdentity(nilEvidence) == CanonicalExactIdentity(emptyEvidence) {
|
||||
t.Fatal("CanonicalExactIdentity() conflated nil and empty source references")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLessSortsMalformedReferencesDeterministically(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user