Refactor test
This commit is contained in:
parent
f115e10f6d
commit
b51588670c
@ -1,7 +1,6 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "blockstore/implementations/testfake/FakeBlockStore.h"
|
||||
#include "blobstore/implementations/onblocks/datanodestore/DataNodeStore.h"
|
||||
#include "../DataTreeTest.h"
|
||||
#include "blobstore/implementations/onblocks/datatreestore/DataTree.h"
|
||||
#include "blobstore/implementations/onblocks/datanodestore/DataLeafNode.h"
|
||||
#include "blobstore/implementations/onblocks/datanodestore/DataInnerNode.h"
|
||||
@ -19,16 +18,8 @@ using blockstore::testfake::FakeBlockStore;
|
||||
using blockstore::Key;
|
||||
using blobstore::onblocks::datatreestore::impl::GetLowestRightBorderNodeWithLessThanKChildrenOrNull;
|
||||
|
||||
namespace blobstore {
|
||||
namespace onblocks {
|
||||
namespace datatreestore {
|
||||
|
||||
class GetLowestRightBorderNodeWithLessThanKChildrenOrNullTest: public Test {
|
||||
class GetLowestRightBorderNodeWithLessThanKChildrenOrNullTest: public DataTreeTest {
|
||||
public:
|
||||
GetLowestRightBorderNodeWithLessThanKChildrenOrNullTest():
|
||||
nodeStore(make_unique<FakeBlockStore>()) {
|
||||
}
|
||||
|
||||
struct TestData {
|
||||
TestData(Key rootNode_, Key expectedResult_): rootNode(rootNode_), expectedResult(expectedResult_) {}
|
||||
Key rootNode;
|
||||
@ -41,22 +32,6 @@ public:
|
||||
EXPECT_EQ(testData.expectedResult, result->key());
|
||||
}
|
||||
|
||||
void FillNode(DataInnerNode *node) {
|
||||
for(unsigned int i=node->numChildren(); i < DataInnerNode::MAX_STORED_CHILDREN; ++i) {
|
||||
node->addChild(*nodeStore.createNewLeafNode());
|
||||
}
|
||||
}
|
||||
|
||||
void FillNodeTwoLevel(DataInnerNode *node) {
|
||||
for(unsigned int i=node->numChildren(); i < DataInnerNode::MAX_STORED_CHILDREN; ++i) {
|
||||
auto inner_node = nodeStore.createNewInnerNode(*nodeStore.createNewLeafNode());
|
||||
for(unsigned int j = 1;j < DataInnerNode::MAX_STORED_CHILDREN; ++j) {
|
||||
inner_node->addChild(*nodeStore.createNewLeafNode());
|
||||
}
|
||||
node->addChild(*inner_node);
|
||||
}
|
||||
}
|
||||
|
||||
TestData CreateTwoRightBorderNodes() {
|
||||
auto leaf = nodeStore.createNewLeafNode();
|
||||
auto node = nodeStore.createNewInnerNode(*leaf);
|
||||
@ -90,24 +65,6 @@ public:
|
||||
root->addChild(*node2);
|
||||
return TestData(root->key(), node2->key());
|
||||
}
|
||||
|
||||
Key CreateFullTwoLevelTree() {
|
||||
auto leaf = nodeStore.createNewLeafNode();
|
||||
auto root = nodeStore.createNewInnerNode(*leaf);
|
||||
FillNode(root.get());
|
||||
return root->key();
|
||||
}
|
||||
|
||||
Key CreateFullThreeLevelTree() {
|
||||
auto leaf = nodeStore.createNewLeafNode();
|
||||
auto node = nodeStore.createNewInnerNode(*leaf);
|
||||
auto root = nodeStore.createNewInnerNode(*node);
|
||||
FillNode(node.get());
|
||||
FillNodeTwoLevel(root.get());
|
||||
return root->key();
|
||||
}
|
||||
|
||||
DataNodeStore nodeStore;
|
||||
};
|
||||
|
||||
TEST_F(GetLowestRightBorderNodeWithLessThanKChildrenOrNullTest, Leaf) {
|
||||
@ -147,7 +104,3 @@ TEST_F(GetLowestRightBorderNodeWithLessThanKChildrenOrNullTest, FullThreeLevelTr
|
||||
auto result = GetLowestRightBorderNodeWithLessThanKChildrenOrNull::run(&nodeStore, root.get());
|
||||
EXPECT_EQ(nullptr, result.get());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user