From cf6ef7c02c1a70ce4f4727e67ec2024a0816290c Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Sun, 21 Jun 2015 14:40:57 +0200 Subject: [PATCH] Use C++11 uniform initialization for structs --- .../testutils/FakeAuthenticatedCipher.h | 9 ++++----- .../helpers/BlockStoreWithRandomKeysTest.cpp | 2 +- test/testutils/BlockStoreTest_Data.h | 17 ++++++++--------- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/test/implementations/encrypted/testutils/FakeAuthenticatedCipher.h b/test/implementations/encrypted/testutils/FakeAuthenticatedCipher.h index ad8232eb..6ece03d9 100644 --- a/test/implementations/encrypted/testutils/FakeAuthenticatedCipher.h +++ b/test/implementations/encrypted/testutils/FakeAuthenticatedCipher.h @@ -6,12 +6,11 @@ #include 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) { diff --git a/test/interface/helpers/BlockStoreWithRandomKeysTest.cpp b/test/interface/helpers/BlockStoreWithRandomKeysTest.cpp index a6d0d53d..4d5c834d 100644 --- a/test/interface/helpers/BlockStoreWithRandomKeysTest.cpp +++ b/test/interface/helpers/BlockStoreWithRandomKeysTest.cpp @@ -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()); diff --git a/test/testutils/BlockStoreTest_Data.h b/test/testutils/BlockStoreTest_Data.h index 202c8b32..21a5ca66 100644 --- a/test/testutils/BlockStoreTest_Data.h +++ b/test/testutils/BlockStoreTest_Data.h @@ -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 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) { \