Use C++11 uniform initialization for structs

This commit is contained in:
Sebastian Messmer 2015-06-21 14:40:57 +02:00
parent 8cfa133676
commit cf6ef7c02c
3 changed files with 13 additions and 15 deletions

View File

@ -6,12 +6,11 @@
#include <messmer/cpp-utils/data/FixedSizeData.h>
struct FakeKey {
FakeKey(uint8_t value_):value(value_) {}
static FakeKey CreateOSRandom() {
return FakeKey(rand());
return FakeKey{(uint8_t)rand()};
}
static FakeKey FromBinary(const void *data) {
return FakeKey(*(uint8_t*)data);
return FakeKey{*(uint8_t*)data};
}
static constexpr unsigned int BINARY_LENGTH = 1;
@ -26,10 +25,10 @@ public:
using EncryptionKey = FakeKey;
static EncryptionKey Key1() {
return FakeKey(5);
return FakeKey{5};
}
static EncryptionKey Key2() {
return FakeKey(63);
return FakeKey{63};
}
static constexpr unsigned int ciphertextSize(unsigned int plaintextBlockSize) {

View File

@ -34,7 +34,7 @@ public:
class BlockMock: public Block {
public:
BlockMock(): Block(Key::CreateOSRandom()) {}
BlockMock(): Block(Key::CreatePseudoRandom()) {}
MOCK_CONST_METHOD0(data, const void*());
MOCK_METHOD3(write, void(const void*, uint64_t, uint64_t));
MOCK_METHOD0(flush, void());

View File

@ -1,7 +1,6 @@
// This file is meant to be included by BlockStoreTest.h only
struct DataRange {
constexpr DataRange(size_t blocksize_, off_t offset_, size_t count_): blocksize(blocksize_), offset(offset_), count(count_) {}
size_t blocksize;
off_t offset;
size_t count;
@ -77,14 +76,14 @@ private:
}
};
constexpr std::initializer_list<DataRange> DATA_RANGES = {
DataRange(1024, 0, 1024), // full size leaf, access beginning to end
DataRange(1024, 100, 1024-200), // full size leaf, access middle to middle
DataRange(1024, 0, 1024-100), // full size leaf, access beginning to middle
DataRange(1024, 100, 1024-100), // full size leaf, access middle to end
DataRange(1024-100, 0, 1024-100), // non-full size leaf, access beginning to end
DataRange(1024-100, 100, 1024-300), // non-full size leaf, access middle to middle
DataRange(1024-100, 0, 1024-200), // non-full size leaf, access beginning to middle
DataRange(1024-100, 100, 1024-200) // non-full size leaf, access middle to end
DataRange{1024, 0, 1024}, // full size leaf, access beginning to end
DataRange{1024, 100, 1024-200}, // full size leaf, access middle to middle
DataRange{1024, 0, 1024-100}, // full size leaf, access beginning to middle
DataRange{1024, 100, 1024-100}, // full size leaf, access middle to end
DataRange{1024-100, 0, 1024-100}, // non-full size leaf, access beginning to end
DataRange{1024-100, 100, 1024-300}, // non-full size leaf, access middle to middle
DataRange{1024-100, 0, 1024-200}, // non-full size leaf, access beginning to middle
DataRange{1024-100, 100, 1024-200} // non-full size leaf, access middle to end
};
#define TYPED_TEST_P_FOR_ALL_DATA_RANGES(TestName) \
TYPED_TEST_P(BlockStoreTest, TestName) { \