Use cpputils::DataFixture instead of DataBlockFixture
This commit is contained in:
parent
6a0623956d
commit
b4e2eaa3e8
@ -1,6 +1,6 @@
|
|||||||
#include "testutils/BlobStoreTest.h"
|
#include "testutils/BlobStoreTest.h"
|
||||||
#include <messmer/cpp-utils/data/Data.h>
|
#include <messmer/cpp-utils/data/Data.h>
|
||||||
#include <messmer/cpp-utils/data/DataBlockFixture.h>
|
#include <messmer/cpp-utils/data/DataFixture.h>
|
||||||
#include "../../../implementations/onblocks/datanodestore/DataNodeView.h"
|
#include "../../../implementations/onblocks/datanodestore/DataNodeView.h"
|
||||||
|
|
||||||
using std::unique_ptr;
|
using std::unique_ptr;
|
||||||
@ -11,7 +11,7 @@ using namespace blobstore;
|
|||||||
using blobstore::onblocks::datanodestore::DataNodeLayout;
|
using blobstore::onblocks::datanodestore::DataNodeLayout;
|
||||||
using blockstore::Key;
|
using blockstore::Key;
|
||||||
using cpputils::Data;
|
using cpputils::Data;
|
||||||
using cpputils::DataBlockFixture;
|
using cpputils::DataFixture;
|
||||||
|
|
||||||
class BlobReadWriteTest: public BlobStoreTest {
|
class BlobReadWriteTest: public BlobStoreTest {
|
||||||
public:
|
public:
|
||||||
@ -19,7 +19,7 @@ public:
|
|||||||
static constexpr DataNodeLayout LAYOUT = DataNodeLayout(BLOCKSIZE_BYTES);
|
static constexpr DataNodeLayout LAYOUT = DataNodeLayout(BLOCKSIZE_BYTES);
|
||||||
|
|
||||||
BlobReadWriteTest()
|
BlobReadWriteTest()
|
||||||
:randomData(LARGE_SIZE),
|
:randomData(DataFixture::generate(LARGE_SIZE)),
|
||||||
blob(blobStore->create()) {
|
blob(blobStore->create()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ public:
|
|||||||
EXPECT_EQ(0, std::memcmp(expected.data(), read.data(), size));
|
EXPECT_EQ(0, std::memcmp(expected.data(), read.data(), size));
|
||||||
}
|
}
|
||||||
|
|
||||||
DataBlockFixture randomData;
|
Data randomData;
|
||||||
unique_ptr<Blob> blob;
|
unique_ptr<Blob> blob;
|
||||||
};
|
};
|
||||||
constexpr uint32_t BlobReadWriteTest::LARGE_SIZE;
|
constexpr uint32_t BlobReadWriteTest::LARGE_SIZE;
|
||||||
@ -64,12 +64,12 @@ struct DataRange {
|
|||||||
};
|
};
|
||||||
class BlobReadWriteDataTest: public BlobReadWriteTest, public WithParamInterface<DataRange> {
|
class BlobReadWriteDataTest: public BlobReadWriteTest, public WithParamInterface<DataRange> {
|
||||||
public:
|
public:
|
||||||
DataBlockFixture foregroundData;
|
Data foregroundData;
|
||||||
DataBlockFixture backgroundData;
|
Data backgroundData;
|
||||||
|
|
||||||
BlobReadWriteDataTest()
|
BlobReadWriteDataTest()
|
||||||
: foregroundData(GetParam().count),
|
: foregroundData(DataFixture::generate(GetParam().count, 0)),
|
||||||
backgroundData(GetParam().blobsize) {
|
backgroundData(DataFixture::generate(GetParam().blobsize, 1)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class DataClass>
|
template<class DataClass>
|
||||||
@ -146,7 +146,7 @@ TEST_P(BlobReadWriteDataTest, WriteWholeAndReadPart) {
|
|||||||
blob->write(this->backgroundData.data(), 0, GetParam().blobsize);
|
blob->write(this->backgroundData.data(), 0, GetParam().blobsize);
|
||||||
Data read(GetParam().count);
|
Data read(GetParam().count);
|
||||||
blob->read(read.data(), GetParam().offset, GetParam().count);
|
blob->read(read.data(), GetParam().offset, GetParam().count);
|
||||||
EXPECT_EQ(0, std::memcmp(read.data(), this->backgroundData.data()+GetParam().offset, GetParam().count));
|
EXPECT_EQ(0, std::memcmp(read.data(), (uint8_t*)this->backgroundData.data()+GetParam().offset, GetParam().count));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(BlobReadWriteDataTest, WritePartAndReadWhole) {
|
TEST_P(BlobReadWriteDataTest, WritePartAndReadWhole) {
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
#include "testutils/BlobStoreTest.h"
|
#include "testutils/BlobStoreTest.h"
|
||||||
#include <messmer/cpp-utils/data/Data.h>
|
#include <messmer/cpp-utils/data/Data.h>
|
||||||
#include <messmer/cpp-utils/data/DataBlockFixture.h>
|
#include <messmer/cpp-utils/data/DataFixture.h>
|
||||||
|
|
||||||
using std::unique_ptr;
|
using std::unique_ptr;
|
||||||
|
|
||||||
using namespace blobstore;
|
using namespace blobstore;
|
||||||
using blockstore::Key;
|
using blockstore::Key;
|
||||||
using cpputils::Data;
|
using cpputils::Data;
|
||||||
using cpputils::DataBlockFixture;
|
using cpputils::DataFixture;
|
||||||
|
|
||||||
class BlobSizeTest: public BlobStoreTest {
|
class BlobSizeTest: public BlobStoreTest {
|
||||||
public:
|
public:
|
||||||
@ -122,7 +122,7 @@ class BlobSizeDataTest: public BlobSizeTest {
|
|||||||
public:
|
public:
|
||||||
BlobSizeDataTest()
|
BlobSizeDataTest()
|
||||||
:ZEROES(LARGE_SIZE),
|
:ZEROES(LARGE_SIZE),
|
||||||
randomData(LARGE_SIZE) {
|
randomData(DataFixture::generate(LARGE_SIZE)) {
|
||||||
ZEROES.FillWithZeroes();
|
ZEROES.FillWithZeroes();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
Data ZEROES;
|
Data ZEROES;
|
||||||
DataBlockFixture randomData;
|
Data randomData;
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(BlobSizeDataTest, BlobIsZeroedOutAfterGrowing) {
|
TEST_F(BlobSizeDataTest, BlobIsZeroedOutAfterGrowing) {
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#include "messmer/blockstore/implementations/testfake/FakeBlockStore.h"
|
#include "messmer/blockstore/implementations/testfake/FakeBlockStore.h"
|
||||||
#include "messmer/blockstore/implementations/testfake/FakeBlock.h"
|
#include "messmer/blockstore/implementations/testfake/FakeBlock.h"
|
||||||
#include <messmer/cpp-utils/data/DataBlockFixture.h>
|
#include <messmer/cpp-utils/data/DataFixture.h>
|
||||||
|
|
||||||
using ::testing::Test;
|
using ::testing::Test;
|
||||||
using ::testing::WithParamInterface;
|
using ::testing::WithParamInterface;
|
||||||
@ -17,7 +17,7 @@ using ::testing::Combine;
|
|||||||
using std::unique_ptr;
|
using std::unique_ptr;
|
||||||
using std::make_unique;
|
using std::make_unique;
|
||||||
using std::string;
|
using std::string;
|
||||||
using cpputils::DataBlockFixture;
|
using cpputils::DataFixture;
|
||||||
|
|
||||||
//TODO Split into multiple files
|
//TODO Split into multiple files
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ public:
|
|||||||
|
|
||||||
ZEROES.FillWithZeroes();
|
ZEROES.FillWithZeroes();
|
||||||
|
|
||||||
DataBlockFixture dataFixture(nodeStore->layout().maxBytesPerLeaf());
|
Data dataFixture(DataFixture::generate(nodeStore->layout().maxBytesPerLeaf()));
|
||||||
|
|
||||||
std::memcpy(randomData.data(), dataFixture.data(), randomData.size());
|
std::memcpy(randomData.data(), dataFixture.data(), randomData.size());
|
||||||
}
|
}
|
||||||
@ -282,11 +282,9 @@ public:
|
|||||||
Data foregroundData;
|
Data foregroundData;
|
||||||
Data backgroundData;
|
Data backgroundData;
|
||||||
|
|
||||||
DataLeafNodeDataTest(): foregroundData(GetParam().count), backgroundData(GetParam().leafsize) {
|
DataLeafNodeDataTest():
|
||||||
DataBlockFixture _foregroundData(GetParam().count);
|
foregroundData(DataFixture::generate(GetParam().count, 0)),
|
||||||
DataBlockFixture _backgroundData(GetParam().leafsize);
|
backgroundData(DataFixture::generate(GetParam().leafsize, 1)) {
|
||||||
std::memcpy(foregroundData.data(), _foregroundData.data(), foregroundData.size());
|
|
||||||
std::memcpy(backgroundData.data(), _backgroundData.data(), backgroundData.size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EXPECT_DATA_EQ(const Data &expected, const Data &actual) {
|
void EXPECT_DATA_EQ(const Data &expected, const Data &actual) {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "messmer/blockstore/implementations/testfake/FakeBlockStore.h"
|
#include "messmer/blockstore/implementations/testfake/FakeBlockStore.h"
|
||||||
#include "messmer/blockstore/implementations/testfake/FakeBlock.h"
|
#include "messmer/blockstore/implementations/testfake/FakeBlock.h"
|
||||||
#include "../../../../implementations/onblocks/BlobStoreOnBlocks.h"
|
#include "../../../../implementations/onblocks/BlobStoreOnBlocks.h"
|
||||||
#include <messmer/cpp-utils/data/DataBlockFixture.h>
|
#include <messmer/cpp-utils/data/DataFixture.h>
|
||||||
|
|
||||||
using ::testing::Test;
|
using ::testing::Test;
|
||||||
using ::testing::WithParamInterface;
|
using ::testing::WithParamInterface;
|
||||||
@ -16,7 +16,7 @@ using std::string;
|
|||||||
using blockstore::BlockStore;
|
using blockstore::BlockStore;
|
||||||
using blockstore::testfake::FakeBlockStore;
|
using blockstore::testfake::FakeBlockStore;
|
||||||
using cpputils::Data;
|
using cpputils::Data;
|
||||||
using cpputils::DataBlockFixture;
|
using cpputils::DataFixture;
|
||||||
using namespace blobstore;
|
using namespace blobstore;
|
||||||
using namespace blobstore::onblocks;
|
using namespace blobstore::onblocks;
|
||||||
using namespace blobstore::onblocks::datanodestore;
|
using namespace blobstore::onblocks::datanodestore;
|
||||||
@ -60,7 +60,7 @@ TEST_P(DataNodeViewSizeTest, SizeIsStored) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DataNodeViewTest, DataIsStored) {
|
TEST_F(DataNodeViewTest, DataIsStored) {
|
||||||
DataBlockFixture randomData(DATASIZE_BYTES);
|
Data randomData = DataFixture::generate(DATASIZE_BYTES);
|
||||||
auto block = blockStore->create(Data(BLOCKSIZE_BYTES));
|
auto block = blockStore->create(Data(BLOCKSIZE_BYTES));
|
||||||
auto key = block->key();
|
auto key = block->key();
|
||||||
{
|
{
|
||||||
@ -72,7 +72,7 @@ TEST_F(DataNodeViewTest, DataIsStored) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DataNodeViewTest, HeaderAndBodyDontOverlap) {
|
TEST_F(DataNodeViewTest, HeaderAndBodyDontOverlap) {
|
||||||
DataBlockFixture randomData(DATASIZE_BYTES);
|
Data randomData = DataFixture::generate(DATASIZE_BYTES);
|
||||||
auto block = blockStore->create(Data(BLOCKSIZE_BYTES));
|
auto block = blockStore->create(Data(BLOCKSIZE_BYTES));
|
||||||
auto key = block->key();
|
auto key = block->key();
|
||||||
{
|
{
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
|
|
||||||
#include <google/gtest/gtest.h>
|
#include <google/gtest/gtest.h>
|
||||||
|
|
||||||
#include <messmer/cpp-utils/data/DataBlockFixture.h>
|
#include <messmer/cpp-utils/data/DataFixture.h>
|
||||||
|
|
||||||
// A data fixture containing data for a leaf.
|
// A data fixture containing data for a leaf.
|
||||||
// The class can fill this data into a given leaf
|
// The class can fill this data into a given leaf
|
||||||
// and check, whether the data stored in a given leaf is correct.
|
// and check, whether the data stored in a given leaf is correct.
|
||||||
class LeafDataFixture {
|
class LeafDataFixture {
|
||||||
public:
|
public:
|
||||||
LeafDataFixture(int size, int iv = 0): _data(size, iv) {}
|
LeafDataFixture(int size, int iv = 0): _data(cpputils::DataFixture::generate(size, iv)) {}
|
||||||
|
|
||||||
void FillInto(blobstore::onblocks::datanodestore::DataLeafNode *leaf) const {
|
void FillInto(blobstore::onblocks::datanodestore::DataLeafNode *leaf) const {
|
||||||
leaf->resize(_data.size());
|
leaf->resize(_data.size());
|
||||||
@ -34,7 +34,7 @@ private:
|
|||||||
leaf.read(data.data(), 0, leaf.numBytes());
|
leaf.read(data.data(), 0, leaf.numBytes());
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
cpputils::DataBlockFixture _data;
|
cpputils::Data _data;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user