Browse Source

[trac517] updated nextNode() test cases

 - not all nodes were tested.  fixed it.
 - confirmed nextNode() returns NULL at the end of the tree.
JINMEI Tatuya 14 years ago
parent
commit
ad83fe6b6c
1 changed files with 8 additions and 3 deletions
  1. 8 3
      src/lib/datasrc/tests/rbtree_unittest.cc

+ 8 - 3
src/lib/datasrc/tests/rbtree_unittest.cc

@@ -313,11 +313,16 @@ TEST_F(RBTreeTest, nextNode) {
     RBTreeNodeChain<int> node_path;
     const RBNode<int>* node = NULL;
     EXPECT_EQ(RBTree<int>::EXACTMATCH,
-              rbtree.find<void*>(Name(names[0]), &node, node_path, NULL, NULL));
-    for (int i = 0; i < name_count - 1; ++i) {
+              rbtree.find<void*>(Name(names[0]), &node, node_path, NULL,
+                                 NULL));
+    for (int i = 0; i < name_count; ++i) {
+        EXPECT_NE(static_cast<void*>(NULL), node);
         EXPECT_EQ(Name(names[i]), node_path.getAbsoluteName());
-        rbtree.nextNode(node_path);
+        node = rbtree.nextNode(node_path);
     }
+
+    // We should have reached the end of the tree.
+    EXPECT_EQ(static_cast<void*>(NULL), node);
 }
 
 TEST_F(RBTreeTest, dumpTree) {