diff --git a/src/test/blobstore/implementations/onblocks/impl/DataLeafNodeTest.cpp b/src/test/blobstore/implementations/onblocks/impl/DataLeafNodeTest.cpp index 4fcc9316..b272dc6a 100644 --- a/src/test/blobstore/implementations/onblocks/impl/DataLeafNodeTest.cpp +++ b/src/test/blobstore/implementations/onblocks/impl/DataLeafNodeTest.cpp @@ -1,7 +1,7 @@ #include -#include "blockstore/implementations/inmemory/InMemoryBlockStore.h" -#include "blockstore/implementations/inmemory/InMemoryBlock.h" +#include "blockstore/implementations/testfake/FakeBlockStore.h" +#include "blockstore/implementations/testfake/FakeBlock.h" #include "blobstore/implementations/onblocks/BlobStoreOnBlocks.h" #include "blobstore/implementations/onblocks/impl/DataLeafNode.h" #include "test/testutils/DataBlockFixture.h" @@ -16,7 +16,7 @@ using std::string; using blockstore::BlockStore; using blockstore::BlockWithKey; using blockstore::Data; -using blockstore::inmemory::InMemoryBlockStore; +using blockstore::testfake::FakeBlockStore; using namespace blobstore; using namespace blobstore::onblocks; @@ -28,7 +28,7 @@ public: DataLeafNodeTest(): ZEROES(DataLeafNode::MAX_STORED_BYTES), randomData(DataLeafNode::MAX_STORED_BYTES), - blockStore(make_unique()), + blockStore(make_unique()), block(blockStore->create(DataNodeView::BLOCKSIZE_BYTES)), leafblock(blockStore->create(DataNodeView::BLOCKSIZE_BYTES)), leafblockdata((uint8_t*)leafblock.block->data()), diff --git a/src/test/blobstore/implementations/onblocks/impl/DataNodeTest.cpp b/src/test/blobstore/implementations/onblocks/impl/DataNodeTest.cpp index c339b504..6ffcaffc 100644 --- a/src/test/blobstore/implementations/onblocks/impl/DataNodeTest.cpp +++ b/src/test/blobstore/implementations/onblocks/impl/DataNodeTest.cpp @@ -1,7 +1,7 @@ #include -#include "blockstore/implementations/inmemory/InMemoryBlockStore.h" -#include "blockstore/implementations/inmemory/InMemoryBlock.h" +#include "blockstore/implementations/testfake/FakeBlockStore.h" +#include "blockstore/implementations/testfake/FakeBlock.h" #include "blobstore/implementations/onblocks/BlobStoreOnBlocks.h" #include "blobstore/implementations/onblocks/impl/DataNode.h" #include "blobstore/implementations/onblocks/impl/DataLeafNode.h" @@ -13,13 +13,13 @@ using std::make_unique; using std::string; using blockstore::BlockStore; -using blockstore::inmemory::InMemoryBlockStore; +using blockstore::testfake::FakeBlockStore; using namespace blobstore; using namespace blobstore::onblocks; class DataNodeTest: public Test { public: - unique_ptr blockStore = make_unique(); + unique_ptr blockStore = make_unique(); }; #define EXPECT_IS_PTR_TYPE(Type, ptr) EXPECT_NE(nullptr, dynamic_cast(ptr)) << "Given pointer cannot be cast to the given type" diff --git a/src/test/blobstore/implementations/onblocks/impl/DataNodeViewTest.cpp b/src/test/blobstore/implementations/onblocks/impl/DataNodeViewTest.cpp index 78099121..7107ba34 100644 --- a/src/test/blobstore/implementations/onblocks/impl/DataNodeViewTest.cpp +++ b/src/test/blobstore/implementations/onblocks/impl/DataNodeViewTest.cpp @@ -1,7 +1,7 @@ #include -#include "blockstore/implementations/inmemory/InMemoryBlockStore.h" -#include "blockstore/implementations/inmemory/InMemoryBlock.h" +#include "blockstore/implementations/testfake/FakeBlockStore.h" +#include "blockstore/implementations/testfake/FakeBlock.h" #include "blobstore/implementations/onblocks/BlobStoreOnBlocks.h" #include "blobstore/implementations/onblocks/impl/DataNodeView.h" #include "test/testutils/DataBlockFixture.h" @@ -14,7 +14,7 @@ using std::make_unique; using std::string; using blockstore::BlockStore; -using blockstore::inmemory::InMemoryBlockStore; +using blockstore::testfake::FakeBlockStore; using namespace blobstore; using namespace blobstore::onblocks; @@ -25,7 +25,7 @@ public: // because the next block load will just give you the same data region (and the overflow data will most // likely still be intact). // So better write a FakeBlockStore class for test cases. - unique_ptr blockStore = make_unique(); + unique_ptr blockStore = make_unique(); }; TEST_F(DataNodeViewTest, MagicNumberIsStored) { @@ -54,13 +54,13 @@ TEST_P(DataNodeViewSizeTest, SizeIsStored) { TEST_F(DataNodeViewTest, DataIsStored) { DataBlockFixture randomData(DataNodeView::DATASIZE_BYTES); - auto block = blockStore->create(BlobStoreOnBlocks::BLOCKSIZE); + auto block = blockStore->create(DataNodeView::BLOCKSIZE_BYTES); { DataNodeView view(std::move(block.block)); - std::memcpy(view.DataBegin(), randomData.data(), DataNodeView::DATASIZE_BYTES); + std::memcpy(view.DataBegin(), randomData.data(), randomData.size()); } DataNodeView view(blockStore->load(block.key)); - EXPECT_EQ(0, std::memcmp(view.DataBegin(), randomData.data(), DataNodeView::DATASIZE_BYTES)); + EXPECT_EQ(0, std::memcmp(view.DataBegin(), randomData.data(), randomData.size())); } TEST_F(DataNodeViewTest, HeaderAndBodyDontOverlap) { diff --git a/src/test/testutils/DataBlockFixture.cpp b/src/test/testutils/DataBlockFixture.cpp index b4413121..ec50b91c 100644 --- a/src/test/testutils/DataBlockFixture.cpp +++ b/src/test/testutils/DataBlockFixture.cpp @@ -20,6 +20,12 @@ void DataBlockFixture::fillFileWithRandomData(long long int IV) { val += 1442695040888963407; reinterpret_cast(_fileData)[i] = val; } + //Fill remaining bytes + for(size_t i=(_size/sizeof(long long int))*sizeof(long long int); i<_size; ++i) { + val *= 6364136223846793005L; + val += 1442695040888963407; + reinterpret_cast(_fileData)[i] = val; + } } const char *DataBlockFixture::data() const {