diff --git a/src/blobstore/implementations/onblocks/datanodestore/DataNodeStore.cpp b/src/blobstore/implementations/onblocks/datanodestore/DataNodeStore.cpp index 3b3006cd..9cfab417 100644 --- a/src/blobstore/implementations/onblocks/datanodestore/DataNodeStore.cpp +++ b/src/blobstore/implementations/onblocks/datanodestore/DataNodeStore.cpp @@ -34,14 +34,14 @@ unique_ptr DataNodeStore::load(unique_ptr block, const Key &key } } -unique_ptr DataNodeStore::createNewInnerNode(const DataNode &first_child) { +unique_ptr DataNodeStore::createNewInnerNode(const DataNode &first_child) { auto block = _blockstore->create(DataNodeView::BLOCKSIZE_BYTES); auto newNode = make_unique(std::move(block.block), block.key, this); newNode->InitializeNewNode(first_child); return std::move(newNode); } -unique_ptr DataNodeStore::createNewLeafNode() { +unique_ptr DataNodeStore::createNewLeafNode() { auto block = _blockstore->create(DataNodeView::BLOCKSIZE_BYTES); auto newNode = make_unique(std::move(block.block), block.key, this); newNode->InitializeNewNode(); diff --git a/src/blobstore/implementations/onblocks/datanodestore/DataNodeStore.h b/src/blobstore/implementations/onblocks/datanodestore/DataNodeStore.h index 4d55b906..4741097e 100644 --- a/src/blobstore/implementations/onblocks/datanodestore/DataNodeStore.h +++ b/src/blobstore/implementations/onblocks/datanodestore/DataNodeStore.h @@ -14,6 +14,8 @@ class Key; namespace blobstore { namespace onblocks { class DataNode; +class DataLeafNode; +class DataInnerNode; class DataNodeStore { public: @@ -25,8 +27,8 @@ public: std::unique_ptr load(const blockstore::Key &key); std::unique_ptr load(const blockstore::Key &key) const; - std::unique_ptr createNewLeafNode(); - std::unique_ptr createNewInnerNode(const DataNode &first_child); + std::unique_ptr createNewLeafNode(); + std::unique_ptr createNewInnerNode(const DataNode &first_child); private: std::unique_ptr load(std::unique_ptr block, const blockstore::Key &key); diff --git a/src/test/blobstore/implementations/onblocks/datanodestore/DataLeafNodeTest.cpp b/src/test/blobstore/implementations/onblocks/datanodestore/DataLeafNodeTest.cpp index 997e8406..d7bc0035 100644 --- a/src/test/blobstore/implementations/onblocks/datanodestore/DataLeafNodeTest.cpp +++ b/src/test/blobstore/implementations/onblocks/datanodestore/DataLeafNodeTest.cpp @@ -70,9 +70,20 @@ public: unique_ptr _blockStore; BlockStore *blockStore; unique_ptr nodeStore; - unique_ptr leaf; + unique_ptr leaf; }; +TEST_F(DataLeafNodeTest, InitializesCorrectly) { + leaf->InitializeNewNode(); + EXPECT_EQ(0u, leaf->numBytesInThisNode()); +} + +TEST_F(DataLeafNodeTest, ReinitializesCorrectly) { + leaf->resize(5); + leaf->InitializeNewNode(); + EXPECT_EQ(0u, leaf->numBytesInThisNode()); +} + TEST_F(DataLeafNodeTest, ReadWrittenDataImmediately) { leaf->resize(randomData.size()); leaf->write(0, randomData.size(), randomData);