Commit b26f6251 authored by Mukund Sivaraman's avatar Mukund Sivaraman
Browse files

Merge branch 'trac3263_2'

parents c9505d8f 5519de5b
...@@ -376,6 +376,13 @@ public: ...@@ -376,6 +376,13 @@ public:
/// Still, this version would offer a more intuitive interface and is /// Still, this version would offer a more intuitive interface and is
/// provided as such. /// provided as such.
/// ///
/// NOTE: Because a new Rdata object is constructed, this method can
/// throw a std::bad_cast exception if this RRset's class is NONE,
/// or if some other error occurs. If you want to be able to add
/// RDATA to an RRset whose class is NONE, please use the other
/// variant of \c addRdata() which accepts a \c ConstRdataPtr
/// argument.
///
/// \param rdata A reference to a \c rdata::RdataPtr (derived) class /// \param rdata A reference to a \c rdata::RdataPtr (derived) class
/// object, a copy of which is to be added to the \c RRset. /// object, a copy of which is to be added to the \c RRset.
virtual void addRdata(const rdata::Rdata& rdata) = 0; virtual void addRdata(const rdata::Rdata& rdata) = 0;
......
...@@ -157,14 +157,22 @@ TEST_F(RRsetTest, addRdataPtr) { ...@@ -157,14 +157,22 @@ TEST_F(RRsetTest, addRdataPtr) {
rrset_a_empty.addRdata(createRdata(rrset_a_empty.getType(), rrset_a_empty.addRdata(createRdata(rrset_a_empty.getType(),
rrset_a_empty.getClass(), rrset_a_empty.getClass(),
"192.0.2.2")); "192.0.2.2"));
addRdataTestCommon(rrset_a); addRdataTestCommon(rrset_a);
}
TEST_F(RRsetTest, addRdataPtrMismatched) {
// Pointer version of addRdata() doesn't type check and does allow to // Pointer version of addRdata() doesn't type check and does allow to
//add a different type of Rdata as a result. //add a different type of Rdata as a result.
// Type mismatch
rrset_a_empty.addRdata(createRdata(RRType::NS(), RRClass::IN(), rrset_a_empty.addRdata(createRdata(RRType::NS(), RRClass::IN(),
"ns.example.com.")); "ns.example.com."));
EXPECT_EQ(3, rrset_a_empty.getRdataCount()); EXPECT_EQ(1, rrset_a_empty.getRdataCount());
// Class mismatch
rrset_ch_txt.addRdata(createRdata(RRType::TXT(), RRClass::IN(),
"Test String"));
EXPECT_EQ(1, rrset_ch_txt.getRdataCount());
} }
TEST_F(RRsetTest, iterator) { TEST_F(RRsetTest, iterator) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment