]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2750] Add some more checks and comments to .remove test
authorMukund Sivaraman <muks@isc.org>
Fri, 13 Sep 2013 10:00:28 +0000 (15:30 +0530)
committerMukund Sivaraman <muks@isc.org>
Fri, 13 Sep 2013 10:00:28 +0000 (15:30 +0530)
src/lib/datasrc/tests/memory/domaintree_unittest.cc

index 9b7630c2a91da1d63751407e59c2fec2144bfe95..96413ab77fbf10ee0effe6d9e7ef8fb6ea0f3f96 100644 (file)
@@ -390,7 +390,8 @@ TEST_F(DomainTreeTest, remove) {
     // This testcase checks that after node removal, the binary-search
     // tree is valid and all nodes that are supposed to exist are
     // 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
     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) {
             EXPECT_EQ(TestDomainTree::EXACTMATCH,
                       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.
@@ -440,6 +442,7 @@ TEST_F(DomainTreeTest, remove) {
         for (int i = start_node; i < ordered_names_count; ++i) {
             const Name nj(ordered_names[j]);
             const Name ni(ordered_names[i]);
+
             if (ni == nj) {
                 // This may be true for the last node if we seek ahead
                 // in the loop using nextNode() below.
@@ -462,6 +465,10 @@ TEST_F(DomainTreeTest, remove) {
                  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);
         }