]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[1641] added tests for NSEC::compare(). there's no bug, just confirming it.
authorJINMEI Tatuya <jinmei@isc.org>
Sat, 11 Feb 2012 01:25:46 +0000 (17:25 -0800)
committerJINMEI Tatuya <jinmei@isc.org>
Sat, 11 Feb 2012 01:25:46 +0000 (17:25 -0800)
src/lib/dns/tests/rdata_nsec3_unittest.cc
src/lib/dns/tests/rdata_nsec_unittest.cc

index 282e3178eb66dbd60d4f620979a1371c2b679111..0364d1e8d35f48789301bf6bc97e2d544864da10 100644 (file)
@@ -269,7 +269,6 @@ TEST_F(Rdata_NSEC3_Test, compare) {
         EXPECT_GT(0, (*it).compare(*(it + 1)));
         EXPECT_LT(0, (*(it + 1)).compare(*it));
     }
-
 }
 
 }
index f081cd8216d670557ff14cfd3394e3b63c1b7764..feb70c210db2958d8554b5942a7eb32cf10df31b 100644 (file)
@@ -38,7 +38,7 @@ class Rdata_NSEC_Test : public RdataTest {
     // there's nothing to specialize
 };
 
-string nsec_txt("www2.isc.org. CNAME RRSIG NSEC");
+const char* const nsec_txt = "www2.isc.org. CNAME RRSIG NSEC";
 
 TEST_F(Rdata_NSEC_Test, toText_NSEC) {
     const generic::NSEC rdata_nsec(nsec_txt);
@@ -95,4 +95,31 @@ TEST_F(Rdata_NSEC_Test, getNextName) {
     EXPECT_EQ(Name("www2.isc.org"), generic::NSEC((nsec_txt)).getNextName());
 }
 
+TEST_F(Rdata_NSEC_Test, compare) {
+    // trivial case: self equivalence
+    EXPECT_EQ(0, generic::NSEC("example A").
+              compare(generic::NSEC("example. A")));
+    EXPECT_EQ(0, generic::NSEC("EXAMPLE A"). // should be case insensitive
+              compare(generic::NSEC("example. A")));
+
+    // comparison attempt between incompatible RR types should be rejected
+    EXPECT_THROW(generic::NSEC(nsec_txt).compare(*rdata_nomatch),
+                 bad_cast);
+
+    // test RDATAs, sorted in the ascendent order.  We only compare the
+    // next name here.  Bitmap comparison is tested in the bitmap tests.
+    // Note that names are compared as wire-format data, not based on the
+    // domain name comparison.
+    vector<generic::NSEC> compare_set;
+    compare_set.push_back(generic::NSEC("a.example. A"));
+    compare_set.push_back(generic::NSEC("example. A"));
+    vector<generic::NSEC>::const_iterator it;
+    const vector<generic::NSEC>::const_iterator it_end = compare_set.end();
+    for (it = compare_set.begin(); it != it_end - 1; ++it) {
+        SCOPED_TRACE("compare " + it->toText() + " to " + (it + 1)->toText());
+        EXPECT_GT(0, (*it).compare(*(it + 1)));
+        EXPECT_LT(0, (*(it + 1)).compare(*it));
+    }
+}
+
 }