BIND 10 trac2052, updated. dbef0e25199a8694e57e03fba704d5aa839ab3b7 [2052] Rename partial_compare() to just compare()

BIND 10 source code commits bind10-changes at lists.isc.org
Sun Jul 1 23:20:54 UTC 2012


The branch, trac2052 has been updated
       via  dbef0e25199a8694e57e03fba704d5aa839ab3b7 (commit)
       via  6b32945256d568825b2c0c07fd84d96efedd85bf (commit)
       via  87e091a226590e11fea99cc16af4c03a25f0b840 (commit)
      from  c09a49cd3d1cd3498a7c7fb778abbe5485989e65 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit dbef0e25199a8694e57e03fba704d5aa839ab3b7
Author: Mukund Sivaraman <muks at isc.org>
Date:   Mon Jul 2 04:50:16 2012 +0530

    [2052] Rename partial_compare() to just compare()

commit 6b32945256d568825b2c0c07fd84d96efedd85bf
Author: Mukund Sivaraman <muks at isc.org>
Date:   Mon Jul 2 04:50:01 2012 +0530

    [2052] Add getOrder() checks for all compare tests

commit 87e091a226590e11fea99cc16af4c03a25f0b840
Author: Mukund Sivaraman <muks at isc.org>
Date:   Mon Jul 2 04:49:28 2012 +0530

    [2052] Return order=0 when name comparison result is NONE

-----------------------------------------------------------------------

Summary of changes:
 src/lib/dns/labelsequence.cc                |   12 ++++++------
 src/lib/dns/name.cc                         |   18 +++++++++---------
 src/lib/dns/name.h                          |   12 ++++++------
 src/lib/dns/tests/labelsequence_unittest.cc |   23 ++++++++++++++++++++++-
 4 files changed, 43 insertions(+), 22 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/dns/labelsequence.cc b/src/lib/dns/labelsequence.cc
index 76aee18..acbafe4 100644
--- a/src/lib/dns/labelsequence.cc
+++ b/src/lib/dns/labelsequence.cc
@@ -78,12 +78,12 @@ LabelSequence::compare(const LabelSequence& other,
         return (NameComparisonResult(0, 0, NameComparisonResult::NONE));
     }
 
-    return (name_.partial_compare(other.name_,
-                                  first_label_,
-                                  other.first_label_,
-                                  last_label_,
-                                  other.last_label_,
-                                  case_sensitive));
+    return (name_.compare(other.name_,
+                          first_label_,
+                          other.first_label_,
+                          last_label_,
+                          other.last_label_,
+                          case_sensitive));
 }
 
 void
diff --git a/src/lib/dns/name.cc b/src/lib/dns/name.cc
index 87bf41e..a28f8d3 100644
--- a/src/lib/dns/name.cc
+++ b/src/lib/dns/name.cc
@@ -507,16 +507,16 @@ Name::toText(bool omit_final_dot) const {
 
 NameComparisonResult
 Name::compare(const Name& other) const {
-    return (partial_compare(other, 0, 0, labelcount_, other.labelcount_));
+    return (compare(other, 0, 0, labelcount_, other.labelcount_));
 }
 
 NameComparisonResult
-Name::partial_compare(const Name& other,
-                      unsigned int first_label,
-                      unsigned int first_label_other,
-                      unsigned int last_label,
-                      unsigned int last_label_other,
-                      bool case_sensitive) const {
+Name::compare(const Name& other,
+              unsigned int first_label,
+              unsigned int first_label_other,
+              unsigned int last_label,
+              unsigned int last_label_other,
+              bool case_sensitive) const {
     // Determine the relative ordering under the DNSSEC order relation of
     // 'this' and 'other', and also determine the hierarchical relationship
     // of the names.
@@ -568,7 +568,7 @@ Name::partial_compare(const Name& other,
                 if ((nlabels == 0) &&
                     ((last_label < labelcount_) ||
                      (last_label_other < other.labelcount_))) {
-                    return (NameComparisonResult(chdiff, 0,
+                    return (NameComparisonResult(0, 0,
                                                  NameComparisonResult::NONE));
                 } else {
                     return (NameComparisonResult(chdiff, nlabels,
@@ -583,7 +583,7 @@ Name::partial_compare(const Name& other,
             if ((nlabels == 0) &&
                 ((last_label < labelcount_) ||
                  (last_label_other < other.labelcount_))) {
-                return (NameComparisonResult(cdiff, 0,
+                return (NameComparisonResult(0, 0,
                                              NameComparisonResult::NONE));
             } else {
                 return (NameComparisonResult(cdiff, nlabels,
diff --git a/src/lib/dns/name.h b/src/lib/dns/name.h
index d6fb294..5089214 100644
--- a/src/lib/dns/name.h
+++ b/src/lib/dns/name.h
@@ -422,12 +422,12 @@ private:
     /// \param case_sensitive If true, comparison is case-insensitive
     /// \return a <code>NameComparisonResult</code> object representing the
     /// comparison result.
-    NameComparisonResult partial_compare(const Name& other,
-                                         unsigned int first_label,
-                                         unsigned int first_label_other,
-                                         unsigned int last_label,
-                                         unsigned int last_label_other,
-                                         bool case_sensitive = false) const;
+    NameComparisonResult compare(const Name& other,
+                                 unsigned int first_label,
+                                 unsigned int first_label_other,
+                                 unsigned int last_label,
+                                 unsigned int last_label_other,
+                                 bool case_sensitive = false) const;
 
 public:
     /// \brief Return true iff two names are equal.
diff --git a/src/lib/dns/tests/labelsequence_unittest.cc b/src/lib/dns/tests/labelsequence_unittest.cc
index 73aa601..228439a 100644
--- a/src/lib/dns/tests/labelsequence_unittest.cc
+++ b/src/lib/dns/tests/labelsequence_unittest.cc
@@ -131,18 +131,21 @@ TEST_F(LabelSequenceTest, compare) {
     NameComparisonResult result = ls1.compare(ls3, true);
     EXPECT_EQ(isc::dns::NameComparisonResult::EQUAL,
               result.getRelation());
+    EXPECT_EQ(0, result.getOrder());
     EXPECT_EQ(3, result.getCommonLabels());
 
     // "example.org." and "example.ORG.", case sensitive
     result = ls3.compare(ls5, true);
     EXPECT_EQ(isc::dns::NameComparisonResult::COMMONANCESTOR,
               result.getRelation());
+    EXPECT_LT(0, result.getOrder());
     EXPECT_EQ(1, result.getCommonLabels());
 
     // "example.org." and "example.ORG.", case in-sensitive
     result = ls3.compare(ls5);
     EXPECT_EQ(isc::dns::NameComparisonResult::EQUAL,
               result.getRelation());
+    EXPECT_EQ(0, result.getOrder());
     EXPECT_EQ(3, result.getCommonLabels());
 
     Name na("a.example.org");
@@ -154,6 +157,7 @@ TEST_F(LabelSequenceTest, compare) {
     result = lsa.compare(lsb);
     EXPECT_EQ(isc::dns::NameComparisonResult::COMMONANCESTOR,
               result.getRelation());
+    EXPECT_GT(0, result.getOrder());
     EXPECT_EQ(3, result.getCommonLabels());
 
     // "example.org." and "b.example.org.", case in-sensitive
@@ -161,6 +165,7 @@ TEST_F(LabelSequenceTest, compare) {
     result = lsa.compare(lsb);
     EXPECT_EQ(isc::dns::NameComparisonResult::SUPERDOMAIN,
               result.getRelation());
+    EXPECT_GT(0, result.getOrder());
     EXPECT_EQ(3, result.getCommonLabels());
 
     Name nc("g.f.e.d.c.example.org");
@@ -172,13 +177,14 @@ TEST_F(LabelSequenceTest, compare) {
     result = lsc.compare(lsb);
     EXPECT_EQ(isc::dns::NameComparisonResult::NONE,
               result.getRelation());
-    EXPECT_EQ(0, result.getCommonLabels());
     EXPECT_EQ(0, result.getOrder());
+    EXPECT_EQ(0, result.getCommonLabels());
 
     // "g.f.e.d.c.example.org." and "example.org.", case in-sensitive
     result = lsc.compare(ls1);
     EXPECT_EQ(isc::dns::NameComparisonResult::SUBDOMAIN,
               result.getRelation());
+    EXPECT_LT(0, result.getOrder());
     EXPECT_EQ(3, result.getCommonLabels());
 
     // "e.d.c.example.org." and "example.org.", case in-sensitive
@@ -186,6 +192,7 @@ TEST_F(LabelSequenceTest, compare) {
     result = lsc.compare(ls1);
     EXPECT_EQ(isc::dns::NameComparisonResult::SUBDOMAIN,
               result.getRelation());
+    EXPECT_LT(0, result.getOrder());
     EXPECT_EQ(3, result.getCommonLabels());
 
     // "example.org." and "example.org.", case in-sensitive
@@ -193,6 +200,7 @@ TEST_F(LabelSequenceTest, compare) {
     result = lsc.compare(ls1);
     EXPECT_EQ(isc::dns::NameComparisonResult::EQUAL,
               result.getRelation());
+    EXPECT_EQ(0, result.getOrder());
     EXPECT_EQ(3, result.getCommonLabels());
 
     // "." and "example.org.", case in-sensitive
@@ -200,6 +208,7 @@ TEST_F(LabelSequenceTest, compare) {
     result = lsc.compare(ls1);
     EXPECT_EQ(isc::dns::NameComparisonResult::SUPERDOMAIN,
               result.getRelation());
+    EXPECT_GT(0, result.getOrder());
     EXPECT_EQ(1, result.getCommonLabels());
 
     Name nd("a.b.c.isc.example.org");
@@ -212,6 +221,7 @@ TEST_F(LabelSequenceTest, compare) {
     result = lsd.compare(lse, true);
     EXPECT_EQ(isc::dns::NameComparisonResult::COMMONANCESTOR,
               result.getRelation());
+    EXPECT_LT(0, result.getOrder());
     EXPECT_EQ(2, result.getCommonLabels());
 
     // "a.b.c.isc.example.org." and "w.x.y.isc.EXAMPLE.org.",
@@ -219,6 +229,7 @@ TEST_F(LabelSequenceTest, compare) {
     result = lsd.compare(lse);
     EXPECT_EQ(isc::dns::NameComparisonResult::COMMONANCESTOR,
               result.getRelation());
+    EXPECT_GT(0, result.getOrder());
     EXPECT_EQ(4, result.getCommonLabels());
 
     // "isc.example.org." and "isc.EXAMPLE.org.", case sensitive
@@ -227,12 +238,14 @@ TEST_F(LabelSequenceTest, compare) {
     result = lsd.compare(lse, true);
     EXPECT_EQ(isc::dns::NameComparisonResult::COMMONANCESTOR,
               result.getRelation());
+    EXPECT_LT(0, result.getOrder());
     EXPECT_EQ(2, result.getCommonLabels());
 
     // "isc.example.org." and "isc.EXAMPLE.org.", case in-sensitive
     result = lsd.compare(lse);
     EXPECT_EQ(isc::dns::NameComparisonResult::EQUAL,
               result.getRelation());
+    EXPECT_EQ(0, result.getOrder());
     EXPECT_EQ(4, result.getCommonLabels());
 
     Name nf("a.b.c.isc.example.org");
@@ -246,6 +259,7 @@ TEST_F(LabelSequenceTest, compare) {
     result = lsg.compare(lsf);
     EXPECT_EQ(isc::dns::NameComparisonResult::NONE,
               result.getRelation());
+    EXPECT_EQ(0, result.getOrder());
     EXPECT_EQ(0, result.getCommonLabels());
 
     // "a.b.c.isc.example.org" (not absolute) and
@@ -254,6 +268,7 @@ TEST_F(LabelSequenceTest, compare) {
     result = lsg.compare(lsf);
     EXPECT_EQ(isc::dns::NameComparisonResult::COMMONANCESTOR,
               result.getRelation());
+    EXPECT_LT(0, result.getOrder());
     EXPECT_EQ(3, result.getCommonLabels());
 
     // "a.b.c.isc.example" (not absolute) and
@@ -263,6 +278,7 @@ TEST_F(LabelSequenceTest, compare) {
     result = lsg.compare(lsf);
     EXPECT_EQ(isc::dns::NameComparisonResult::COMMONANCESTOR,
               result.getRelation());
+    EXPECT_LT(0, result.getOrder());
     EXPECT_EQ(2, result.getCommonLabels());
 
     // "a.b.c" (not absolute) and
@@ -272,6 +288,7 @@ TEST_F(LabelSequenceTest, compare) {
     result = lsg.compare(lsf);
     EXPECT_EQ(isc::dns::NameComparisonResult::NONE,
               result.getRelation());
+    EXPECT_EQ(0, result.getOrder());
     EXPECT_EQ(0, result.getCommonLabels());
 
     Name nh("aexample.org");
@@ -286,6 +303,7 @@ TEST_F(LabelSequenceTest, compare) {
     result = lsh.compare(lsi);
     EXPECT_EQ(isc::dns::NameComparisonResult::COMMONANCESTOR,
               result.getRelation());
+    EXPECT_GT(0, result.getOrder());
     EXPECT_EQ(1, result.getCommonLabels());
 
     // "aexample" (not absolute) and
@@ -295,6 +313,7 @@ TEST_F(LabelSequenceTest, compare) {
     result = lsh.compare(lsi);
     EXPECT_EQ(isc::dns::NameComparisonResult::NONE,
               result.getRelation());
+    EXPECT_EQ(0, result.getOrder());
     EXPECT_EQ(0, result.getCommonLabels());
 
     Name nj("example.org");
@@ -309,6 +328,7 @@ TEST_F(LabelSequenceTest, compare) {
     result = lsj.compare(lsk);
     EXPECT_EQ(isc::dns::NameComparisonResult::EQUAL,
               result.getRelation());
+    EXPECT_EQ(0, result.getOrder());
     EXPECT_EQ(2, result.getCommonLabels());
 
     // "example" (not absolute) and
@@ -318,6 +338,7 @@ TEST_F(LabelSequenceTest, compare) {
     result = lsj.compare(lsk);
     EXPECT_EQ(isc::dns::NameComparisonResult::EQUAL,
               result.getRelation());
+    EXPECT_EQ(0, result.getOrder());
     EXPECT_EQ(1, result.getCommonLabels());
 }
 



More information about the bind10-changes mailing list