Remove Key::CreateDummyKey()

This commit is contained in:
Sebastian Messmer 2014-12-09 20:57:10 +01:00
parent fa5058c8e3
commit 1924c936a4
5 changed files with 10 additions and 15 deletions

View File

@ -35,12 +35,6 @@ Key Key::CreateRandomKey() {
return result;
}
Key Key::CreateDummyKey() {
Key result;
std::memset(result._key, 0, KEYLENGTH_BINARY);
return result;
}
Key Key::FromString(const std::string &key) {
assert(key.size() == KEYLENGTH_STRING);
Key result;

View File

@ -16,7 +16,6 @@ public:
static constexpr unsigned int KEYLENGTH_STRING = 2 * KEYLENGTH_BINARY; // Hex encoding
static Key CreateRandomKey();
static Key CreateDummyKey();
static Key FromString(const std::string &key);
std::string AsString() const;

View File

@ -38,6 +38,7 @@ class BlockStoreWithRandomKeysTest: public Test {
public:
BlockStoreWithRandomKeysMock blockStoreMock;
BlockStore &blockStore = blockStoreMock;
const blockstore::Key key = Key::FromString("1491BB4932A389EE14BC7090AC772972");
};
TEST_F(BlockStoreWithRandomKeysTest, SizeIsPassedThrough0) {
@ -65,7 +66,7 @@ TEST_F(BlockStoreWithRandomKeysTest, KeyHasCorrectSize) {
}
TEST_F(BlockStoreWithRandomKeysTest, TwoBlocksGetDifferentKeys) {
Key first_key = Key::CreateDummyKey();
Key first_key = key;
EXPECT_CALL(blockStoreMock, do_create(_, _))
.WillOnce(Invoke([&first_key](const Key &key, size_t) {
first_key = key;
@ -81,7 +82,7 @@ TEST_F(BlockStoreWithRandomKeysTest, TwoBlocksGetDifferentKeys) {
}
TEST_F(BlockStoreWithRandomKeysTest, WillTryADifferentKeyIfKeyAlreadyExists) {
Key first_key = Key::CreateDummyKey();
Key first_key = key;
EXPECT_CALL(blockStoreMock, do_create(_, _))
.WillOnce(Invoke([&first_key](const Key &key, size_t) {
first_key = key;
@ -96,7 +97,7 @@ TEST_F(BlockStoreWithRandomKeysTest, WillTryADifferentKeyIfKeyAlreadyExists) {
}
TEST_F(BlockStoreWithRandomKeysTest, WillTryADifferentKeyIfKeyAlreadyExistsTwoTimes) {
Key first_key = Key::CreateDummyKey();
Key first_key = key;
EXPECT_CALL(blockStoreMock, do_create(_, _))
.WillOnce(Invoke([&first_key](const Key &key, size_t) {
first_key = key;

View File

@ -85,7 +85,7 @@ public:
void TestAfterCreate_FlushesWhenDestructed() {
DataBlockFixture randomData(size);
blockstore::Key key = blockstore::Key::CreateDummyKey();
blockstore::Key key = key;
{
auto block = blockStore->create(size);
key = block.key;
@ -97,7 +97,7 @@ public:
void TestAfterLoad_FlushesWhenDestructed() {
DataBlockFixture randomData(size);
blockstore::Key key = blockstore::Key::CreateDummyKey();
blockstore::Key key = key;
{
key = blockStore->create(size).key;
auto block = blockStore->load(key);
@ -109,17 +109,18 @@ public:
void TestLoadNonExistingBlock() {
EXPECT_FALSE(
(bool)blockStore->load(blockstore::Key::CreateRandomKey())
(bool)blockStore->load(key)
);
}
void TestLoadNonExistingBlockWithEmptyKey() {
EXPECT_FALSE(
(bool)blockStore->load(blockstore::Key::CreateDummyKey())
(bool)blockStore->load(key)
);
}
private:
const blockstore::Key key = blockstore::Key::FromString("1491BB4932A389EE14BC7090AC772972");
std::unique_ptr<blockstore::BlockStore> blockStore;
size_t size;

View File

@ -21,7 +21,7 @@ public:
"Given test fixture for instantiating the (type parameterized) BlockStoreWithRandomKeysTest must inherit from BlockStoreWithRandomKeysTestFixture"
);
blockstore::Key key = blockstore::Key::CreateDummyKey();
blockstore::Key key = blockstore::Key::FromString("1491BB4932A389EE14BC7090AC772972");
const std::vector<size_t> SIZES = {0, 1, 1024, 4096, 10*1024*1024};