]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[1749] Implement a specialized RBNodeRRset::isSameKind()
authorMukund Sivaraman <muks@isc.org>
Sun, 11 Mar 2012 08:44:51 +0000 (14:14 +0530)
committerMukund Sivaraman <muks@isc.org>
Wed, 14 Mar 2012 02:26:33 +0000 (07:56 +0530)
src/lib/datasrc/rbnode_rrset.h
src/lib/datasrc/tests/rbnode_rrset_unittest.cc

index f68791963094ea4fefe8275bce00d36cee936ac8..f0e1f6fd21615c70b6515e5aafde0f050d0871de 100644 (file)
@@ -127,6 +127,17 @@ public:
 
     virtual std::string toText() const;
 
+    virtual bool isSameKind(const AbstractRRset& other) {
+        const AbstractRRset* t = &other;
+        const RBNodeRRset* rb;
+
+        rb = dynamic_cast<const RBNodeRRset*>(t);
+        if (rb)
+          return (this == rb);
+        else
+          return AbstractRRset::isSameKind(other);
+    }
+
     virtual unsigned int toWire(
         isc::dns::AbstractMessageRenderer& renderer) const;
 
index a46d9cfe3f6827c795f45b99e28d9f551af6a519..005f7d2c91506abc2088abef4d4a1398f415f63c 100644 (file)
@@ -138,6 +138,23 @@ TEST_F(RBNodeRRsetTest, toText) {
     EXPECT_THROW(rrset_a_empty.toText(), EmptyRRset);
 }
 
+TEST_F(RBNodeRRsetTest, isSameKind) {
+    RBNodeRRset rrset_p(ConstRRsetPtr(new RRset(test_name, RRClass::IN(), RRType::A(), RRTTL(3600))));
+    RBNodeRRset rrset_q(ConstRRsetPtr(new RRset(test_name, RRClass::IN(), RRType::A(), RRTTL(3600))));
+    RRset rrset_w(test_name, RRClass::IN(), RRType::A(), RRTTL(3600));
+    RRset rrset_x(test_name, RRClass::IN(), RRType::A(), RRTTL(3600));
+    RRset rrset_y(test_name, RRClass::IN(), RRType::NS(), RRTTL(3600));
+    RRset rrset_z(test_name, RRClass::CH(), RRType::A(), RRTTL(3600));
+
+    EXPECT_TRUE(rrset_p.isSameKind(rrset_p));
+    EXPECT_FALSE(rrset_p.isSameKind(rrset_q));
+
+    EXPECT_TRUE(rrset_p.isSameKind(rrset_w));
+    EXPECT_TRUE(rrset_p.isSameKind(rrset_x));
+    EXPECT_FALSE(rrset_p.isSameKind(rrset_y));
+    EXPECT_FALSE(rrset_p.isSameKind(rrset_z));
+}
+
 // Note: although the next two tests are essentially the same and used common
 // test code, they use different test data: the MessageRenderer produces
 // compressed wire data whereas the OutputBuffer does not.