]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
Merge branch 'master' into trac2052
authorMukund Sivaraman <muks@isc.org>
Tue, 3 Jul 2012 01:14:42 +0000 (06:44 +0530)
committerMukund Sivaraman <muks@isc.org>
Tue, 3 Jul 2012 01:14:42 +0000 (06:44 +0530)
Conflicts:
src/lib/dns/name.cc

1  2 
src/lib/dns/labelsequence.cc
src/lib/dns/labelsequence.h
src/lib/dns/name.cc
src/lib/dns/name.h
src/lib/dns/tests/labelsequence_unittest.cc

Simple merge
Simple merge
index a28f8d33bd192da70ecc025235d36aa7f4c8554c,5630435d0a802d0fd66dd0a15411c053f0df1902..a8b080c438ca62f971491383b20deea8f28fac50
@@@ -554,26 -534,13 +554,26 @@@ Name::compare(const Name& other
          unsigned int count = (cdiff < 0) ? count1 : count2;
  
          while (count > 0) {
-             unsigned char label1 = ndata_[pos1];
-             unsigned char label2 = other.ndata_[pos2];
+             uint8_t label1 = ndata_[pos1];
+             uint8_t label2 = other.ndata_[pos2];
 +            int chdiff;
 +
 +            if (case_sensitive) {
 +                chdiff = (int)label1 - (int)label2;
 +            } else {
 +                chdiff = (int)maptolower[label1] - (int)maptolower[label2];
 +            }
  
 -            int chdiff = (int)maptolower[label1] - (int)maptolower[label2];
              if (chdiff != 0) {
 -                return (NameComparisonResult(chdiff, nlabels,
 -                                         NameComparisonResult::COMMONANCESTOR));
 +                if ((nlabels == 0) &&
 +                    ((last_label < labelcount_) ||
 +                     (last_label_other < other.labelcount_))) {
 +                    return (NameComparisonResult(0, 0,
 +                                                 NameComparisonResult::NONE));
 +                } else {
 +                    return (NameComparisonResult(chdiff, nlabels,
 +                                                 NameComparisonResult::COMMONANCESTOR));
 +                }
              }
              --count;
              ++pos1;
Simple merge
index 228439acbbf6290fdb3bcd672e2236dbb7bcf5cf,0e1fd5ee8c8ea3599cdd81c54ed46c47e665e74a..d1671a250fb8ed45dc568a54b92ce2037b042d15
@@@ -123,227 -135,15 +135,232 @@@ TEST_F(LabelSequenceTest, equals_insens
      EXPECT_TRUE(ls5.equals(ls5));
      EXPECT_TRUE(ls5.equals(ls6));
      EXPECT_FALSE(ls5.equals(ls7));
+     EXPECT_TRUE(ls9.equals(ls10));
+     EXPECT_FALSE(ls9.equals(ls11));
+     EXPECT_FALSE(ls9.equals(ls12));
+     EXPECT_TRUE(ls11.equals(ls12));
  }
  
 +// Compare tests
 +TEST_F(LabelSequenceTest, compare) {
 +    // "example.org." and "example.org.", case sensitive
 +    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");
 +    Name nb("b.example.org");
 +    LabelSequence lsa(na);
 +    LabelSequence lsb(nb);
 +
 +    // "a.example.org." and "b.example.org.", case in-sensitive
 +    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
 +    lsa.stripLeft(1);
 +    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");
 +    LabelSequence lsc(nc);
 +
 +    // "g.f.e.d.c.example.org." and "b.example.org" (not absolute), case
 +    // in-sensitive
 +    lsb.stripRight(1);
 +    result = lsc.compare(lsb);
 +    EXPECT_EQ(isc::dns::NameComparisonResult::NONE,
 +              result.getRelation());
 +    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
 +    lsc.stripLeft(2);
 +    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
 +    lsc.stripLeft(3);
 +    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
 +    lsc.stripLeft(2);
 +    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");
 +    LabelSequence lsd(nd);
 +    Name ne("w.x.y.isc.EXAMPLE.org");
 +    LabelSequence lse(ne);
 +
 +    // "a.b.c.isc.example.org." and "w.x.y.isc.EXAMPLE.org.",
 +    // case sensitive
 +    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.",
 +    // case in-sensitive
 +    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
 +    lsd.stripLeft(3);
 +    lse.stripLeft(3);
 +    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");
 +    LabelSequence lsf(nf);
 +    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
 +    lsg.stripRight(1);
 +    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
 +    // "w.x.y.isc.EXAMPLE.org" (not absolute), case in-sensitive
 +    lsf.stripRight(1);
 +    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
 +    // "w.x.y.isc.EXAMPLE" (not absolute), case in-sensitive
 +    lsf.stripRight(1);
 +    lsg.stripRight(1);
 +    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
 +    // "w.x.y" (not absolute), case in-sensitive
 +    lsf.stripRight(2);
 +    lsg.stripRight(2);
 +    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");
 +    LabelSequence lsh(nh);
 +    Name ni("bexample.org");
 +    LabelSequence lsi(ni);
 +
 +    // "aexample.org" (not absolute) and
 +    // "bexample.org" (not absolute), case in-sensitive
 +    lsh.stripRight(1);
 +    lsi.stripRight(1);
 +    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
 +    // "bexample" (not absolute), case in-sensitive
 +    lsh.stripRight(1);
 +    lsi.stripRight(1);
 +    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");
 +    LabelSequence lsj(nj);
 +    Name nk("example.org");
 +    LabelSequence lsk(nk);
 +
 +    // "example.org" (not absolute) and
 +    // "example.org" (not absolute), case in-sensitive
 +    lsj.stripRight(1);
 +    lsk.stripRight(1);
 +    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
 +    // "example" (not absolute), case in-sensitive
 +    lsj.stripRight(1);
 +    lsk.stripRight(1);
 +    result = lsj.compare(lsk);
 +    EXPECT_EQ(isc::dns::NameComparisonResult::EQUAL,
 +              result.getRelation());
 +    EXPECT_EQ(0, result.getOrder());
 +    EXPECT_EQ(1, result.getCommonLabels());
 +}
 +
  void
- getDataCheck(const char* expected_data, size_t expected_len,
+ getDataCheck(const uint8_t* expected_data, size_t expected_len,
               const LabelSequence& ls)
  {
      size_t len;