Refactor GetLowestRightBorderNode... algorithm test cases
This commit is contained in:
parent
7fea8017c8
commit
388c755f63
@ -35,37 +35,25 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
TestData CreateTwoRightBorderNodes() {
|
TestData CreateTwoRightBorderNodes() {
|
||||||
auto leaf = nodeStore.createNewLeafNode();
|
auto node = CreateInner({CreateLeaf()});
|
||||||
auto node = nodeStore.createNewInnerNode(*leaf);
|
|
||||||
return TestData(node->key(), node->key());
|
return TestData(node->key(), node->key());
|
||||||
}
|
}
|
||||||
|
|
||||||
TestData CreateThreeRightBorderNodes() {
|
TestData CreateThreeRightBorderNodes() {
|
||||||
auto leaf = nodeStore.createNewLeafNode();
|
auto node = CreateInner({CreateLeaf()});
|
||||||
auto node = nodeStore.createNewInnerNode(*leaf);
|
auto root = CreateInner({node.get()});
|
||||||
auto root = nodeStore.createNewInnerNode(*node);
|
|
||||||
return TestData(root->key(), node->key());
|
return TestData(root->key(), node->key());
|
||||||
}
|
}
|
||||||
|
|
||||||
TestData CreateThreeRightBorderNodes_LastFull() {
|
TestData CreateThreeRightBorderNodes_LastFull() {
|
||||||
auto leaf = nodeStore.createNewLeafNode();
|
auto root = CreateInner({CreateFullTwoLevel()});
|
||||||
auto node = nodeStore.createNewInnerNode(*leaf);
|
|
||||||
FillNode(node.get());
|
|
||||||
auto root = nodeStore.createNewInnerNode(*node);
|
|
||||||
return TestData(root->key(), root->key());
|
return TestData(root->key(), root->key());
|
||||||
}
|
}
|
||||||
|
|
||||||
TestData CreateLargerTree() {
|
TestData CreateLargerTree() {
|
||||||
auto leaf = nodeStore.createNewLeafNode();
|
auto node = CreateInner({CreateLeaf(), CreateLeaf()});
|
||||||
auto leaf2 = nodeStore.createNewLeafNode();
|
auto root = CreateInner({CreateFullTwoLevel().get(), node.get()});
|
||||||
auto leaf3 = nodeStore.createNewLeafNode();
|
return TestData(root->key(), node->key());
|
||||||
auto node = nodeStore.createNewInnerNode(*leaf);
|
|
||||||
FillNode(node.get());
|
|
||||||
auto node2 = nodeStore.createNewInnerNode(*leaf2);
|
|
||||||
node2->addChild(*leaf3);
|
|
||||||
auto root = nodeStore.createNewInnerNode(*node);
|
|
||||||
root->addChild(*node2);
|
|
||||||
return TestData(root->key(), node2->key());
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -35,85 +35,47 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
Key CreateLeafOnlyTree() {
|
Key CreateLeafOnlyTree() {
|
||||||
return nodeStore.createNewLeafNode()->key();
|
return CreateLeaf()->key();
|
||||||
}
|
}
|
||||||
|
|
||||||
Key CreateTwoRightBorderNodes() {
|
Key CreateTwoRightBorderNodes() {
|
||||||
auto leaf = nodeStore.createNewLeafNode();
|
return CreateInner({CreateLeaf()})->key();
|
||||||
auto node = nodeStore.createNewInnerNode(*leaf);
|
|
||||||
return node->key(), node->key();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Key CreateThreeRightBorderNodes() {
|
Key CreateThreeRightBorderNodes() {
|
||||||
auto leaf = nodeStore.createNewLeafNode();
|
return CreateInner({CreateInner({CreateLeaf()})})->key();
|
||||||
auto node = nodeStore.createNewInnerNode(*leaf);
|
|
||||||
auto root = nodeStore.createNewInnerNode(*node);
|
|
||||||
return root->key();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TestData CreateThreeRightBorderNodes_LastFull() {
|
TestData CreateThreeRightBorderNodes_LastFull() {
|
||||||
auto leaf = nodeStore.createNewLeafNode();
|
auto node = CreateFullTwoLevel();
|
||||||
auto node = nodeStore.createNewInnerNode(*leaf);
|
auto root = CreateInner({node.get()});
|
||||||
FillNode(node.get());
|
|
||||||
auto root = nodeStore.createNewInnerNode(*node);
|
|
||||||
return TestData(root->key(), node->key());
|
return TestData(root->key(), node->key());
|
||||||
}
|
}
|
||||||
|
|
||||||
TestData CreateLargerTree() {
|
TestData CreateLargerTree() {
|
||||||
auto leaf = nodeStore.createNewLeafNode();
|
auto node = CreateInner({CreateLeaf(), CreateLeaf()});
|
||||||
auto leaf2 = nodeStore.createNewLeafNode();
|
auto root = CreateInner({CreateFullTwoLevel().get(), node.get()});
|
||||||
auto leaf3 = nodeStore.createNewLeafNode();
|
return TestData(root->key(), node->key());
|
||||||
auto node = nodeStore.createNewInnerNode(*leaf);
|
|
||||||
FillNode(node.get());
|
|
||||||
auto node2 = nodeStore.createNewInnerNode(*leaf2);
|
|
||||||
node2->addChild(*leaf3);
|
|
||||||
auto root = nodeStore.createNewInnerNode(*node);
|
|
||||||
root->addChild(*node2);
|
|
||||||
return TestData(root->key(), node2->key());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TestData CreateThreeLevelTreeWithRightBorderSingleNodeChain() {
|
TestData CreateThreeLevelTreeWithRightBorderSingleNodeChain() {
|
||||||
auto leaf = nodeStore.createNewLeafNode();
|
auto root = CreateInner({CreateFullTwoLevel(), CreateInner({CreateLeaf()})});
|
||||||
auto node1 = nodeStore.createNewInnerNode(*leaf);
|
|
||||||
FillNode(node1.get());
|
|
||||||
auto leaf2 = nodeStore.createNewLeafNode();
|
|
||||||
auto node2 = nodeStore.createNewInnerNode(*leaf2);
|
|
||||||
auto root = nodeStore.createNewInnerNode(*node1);
|
|
||||||
root->addChild(*node2);
|
|
||||||
return TestData(root->key(), root->key());
|
return TestData(root->key(), root->key());
|
||||||
}
|
}
|
||||||
|
|
||||||
TestData CreateThreeLevelTree() {
|
TestData CreateThreeLevelTree() {
|
||||||
auto leaf = nodeStore.createNewLeafNode();
|
auto node = CreateInner({CreateLeaf(), CreateLeaf()});
|
||||||
auto node1 = nodeStore.createNewInnerNode(*leaf);
|
auto root = CreateInner({CreateFullTwoLevel().get(), node.get()});
|
||||||
FillNode(node1.get());
|
return TestData(root->key(), node->key());
|
||||||
auto leaf2 = nodeStore.createNewLeafNode();
|
|
||||||
auto leaf3 = nodeStore.createNewLeafNode();
|
|
||||||
auto node2 = nodeStore.createNewInnerNode(*leaf2);
|
|
||||||
node2->addChild(*leaf3);
|
|
||||||
auto root = nodeStore.createNewInnerNode(*node1);
|
|
||||||
root->addChild(*node2);
|
|
||||||
return TestData(root->key(), node2->key());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TestData CreateFullTwoLevelTree() {
|
TestData CreateFullTwoLevelTree() {
|
||||||
auto leaf = nodeStore.createNewLeafNode();
|
auto node = CreateFullTwoLevel();
|
||||||
auto node = nodeStore.createNewInnerNode(*leaf);
|
|
||||||
FillNode(node.get());
|
|
||||||
return TestData(node->key(), node->key());
|
return TestData(node->key(), node->key());
|
||||||
}
|
}
|
||||||
|
|
||||||
TestData CreateFullThreeLevelTree() {
|
TestData CreateFullThreeLevelTree() {
|
||||||
auto leaf = nodeStore.createNewLeafNode();
|
auto root = CreateFullThreeLevel();
|
||||||
auto firstFullTwoLevelTree = nodeStore.createNewInnerNode(*leaf);
|
|
||||||
FillNode(firstFullTwoLevelTree.get());
|
|
||||||
auto root = nodeStore.createNewInnerNode(*firstFullTwoLevelTree);
|
|
||||||
for (int i = 1; i < DataInnerNode::MAX_STORED_CHILDREN; ++i) {
|
|
||||||
auto leaf2 = nodeStore.createNewLeafNode();
|
|
||||||
auto fullTwoLevelTree = nodeStore.createNewInnerNode(*leaf2);
|
|
||||||
FillNode(fullTwoLevelTree.get());
|
|
||||||
root->addChild(*fullTwoLevelTree);
|
|
||||||
}
|
|
||||||
return TestData(root->key(), root->LastChild()->key());
|
return TestData(root->key(), root->LastChild()->key());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user