Browse Source

[2377] Use rrsetCheck() for comparing RRsets

Comparing their toText() might be unreliable. In theory, the toText()
result could be slightly different even for equal RRsets (if their
background implementation is different) and the test fail.

Include a hack for the rrsetCheck interface being incompatible.
Michal 'vorner' Vaner 12 years ago
parent
commit
03911f1000
1 changed files with 16 additions and 1 deletions
  1. 16 1
      src/lib/datasrc/tests/master_loader_callbacks_test.cc

+ 16 - 1
src/lib/datasrc/tests/master_loader_callbacks_test.cc

@@ -20,6 +20,8 @@
 #include <dns/rrttl.h>
 #include <dns/rdata.h>
 
+#include <testutils/dnsmessage_test.h>
+
 #include <exceptions/exceptions.h>
 
 #include <gtest/gtest.h>
@@ -42,7 +44,20 @@ public:
     virtual void addRRset(const isc::dns::AbstractRRset& rrset) {
         ASSERT_FALSE(expected_rrsets_.empty());
 
-        EXPECT_EQ(expected_rrsets_.front().get()->toText(), rrset.toText());
+        // As the rrsetCheck requires a shared pointer, we need to create
+        // a copy.
+        isc::dns::RRsetPtr copy(new isc::dns::BasicRRset(rrset.getName(),
+                                                         rrset.getClass(),
+                                                         rrset.getType(),
+                                                         rrset.getTTL()));
+        EXPECT_FALSE(rrset.getRRsig()) << "Unexpected RRSIG on rrset, not "
+            "copying. Following check will likely fail as a result.";
+        for (isc::dns::RdataIteratorPtr it(rrset.getRdataIterator());
+             !it->isLast(); it->next()) {
+            copy->addRdata(it->getCurrent());
+        }
+
+        isc::testutils::rrsetCheck(expected_rrsets_.front(), copy);
         // And remove this RRset, as it has been used.
         expected_rrsets_.pop_front();
     }