Browse Source

[2107] add explicit tests for RdataSet::getNext()

JINMEI Tatuya 12 years ago
parent
commit
56de9af8c7
1 changed files with 16 additions and 0 deletions
  1. 16 0
      src/lib/datasrc/memory/tests/rdataset_unittest.cc

+ 16 - 0
src/lib/datasrc/memory/tests/rdataset_unittest.cc

@@ -116,6 +116,22 @@ TEST_F(RdataSetTest, create) {
     RdataSet::destroy(mem_sgmt_, RRClass::IN(), rdataset);
 }
 
+TEST_F(RdataSetTest, getNext) {
+    RdataSet* rdataset = RdataSet::create(mem_sgmt_, encoder_, a_rrset_,
+                                          ConstRRsetPtr());
+
+    // By default, the next pointer should be NULL (already tested in other
+    // test cases), which should be the case with getNext()
+    EXPECT_EQ(static_cast<RdataSet*>(NULL), rdataset->getNext());
+
+    // making a link (it would form an infinite loop, but it doesn't matter
+    // in this test), and check the pointer returned by getNext().
+    rdataset->next = rdataset;
+    EXPECT_EQ(rdataset, rdataset->getNext());
+
+    RdataSet::destroy(mem_sgmt_, RRClass::IN(), rdataset);
+}
+
 // A helper function to create an RRset containing the given number of
 // unique RDATAs.
 ConstRRsetPtr