Add test cases checking that growing a tree sets correct depth flags
This commit is contained in:
parent
0607dcb282
commit
5133e3d8a0
@ -26,5 +26,4 @@ TEST_F(DataTreeGrowingTest, GrowAOneNodeTree_FlushingWorks) {
|
|||||||
EXPECT_INNER_NODE_NUMBER_OF_LEAVES_IS(2, tree->key());
|
EXPECT_INNER_NODE_NUMBER_OF_LEAVES_IS(2, tree->key());
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO Test tree depth markers on the nodes
|
|
||||||
//TODO Build-up test cases (build a leaf tree, add N leaves and check end state. End states for example FullTwoLevelTree, FullThreeLevelTree)
|
//TODO Build-up test cases (build a leaf tree, add N leaves and check end state. End states for example FullTwoLevelTree, FullThreeLevelTree)
|
||||||
|
@ -0,0 +1,61 @@
|
|||||||
|
#include "testutils/DataTreeGrowingTest.h"
|
||||||
|
|
||||||
|
using blockstore::Key;
|
||||||
|
|
||||||
|
class DataTreeGrowingTest_DepthFlags: public DataTreeGrowingTest {
|
||||||
|
public:
|
||||||
|
void CHECK_DEPTH(int depth, const Key &key) {
|
||||||
|
auto node = LoadInnerNode(key);
|
||||||
|
EXPECT_EQ(depth, node->depth());
|
||||||
|
if (depth > 1) {
|
||||||
|
for (int i = 0; i < node->numChildren(); ++i) {
|
||||||
|
CHECK_DEPTH(depth-1, node->getChild(i)->key());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(DataTreeGrowingTest_DepthFlags, GrowAOneNodeTree) {
|
||||||
|
auto key = CreateTreeAddOneLeafReturnRootKey();
|
||||||
|
CHECK_DEPTH(1, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(DataTreeGrowingTest_DepthFlags, GrowATwoNodeTree) {
|
||||||
|
auto key = CreateTreeAddTwoLeavesReturnRootKey();
|
||||||
|
CHECK_DEPTH(1, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(DataTreeGrowingTest_DepthFlags, GrowATwoLevelThreeNodeTree) {
|
||||||
|
auto key = CreateTreeAddThreeLeavesReturnRootKey();
|
||||||
|
CHECK_DEPTH(1, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(DataTreeGrowingTest_DepthFlags, GrowAThreeNodeChainedTree) {
|
||||||
|
auto key = CreateThreeNodeChainedTreeReturnRootKey();
|
||||||
|
AddLeafTo(key);
|
||||||
|
CHECK_DEPTH(2, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(DataTreeGrowingTest_DepthFlags, GrowAFullTwoLevelTree) {
|
||||||
|
auto key = CreateFullTwoLevelTree();
|
||||||
|
AddLeafTo(key);
|
||||||
|
CHECK_DEPTH(2, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(DataTreeGrowingTest_DepthFlags, GrowAThreeLevelTreeWithLowerLevelFull) {
|
||||||
|
auto key = CreateThreeLevelTreeWithLowerLevelFullReturnRootKey();
|
||||||
|
AddLeafTo(key);
|
||||||
|
CHECK_DEPTH(2, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(DataTreeGrowingTest_DepthFlags, GrowAFullThreeLevelTree) {
|
||||||
|
auto key = CreateFullThreeLevelTree();
|
||||||
|
AddLeafTo(key);
|
||||||
|
CHECK_DEPTH(3, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(DataTreeGrowingTest_DepthFlags, GrowAThreeLevelTreeWithTwoFullSubtrees) {
|
||||||
|
auto key = CreateThreeLevelTreeWithTwoFullSubtrees();
|
||||||
|
AddLeafTo(key);
|
||||||
|
CHECK_DEPTH(2, key);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user