Test cases for BlockStore::numBlocks()

This commit is contained in:
Sebastian Messmer 2015-02-24 14:42:26 +01:00
parent f491d3d183
commit 1006c2cc38
2 changed files with 39 additions and 2 deletions

View File

@ -21,7 +21,6 @@ public:
virtual std::unique_ptr<Block> load(const Key &key) = 0;
virtual void remove(std::unique_ptr<Block> block) = 0;
virtual uint64_t numBlocks() const = 0;
//TODO Test numBlocks
};
}

View File

@ -209,6 +209,39 @@ TYPED_TEST_P(BlockStoreTest, BlockIsNotLoadableAfterDeleting) {
EXPECT_EQ(nullptr, blockStore->load(blockkey));
}
TYPED_TEST_P(BlockStoreTest, NumBlocksIsCorrectOnEmptyBlockstore) {
auto blockStore = this->fixture.createBlockStore();
EXPECT_EQ(0, blockStore->numBlocks());
}
TYPED_TEST_P(BlockStoreTest, NumBlocksIsCorrectAfterAddingOneBlock) {
auto blockStore = this->fixture.createBlockStore();
blockStore->create(1);
EXPECT_EQ(1, blockStore->numBlocks());
}
TYPED_TEST_P(BlockStoreTest, NumBlocksIsCorrectAfterRemovingTheLastBlock) {
auto blockStore = this->fixture.createBlockStore();
auto block = blockStore->create(1);
blockStore->remove(std::move(block));
EXPECT_EQ(0, blockStore->numBlocks());
}
TYPED_TEST_P(BlockStoreTest, NumBlocksIsCorrectAfterAddingTwoBlocks) {
auto blockStore = this->fixture.createBlockStore();
blockStore->create(1);
blockStore->create(0);
EXPECT_EQ(2, blockStore->numBlocks());
}
TYPED_TEST_P(BlockStoreTest, NumBlocksIsCorrectAfterRemovingABlock) {
auto blockStore = this->fixture.createBlockStore();
auto block = blockStore->create(1);
blockStore->create(1);
blockStore->remove(std::move(block));
EXPECT_EQ(1, blockStore->numBlocks());
}
REGISTER_TYPED_TEST_CASE_P(BlockStoreTest,
CreatedBlockHasCorrectSize,
LoadingUnchangedBlockHasCorrectSize,
@ -223,7 +256,12 @@ REGISTER_TYPED_TEST_CASE_P(BlockStoreTest,
LoadNonExistingBlock,
LoadNonExistingBlockWithEmptyKey,
TwoCreatedBlocksHaveDifferentKeys,
BlockIsNotLoadableAfterDeleting
BlockIsNotLoadableAfterDeleting,
NumBlocksIsCorrectOnEmptyBlockstore,
NumBlocksIsCorrectAfterAddingOneBlock,
NumBlocksIsCorrectAfterRemovingTheLastBlock,
NumBlocksIsCorrectAfterAddingTwoBlocks,
NumBlocksIsCorrectAfterRemovingABlock
);