Added test cases for DataNodeStore::numNodes()

This commit is contained in:
Sebastian Messmer 2015-02-24 16:52:11 +01:00
parent 96208200f9
commit b9e3a9b109
2 changed files with 29 additions and 1 deletions

View File

@ -37,7 +37,7 @@ public:
void remove(std::unique_ptr<DataNode> node);
uint64_t numNodes() const;
//TODO Test remove(), overwriteNodeWith(), createNodeAsCopyFrom(), numNodes()
//TODO Test remove(), overwriteNodeWith(), createNodeAsCopyFrom()
private:
std::unique_ptr<DataNode> load(std::unique_ptr<blockstore::Block> block);

View File

@ -92,3 +92,31 @@ TEST_F(DataNodeStoreTest, CreatedLeafNodeIsInitialized) {
auto leaf = nodeStore->createNewLeafNode();
EXPECT_EQ(0u, leaf->numBytes());
}
TEST_F(DataNodeStoreTest, NumNodesIsCorrectOnEmptyNodestore) {
EXPECT_EQ(0, nodeStore->numNodes());
}
TEST_F(DataNodeStoreTest, NumNodesIsCorrectAfterAddingOneLeafNode) {
nodeStore->createNewLeafNode();
EXPECT_EQ(1, nodeStore->numNodes());
}
TEST_F(DataNodeStoreTest, NumNodesIsCorrectAfterRemovingTheLastNode) {
auto leaf = nodeStore->createNewLeafNode();
nodeStore->remove(std::move(leaf));
EXPECT_EQ(0, nodeStore->numNodes());
}
TEST_F(DataNodeStoreTest, NumNodesIsCorrectAfterAddingTwoNodes) {
auto leaf = nodeStore->createNewLeafNode();
auto node = nodeStore->createNewInnerNode(*leaf);
EXPECT_EQ(2, nodeStore->numNodes());
}
TEST_F(DataNodeStoreTest, NumNodesIsCorrectAfterRemovingANode) {
auto leaf = nodeStore->createNewLeafNode();
auto node = nodeStore->createNewInnerNode(*leaf);
nodeStore->remove(std::move(node));
EXPECT_EQ(1, nodeStore->numNodes());
}