Add test cases to KnownBlockVersionsTest

This commit is contained in:
Sebastian Messmer 2016-06-25 15:41:22 -07:00
parent c84a230afd
commit 2284571127
1 changed files with 38 additions and 0 deletions

View File

@ -297,3 +297,41 @@ TEST_F(KnownBlockVersionsTest, saveAndLoad_lastUpdateClientIdIsStored) {
EXPECT_TRUE(obj.checkAndUpdateVersion(clientId2, key, 10));
EXPECT_TRUE(obj.checkAndUpdateVersion(clientId, key, 101));
}
TEST_F(KnownBlockVersionsTest, markAsDeleted_doesntAllowReIntroducing_sameClientId) {
setVersion(&testobj, clientId, key, 5);
testobj.markBlockAsDeleted(key);
EXPECT_FALSE(testobj.checkAndUpdateVersion(clientId, key, 5));
}
TEST_F(KnownBlockVersionsTest, markAsDeleted_doesntAllowReIntroducing_oldClientId) {
setVersion(&testobj, clientId, key, 5);
setVersion(&testobj, clientId2, key, 5);
testobj.markBlockAsDeleted(key);
EXPECT_FALSE(testobj.checkAndUpdateVersion(clientId, key, 5));
}
TEST_F(KnownBlockVersionsTest, markAsDeleted_checkAndUpdateDoesntDestroyState) {
setVersion(&testobj, clientId, key, 5);
setVersion(&testobj, clientId2, key, 5);
testobj.markBlockAsDeleted(key);
EXPECT_FALSE(testobj.checkAndUpdateVersion(clientId, key, 5));
// Check block is still deleted
EXPECT_FALSE(testobj.blockShouldExist(key));
}
TEST_F(KnownBlockVersionsTest, blockShouldExist_unknownBlock) {
EXPECT_FALSE(testobj.blockShouldExist(key));
}
TEST_F(KnownBlockVersionsTest, blockShouldExist_knownBlock) {
setVersion(&testobj, clientId, key, 5);
EXPECT_TRUE(testobj.blockShouldExist(key));
}
TEST_F(KnownBlockVersionsTest, blockShouldExist_deletedBlock) {
setVersion(&testobj, clientId, key, 5);
testobj.markBlockAsDeleted(key);
EXPECT_FALSE(testobj.blockShouldExist(key));
}