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