From: Mukund Sivaraman Date: Wed, 26 Dec 2012 04:58:32 +0000 (+0530) Subject: [2432] Add zero-argument RRsetCollection constructor X-Git-Tag: bind10-1.0.0-rc-release~156 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7383457001cd2b6d78ec755f1cf20fa4529a43ab;p=thirdparty%2Fkea.git [2432] Add zero-argument RRsetCollection constructor --- diff --git a/src/lib/dns/rrset_collection.h b/src/lib/dns/rrset_collection.h index 5c6f8fd24c..37db6cca4f 100644 --- a/src/lib/dns/rrset_collection.h +++ b/src/lib/dns/rrset_collection.h @@ -30,6 +30,10 @@ namespace dns { /// container. class RRsetCollection : public RRsetCollectionBase { public: + /// \brief Constructor. + RRsetCollection() + {} + /// \brief Constructor. /// /// The \c origin and \c rrclass arguments are required for the zone diff --git a/src/lib/dns/tests/rrset_collection_unittest.cc b/src/lib/dns/tests/rrset_collection_unittest.cc index 6cbd2f9ac8..b222c45b82 100644 --- a/src/lib/dns/tests/rrset_collection_unittest.cc +++ b/src/lib/dns/tests/rrset_collection_unittest.cc @@ -126,6 +126,9 @@ doAddAndRemove(RRsetCollection& collection, const RRClass& rrclass) { EXPECT_EQ(RRClass("IN"), rrset_found->getClass()); EXPECT_EQ(Name("foo.example.org"), rrset_found->getName()); + // The collection must not be empty. + EXPECT_NE(collection.end(), collection.begin()); + // Remove foo.example.org/A collection.removeRRset(Name("foo.example.org"), rrclass, RRType::A()); @@ -139,6 +142,19 @@ TEST_F(RRsetCollectionTest, addAndRemove) { doAddAndRemove(collection, rrclass); } +TEST_F(RRsetCollectionTest, empty) { + RRsetCollection cln; + + // Here, cln is empty. + EXPECT_EQ(cln.end(), cln.begin()); + + doAddAndRemove(cln, rrclass); + + // cln should be empty again here, after the add and remove + // operations. + EXPECT_EQ(cln.end(), cln.begin()); +} + TEST_F(RRsetCollectionTest, iteratorTest) { // The collection must not be empty. EXPECT_NE(collection.end(), collection.begin());