Browse Source

[2432] Add zero-argument RRsetCollection constructor

Mukund Sivaraman 12 years ago
parent
commit
7383457001
2 changed files with 20 additions and 0 deletions
  1. 4 0
      src/lib/dns/rrset_collection.h
  2. 16 0
      src/lib/dns/tests/rrset_collection_unittest.cc

+ 4 - 0
src/lib/dns/rrset_collection.h

@@ -31,6 +31,10 @@ namespace dns {
 class RRsetCollection : public RRsetCollectionBase {
 public:
     /// \brief Constructor.
+    RRsetCollection()
+    {}
+
+    /// \brief Constructor.
     ///
     /// The \c origin and \c rrclass arguments are required for the zone
     /// loading, but \c RRsetCollection itself does not do any

+ 16 - 0
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());