Added test cases for DataNode::key() and DataTree::key()

This commit is contained in:
Sebastian Messmer 2015-02-27 14:32:28 +01:00
parent 4d50479777
commit 68182e523f
3 changed files with 38 additions and 0 deletions

View File

@ -110,6 +110,22 @@ public:
constexpr uint32_t DataInnerNodeTest::BLOCKSIZE_BYTES;
TEST_F(DataInnerNodeTest, CorrectKeyReturnedAfterInitialization) {
auto block = blockStore->create(BLOCKSIZE_BYTES);
Key key = block->key();
auto node = DataInnerNode::InitializeNewNode(std::move(block), *leaf);
EXPECT_EQ(key, node->key());
}
TEST_F(DataInnerNodeTest, CorrectKeyReturnedAfterLoading) {
auto block = blockStore->create(BLOCKSIZE_BYTES);
Key key = block->key();
DataInnerNode::InitializeNewNode(std::move(block), *leaf);
auto loaded = nodeStore->load(key);
EXPECT_EQ(key, loaded->key());
}
TEST_F(DataInnerNodeTest, InitializesCorrectly) {
auto node = DataInnerNode::InitializeNewNode(blockStore->create(BLOCKSIZE_BYTES), *leaf);

View File

@ -106,6 +106,22 @@ public:
constexpr uint32_t DataLeafNodeTest::BLOCKSIZE_BYTES;
TEST_F(DataLeafNodeTest, CorrectKeyReturnedAfterInitialization) {
auto block = blockStore->create(BLOCKSIZE_BYTES);
Key key = block->key();
auto node = DataLeafNode::InitializeNewNode(std::move(block));
EXPECT_EQ(key, node->key());
}
TEST_F(DataLeafNodeTest, CorrectKeyReturnedAfterLoading) {
auto block = blockStore->create(BLOCKSIZE_BYTES);
Key key = block->key();
DataLeafNode::InitializeNewNode(std::move(block));
auto loaded = nodeStore->load(key);
EXPECT_EQ(key, loaded->key());
}
TEST_F(DataLeafNodeTest, InitializesCorrectly) {
auto leaf = DataLeafNode::InitializeNewNode(blockStore->create(BLOCKSIZE_BYTES));
EXPECT_EQ(0u, leaf->numBytes());

View File

@ -14,6 +14,12 @@ using namespace blobstore::onblocks::datatreestore;
class DataTreeStoreTest: public DataTreeTest {
};
TEST_F(DataTreeStoreTest, CorrectKeyReturned) {
Key key = treeStore.createNewTree()->key();
auto tree = treeStore.load(key);
EXPECT_EQ(key, tree->key());
}
TEST_F(DataTreeStoreTest, CreatedTreeIsLoadable) {
auto key = treeStore.createNewTree()->key();
auto loaded = treeStore.load(key);