Browse Source

[2750] Add some more checks and comments to .remove test

Mukund Sivaraman 11 years ago
parent
commit
b1e65b9023
1 changed files with 10 additions and 3 deletions
  1. 10 3
      src/lib/datasrc/tests/memory/domaintree_unittest.cc

+ 10 - 3
src/lib/datasrc/tests/memory/domaintree_unittest.cc

@@ -390,7 +390,8 @@ TEST_F(DomainTreeTest, remove) {
     // This testcase checks that after node removal, the binary-search
     // This testcase checks that after node removal, the binary-search
     // tree is valid and all nodes that are supposed to exist are
     // tree is valid and all nodes that are supposed to exist are
     // present in the correct order. It mainly tests DomainTree as a
     // present in the correct order. It mainly tests DomainTree as a
-    // BST, and not particularly as a red-black tree.
+    // BST, and not particularly as a red-black tree. This test checks
+    // node deletion when upper nodes have data.
 
 
     // Delete single nodes and check if the rest of the nodes exist
     // Delete single nodes and check if the rest of the nodes exist
     for (int j = 0; j < ordered_names_count; ++j) {
     for (int j = 0; j < ordered_names_count; ++j) {
@@ -405,8 +406,9 @@ TEST_F(DomainTreeTest, remove) {
         for (int i = 0; i < ordered_names_count; ++i) {
         for (int i = 0; i < ordered_names_count; ++i) {
             EXPECT_EQ(TestDomainTree::EXACTMATCH,
             EXPECT_EQ(TestDomainTree::EXACTMATCH,
                       tree.find(Name(ordered_names[i]), &node));
                       tree.find(Name(ordered_names[i]), &node));
-            EXPECT_EQ(static_cast<int*>(NULL),
-                      node->setData(new int(i)));
+            // Check nodes are not empty.
+            EXPECT_EQ(static_cast<int*>(NULL), node->setData(new int(i)));
+            EXPECT_FALSE(node->isEmpty());
         }
         }
 
 
         // Now, delete the j'th node from the tree.
         // Now, delete the j'th node from the tree.
@@ -440,6 +442,7 @@ TEST_F(DomainTreeTest, remove) {
         for (int i = start_node; i < ordered_names_count; ++i) {
         for (int i = start_node; i < ordered_names_count; ++i) {
             const Name nj(ordered_names[j]);
             const Name nj(ordered_names[j]);
             const Name ni(ordered_names[i]);
             const Name ni(ordered_names[i]);
+
             if (ni == nj) {
             if (ni == nj) {
                 // This may be true for the last node if we seek ahead
                 // This may be true for the last node if we seek ahead
                 // in the loop using nextNode() below.
                 // in the loop using nextNode() below.
@@ -462,6 +465,10 @@ TEST_F(DomainTreeTest, remove) {
                  EXPECT_EQ(i, *data);
                  EXPECT_EQ(i, *data);
             }
             }
 
 
+            uint8_t buf[isc::dns::LabelSequence::MAX_SERIALIZED_LENGTH];
+            const LabelSequence ls(cnode->getAbsoluteLabels(buf));
+            EXPECT_EQ(LabelSequence(ni), ls);
+
             cnode = tree.nextNode(node_path);
             cnode = tree.nextNode(node_path);
         }
         }