Parcourir la source

[2091a] even further simplification; no need for explicit absolute check.

if one is absoulte and the other is not, they won't have common labels,
so the main logic can detect their relationship is NONE.  We don't need
to handle this case separately for performance (if that was the reason)
because we generally don't expect to do this type of mismatch comparison.

unit tests need to be adjusted because the order is now non 0.
JINMEI Tatuya il y a 12 ans
Parent
commit
34f0efc429
2 fichiers modifiés avec 8 ajouts et 12 suppressions
  1. 0 4
      src/lib/dns/labelsequence.cc
  2. 8 8
      src/lib/dns/tests/labelsequence_unittest.cc

+ 0 - 4
src/lib/dns/labelsequence.cc

@@ -112,10 +112,6 @@ NameComparisonResult
 LabelSequence::compare(const LabelSequence& other,
                        bool case_sensitive) const
 {
-    if (isAbsolute() ^ other.isAbsolute()) {
-        return (NameComparisonResult(0, 0, NameComparisonResult::NONE));
-    }
-
     // Determine the relative ordering under the DNSSEC order relation of
     // 'this' and 'other', and also determine the hierarchical relationship
     // of the names.

+ 8 - 8
src/lib/dns/tests/labelsequence_unittest.cc

@@ -189,11 +189,11 @@ TEST_F(LabelSequenceTest, compare) {
     LabelSequence lsc(nc);
 
     // "g.f.e.d.c.example.org." and "b.example.org" (not absolute), case
-    // in-sensitive
+    // in-sensitive; the absolute one is always smaller.
     lsb.stripRight(1);
     result = lsc.compare(lsb);
     EXPECT_EQ(isc::dns::NameComparisonResult::NONE, result.getRelation());
-    EXPECT_EQ(0, result.getOrder());
+    EXPECT_GT(0, result.getOrder());
     EXPECT_EQ(0, result.getCommonLabels());
 
     // "g.f.e.d.c.example.org." and "example.org.", case in-sensitive
@@ -269,13 +269,13 @@ TEST_F(LabelSequenceTest, compare) {
     Name ng("w.x.y.isc.EXAMPLE.org");
     LabelSequence lsg(ng);
 
-    // "a.b.c.isc.example.org." and "w.x.y.isc.EXAMPLE.org" (not
-    // absolute), case in-sensitive
+    // lsf: "a.b.c.isc.example.org."
+    // lsg: "w.x.y.isc.EXAMPLE.org" (not absolute), case in-sensitive.
+    // the absolute one is always smaller.
     lsg.stripRight(1);
-    result = lsg.compare(lsf);
-    EXPECT_EQ(isc::dns::NameComparisonResult::NONE,
-              result.getRelation());
-    EXPECT_EQ(0, result.getOrder());
+    result = lsg.compare(lsf);  // lsg > lsf
+    EXPECT_EQ(isc::dns::NameComparisonResult::NONE, result.getRelation());
+    EXPECT_LT(0, result.getOrder());
     EXPECT_EQ(0, result.getCommonLabels());
 
     // "a.b.c.isc.example.org" (not absolute) and