Commit a26f28f2 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

Fix build

This eliminates a warning about comparison of enum inside RBTree<int> with
RBTree<int, true> in tests.

Macros don't like commas in template arguments, so a new type is
defined.
parent 063c1cf6
......@@ -65,7 +65,8 @@ protected:
}
RBTree<int> rbtree;
RBTree<int, true> rbtree_expose_empty_node;
typedef RBTree<int, true> ExposeRBTree;
ExposeRBTree rbtree_expose_empty_node;
RBNode<int>* rbtnode;
const RBNode<int>* crbtnode;
};
......@@ -87,7 +88,7 @@ TEST_F(RBTreeTest, insertNames) {
EXPECT_EQ(Name("d.e.f"), rbtnode->getName());
EXPECT_EQ(13, rbtree.getNodeCount());
EXPECT_EQ(RBTree<int>::ALREADYEXISTS,
EXPECT_EQ(ExposeRBTree::ALREADYEXISTS,
rbtree_expose_empty_node.insert(Name("d.e.f"), &rbtnode));
EXPECT_EQ(Name("d.e.f"), rbtnode->getName());
EXPECT_EQ(13, rbtree_expose_empty_node.getNodeCount());
......@@ -98,15 +99,17 @@ TEST_F(RBTreeTest, insertNames) {
EXPECT_EQ(Name("."), rbtnode->getName());
EXPECT_EQ(14, rbtree.getNodeCount());
EXPECT_EQ(RBTree<int>::SUCCESS, rbtree_expose_empty_node.insert(Name("."), &rbtnode));
EXPECT_EQ(ExposeRBTree::SUCCESS, rbtree_expose_empty_node.insert(
Name("."), &rbtnode));
EXPECT_EQ(Name("."), rbtnode->getName());
EXPECT_EQ(14, rbtree_expose_empty_node.getNodeCount());
EXPECT_EQ(RBTree<int>::SUCCESS, rbtree.insert(Name("example.com"), &rbtnode));
EXPECT_EQ(15, rbtree.getNodeCount());
rbtnode->setData(RBNode<int>::NodeDataPtr(new int(12)));
EXPECT_EQ(RBTree<int>::SUCCESS, rbtree_expose_empty_node.insert(Name("example.com"), &rbtnode));
EXPECT_EQ(ExposeRBTree::SUCCESS, rbtree_expose_empty_node.insert(
Name("example.com"), &rbtnode));
EXPECT_EQ(15, rbtree_expose_empty_node.getNodeCount());
rbtnode->setData(RBNode<int>::NodeDataPtr(new int(12)));
......@@ -114,7 +117,8 @@ TEST_F(RBTreeTest, insertNames) {
// return ALREADYEXISTS, since node "example.com" already has been explicitly inserted
EXPECT_EQ(RBTree<int>::ALREADYEXISTS, rbtree.insert(Name("example.com"), &rbtnode));
EXPECT_EQ(15, rbtree.getNodeCount());
EXPECT_EQ(RBTree<int>::ALREADYEXISTS, rbtree_expose_empty_node.insert(Name("example.com"), &rbtnode));
EXPECT_EQ(ExposeRBTree::ALREADYEXISTS,
rbtree_expose_empty_node.insert(Name("example.com"), &rbtnode));
EXPECT_EQ(15, rbtree_expose_empty_node.getNodeCount());
......@@ -123,7 +127,8 @@ TEST_F(RBTreeTest, insertNames) {
EXPECT_EQ(Name("k"), rbtnode->getName());
EXPECT_EQ(17, rbtree.getNodeCount());
EXPECT_EQ(RBTree<int>::SUCCESS, rbtree_expose_empty_node.insert(Name("k.e.f"), &rbtnode));
EXPECT_EQ(ExposeRBTree::SUCCESS,
rbtree_expose_empty_node.insert(Name("k.e.f"), &rbtnode));
EXPECT_EQ(Name("k"), rbtnode->getName());
EXPECT_EQ(17, rbtree_expose_empty_node.getNodeCount());
......@@ -134,7 +139,8 @@ TEST_F(RBTreeTest, insertNames) {
EXPECT_EQ(18, rbtree.getNodeCount());
//node fission will create node "h"
EXPECT_EQ(RBTree<int>::ALREADYEXISTS, rbtree_expose_empty_node.insert(Name("h"), &rbtnode));
EXPECT_EQ(ExposeRBTree::ALREADYEXISTS,
rbtree_expose_empty_node.insert(Name("h"), &rbtnode));
EXPECT_EQ(Name("h"), rbtnode->getName());
EXPECT_EQ(18, rbtree_expose_empty_node.getNodeCount());
......@@ -147,10 +153,12 @@ TEST_F(RBTreeTest, insertNames) {
EXPECT_EQ(Name("n"), rbtnode->getName());
EXPECT_EQ(20, rbtree.getNodeCount());
EXPECT_EQ(RBTree<int>::SUCCESS, rbtree_expose_empty_node.insert(Name("m.p.w.y.d.e.f"), &rbtnode));
EXPECT_EQ(ExposeRBTree::SUCCESS,
rbtree_expose_empty_node.insert(Name("m.p.w.y.d.e.f"), &rbtnode));
EXPECT_EQ(Name("m"), rbtnode->getName());
EXPECT_EQ(19, rbtree_expose_empty_node.getNodeCount());
EXPECT_EQ(RBTree<int>::SUCCESS, rbtree_expose_empty_node.insert(Name("n.p.w.y.d.e.f"), &rbtnode));
EXPECT_EQ(ExposeRBTree::SUCCESS,
rbtree_expose_empty_node.insert(Name("n.p.w.y.d.e.f"), &rbtnode));
EXPECT_EQ(Name("n"), rbtnode->getName());
EXPECT_EQ(20, rbtree_expose_empty_node.getNodeCount());
......@@ -159,7 +167,8 @@ TEST_F(RBTreeTest, insertNames) {
EXPECT_EQ(Name("l"), rbtnode->getName());
EXPECT_EQ(21, rbtree.getNodeCount());
EXPECT_EQ(RBTree<int>::SUCCESS, rbtree_expose_empty_node.insert(Name("l.a"), &rbtnode));
EXPECT_EQ(ExposeRBTree::SUCCESS,
rbtree_expose_empty_node.insert(Name("l.a"), &rbtnode));
EXPECT_EQ(Name("l"), rbtnode->getName());
EXPECT_EQ(21, rbtree_expose_empty_node.getNodeCount());
......@@ -167,12 +176,15 @@ TEST_F(RBTreeTest, insertNames) {
EXPECT_EQ(RBTree<int>::SUCCESS, rbtree.insert(Name("s.d.e.f"), &rbtnode));
EXPECT_EQ(23, rbtree.getNodeCount());
EXPECT_EQ(RBTree<int>::SUCCESS, rbtree_expose_empty_node.insert(Name("r.d.e.f"), &rbtnode));
EXPECT_EQ(RBTree<int>::SUCCESS, rbtree_expose_empty_node.insert(Name("s.d.e.f"), &rbtnode));
EXPECT_EQ(ExposeRBTree::SUCCESS,
rbtree_expose_empty_node.insert(Name("r.d.e.f"), &rbtnode));
EXPECT_EQ(ExposeRBTree::SUCCESS,
rbtree_expose_empty_node.insert(Name("s.d.e.f"), &rbtnode));
EXPECT_EQ(23, rbtree_expose_empty_node.getNodeCount());
EXPECT_EQ(RBTree<int>::SUCCESS, rbtree.insert(Name("h.w.y.d.e.f"), &rbtnode));
EXPECT_EQ(RBTree<int>::SUCCESS, rbtree_expose_empty_node.insert(Name("h.w.y.d.e.f"), &rbtnode));
EXPECT_EQ(ExposeRBTree::SUCCESS,
rbtree_expose_empty_node.insert(Name("h.w.y.d.e.f"), &rbtnode));
// add more nodes one by one to cover leftRotate and rightRotate
EXPECT_EQ(RBTree<int>::SUCCESS, rbtree.insert(Name("f"), &rbtnode));
......@@ -187,17 +199,28 @@ TEST_F(RBTreeTest, insertNames) {
EXPECT_EQ(RBTree<int>::SUCCESS, rbtree.insert(Name("ae"), &rbtnode));
EXPECT_EQ(RBTree<int>::SUCCESS, rbtree.insert(Name("n"), &rbtnode));
EXPECT_EQ(RBTree<int>::ALREADYEXISTS, rbtree_expose_empty_node.insert(Name("f"), &rbtnode));
EXPECT_EQ(RBTree<int>::SUCCESS, rbtree_expose_empty_node.insert(Name("m"), &rbtnode));
EXPECT_EQ(RBTree<int>::SUCCESS, rbtree_expose_empty_node.insert(Name("nm"), &rbtnode));
EXPECT_EQ(RBTree<int>::SUCCESS, rbtree_expose_empty_node.insert(Name("om"), &rbtnode));
EXPECT_EQ(RBTree<int>::SUCCESS, rbtree_expose_empty_node.insert(Name("k"), &rbtnode));
EXPECT_EQ(RBTree<int>::SUCCESS, rbtree_expose_empty_node.insert(Name("l"), &rbtnode));
EXPECT_EQ(RBTree<int>::SUCCESS, rbtree_expose_empty_node.insert(Name("fe"), &rbtnode));
EXPECT_EQ(RBTree<int>::SUCCESS, rbtree_expose_empty_node.insert(Name("ge"), &rbtnode));
EXPECT_EQ(RBTree<int>::SUCCESS, rbtree_expose_empty_node.insert(Name("i"), &rbtnode));
EXPECT_EQ(RBTree<int>::SUCCESS, rbtree_expose_empty_node.insert(Name("ae"), &rbtnode));
EXPECT_EQ(RBTree<int>::SUCCESS, rbtree_expose_empty_node.insert(Name("n"), &rbtnode));
EXPECT_EQ(ExposeRBTree::ALREADYEXISTS,
rbtree_expose_empty_node.insert(Name("f"), &rbtnode));
EXPECT_EQ(ExposeRBTree::SUCCESS,
rbtree_expose_empty_node.insert(Name("m"), &rbtnode));
EXPECT_EQ(ExposeRBTree::SUCCESS,
rbtree_expose_empty_node.insert(Name("nm"), &rbtnode));
EXPECT_EQ(ExposeRBTree::SUCCESS,
rbtree_expose_empty_node.insert(Name("om"), &rbtnode));
EXPECT_EQ(ExposeRBTree::SUCCESS,
rbtree_expose_empty_node.insert(Name("k"), &rbtnode));
EXPECT_EQ(ExposeRBTree::SUCCESS,
rbtree_expose_empty_node.insert(Name("l"), &rbtnode));
EXPECT_EQ(ExposeRBTree::SUCCESS,
rbtree_expose_empty_node.insert(Name("fe"), &rbtnode));
EXPECT_EQ(ExposeRBTree::SUCCESS,
rbtree_expose_empty_node.insert(Name("ge"), &rbtnode));
EXPECT_EQ(ExposeRBTree::SUCCESS,
rbtree_expose_empty_node.insert(Name("i"), &rbtnode));
EXPECT_EQ(ExposeRBTree::SUCCESS,
rbtree_expose_empty_node.insert(Name("ae"), &rbtnode));
EXPECT_EQ(ExposeRBTree::SUCCESS,
rbtree_expose_empty_node.insert(Name("n"), &rbtnode));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment