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