From: Stephen Morris Date: Wed, 22 Feb 2012 12:37:23 +0000 (+0000) Subject: [1605] RBNodeRRset tests now pass X-Git-Tag: trac2351_base~226^2~116^2~136^2~1^2~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f161f37c16c1ce2b84ca467b6f6302e0d7d7a462;p=thirdparty%2Fkea.git [1605] RBNodeRRset tests now pass --- diff --git a/src/lib/datasrc/rbnode_rrset.h b/src/lib/datasrc/rbnode_rrset.h index 854413afdf..f34685e268 100644 --- a/src/lib/datasrc/rbnode_rrset.h +++ b/src/lib/datasrc/rbnode_rrset.h @@ -60,6 +60,8 @@ class RBNodeRRset : public isc::dns::AbstractRRset { private: // Note: The copy constructor and the assignment operator are intentionally // defined as private as we would normally not duplicate a RBNodeRRset. + // (We use the "private" method instead of inheriting from boost::noncopyable + // so as to avoid multiple inheritance.) RBNodeRRset(const RBNodeRRset& source); RBNodeRRset& operator=(const RBNodeRRset& source); @@ -67,6 +69,8 @@ public: /// \brief Usual Constructor /// /// Creates an RBNodeRRset from the pointer to the RRset passed to it. + /// + /// \param rrset Pointer to underlying RRset encapsulated by this object. RBNodeRRset(const isc::dns::ConstRRsetPtr& rrset) : rrset_(rrset) {} /// \brief Destructor @@ -132,30 +136,50 @@ public: } virtual isc::dns::RRsetPtr getRRsig() const { - return (isc::dns::RRsetPtr()); + return (rrset_->getRRsig()); } - virtual void addRRsig(const isc::dns::rdata::ConstRdataPtr& /*rdata*/) { + // With all the RRsig methods, we have the problem that we store the + // underlying RRset using a ConstRRsetPtr - a pointer to a "const" RRset - + // but we need to modify it by adding or removing an RRSIG. We overcome + // this by temporarily violating the "const" nature of the RRset to add the + // data. + + virtual void addRRsig(const isc::dns::rdata::ConstRdataPtr& rdata) { + AbstractRRset* p = const_cast(rrset_.get()); + p->addRRsig(rdata); } - virtual void addRRsig(const isc::dns::rdata::RdataPtr& /*rdata*/) { + virtual void addRRsig(const isc::dns::rdata::RdataPtr& rdata) { + AbstractRRset* p = const_cast(rrset_.get()); + p->addRRsig(rdata); } - virtual void addRRsig(const AbstractRRset& /*sigs*/) { + virtual void addRRsig(const AbstractRRset& sigs) { + AbstractRRset* p = const_cast(rrset_.get()); + p->addRRsig(sigs); } - virtual void addRRsig(const isc::dns::ConstRRsetPtr& /*sigs*/) { + virtual void addRRsig(const isc::dns::ConstRRsetPtr& sigs) { + AbstractRRset* p = const_cast(rrset_.get()); + p->addRRsig(sigs); } - virtual void addRRsig(const isc::dns::RRsetPtr& /*sigs*/) { + virtual void addRRsig(const isc::dns::RRsetPtr& sigs) { + AbstractRRset* p = const_cast(rrset_.get()); + p->addRRsig(sigs); } virtual void removeRRsig() { + AbstractRRset* p = const_cast(rrset_.get()); + p->removeRRsig(); } /// \brief Return underlying RRset pointer + /// + /// ... mainly for testing. virtual isc::dns::ConstRRsetPtr getUnderlyingRRset() const { - return rrset_; + return (rrset_); } private: diff --git a/src/lib/datasrc/tests/rbnode_rrset_unittest.cc b/src/lib/datasrc/tests/rbnode_rrset_unittest.cc index e192b86b6c..db2b7f8bf0 100644 --- a/src/lib/datasrc/tests/rbnode_rrset_unittest.cc +++ b/src/lib/datasrc/tests/rbnode_rrset_unittest.cc @@ -203,13 +203,6 @@ TEST_F(RBNodeRRsetTest, LeftShiftOperator) { "test.example.com. 3600 IN A 192.0.2.2\n", oss.str()); } -// RRSIG-related tests. - - -TEST_F(RBNodeRRsetTest, addRRsigConstantRdataPointer) { - FAIL(); -} - // General RRSIG check function. Get the RRSIG from the RRset and check that // the RDATA is what we expect. void