Some reformation, test cases and first bugfixes
This commit is contained in:
parent
e88efb458f
commit
ef86d0adf9
5 changed files with 93 additions and 47 deletions
|
@ -436,5 +436,40 @@ TEST_F(CacheCursorTest, CornerCases) {
|
|||
EXPECT_EQ(element.first, reference->first);
|
||||
EXPECT_EQ(element.second, reference->second);
|
||||
EXPECT_THROW(cursor.prev(), LMDBAL::NotFound);
|
||||
|
||||
cursor.close();
|
||||
}
|
||||
|
||||
TEST_F(CacheCursorTest, TerminatedTransaction) {
|
||||
LMDBAL::Cursor<uint64_t, std::string> cr = cache->createCursor();
|
||||
|
||||
{
|
||||
LMDBAL::Transaction txn = db->beginReadOnlyTransaction();
|
||||
cr.open(txn);
|
||||
EXPECT_NO_THROW(cr.first());
|
||||
}
|
||||
|
||||
EXPECT_FALSE(cr.opened());
|
||||
|
||||
LMDBAL::Transaction txn2;
|
||||
{
|
||||
LMDBAL::Transaction txn = db->beginReadOnlyTransaction();
|
||||
EXPECT_TRUE(txn.isActive());
|
||||
EXPECT_FALSE(txn2.isActive());
|
||||
|
||||
cr.open(txn);
|
||||
EXPECT_TRUE(cr.opened());
|
||||
|
||||
txn2 = std::move(txn);
|
||||
EXPECT_FALSE(txn.isActive());
|
||||
EXPECT_TRUE(txn2.isActive());
|
||||
EXPECT_TRUE(cr.opened());
|
||||
}
|
||||
|
||||
EXPECT_TRUE(txn2.isActive());
|
||||
EXPECT_TRUE(cr.opened());
|
||||
|
||||
txn2.terminate();
|
||||
EXPECT_FALSE(txn2.isActive());
|
||||
EXPECT_FALSE(cr.opened());
|
||||
}
|
||||
|
|
|
@ -419,13 +419,35 @@ TEST_F(StorageCursorTest, CornerCases) {
|
|||
}
|
||||
|
||||
TEST_F(StorageCursorTest, TerminatedTransaction) {
|
||||
LMDBAL::Cursor<uint64_t, std::string> emptyCursor = table->createCursor();
|
||||
LMDBAL::Cursor<uint64_t, std::string> cr = table->createCursor();
|
||||
|
||||
{
|
||||
LMDBAL::Transaction txn = db->beginReadOnlyTransaction();
|
||||
cursor.open(txn);
|
||||
EXPECT_NO_THROW(cursor.first());
|
||||
cr.open(txn);
|
||||
EXPECT_NO_THROW(cr.first());
|
||||
}
|
||||
|
||||
EXPECT_FALSE(cursor.opened());
|
||||
EXPECT_FALSE(cr.opened());
|
||||
|
||||
LMDBAL::Transaction txn2;
|
||||
{
|
||||
LMDBAL::Transaction txn = db->beginReadOnlyTransaction();
|
||||
EXPECT_TRUE(txn.isActive());
|
||||
EXPECT_FALSE(txn2.isActive());
|
||||
|
||||
cr.open(txn);
|
||||
EXPECT_TRUE(cr.opened());
|
||||
|
||||
txn2 = std::move(txn);
|
||||
EXPECT_FALSE(txn.isActive());
|
||||
EXPECT_TRUE(txn2.isActive());
|
||||
EXPECT_TRUE(cr.opened());
|
||||
}
|
||||
|
||||
EXPECT_TRUE(txn2.isActive());
|
||||
EXPECT_TRUE(cr.opened());
|
||||
|
||||
txn2.terminate();
|
||||
EXPECT_FALSE(txn2.isActive());
|
||||
EXPECT_FALSE(cr.opened());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue