From: Mukund Sivaraman Date: Fri, 13 Sep 2013 10:00:28 +0000 (+0530) Subject: [2750] Add some more checks and comments to .remove test X-Git-Tag: bind10-1.2.0beta1-release~193^2~4^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b1e65b902324572544555903b45bc63ffcefcd2b;p=thirdparty%2Fkea.git [2750] Add some more checks and comments to .remove test --- diff --git a/src/lib/datasrc/tests/memory/domaintree_unittest.cc b/src/lib/datasrc/tests/memory/domaintree_unittest.cc index 9b7630c2a9..96413ab77f 100644 --- a/src/lib/datasrc/tests/memory/domaintree_unittest.cc +++ b/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 // 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(NULL), - node->setData(new int(i))); + // Check nodes are not empty. + EXPECT_EQ(static_cast(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); }