Skip to content
This repository has been archived by the owner on Mar 22, 2023. It is now read-only.

Commit

Permalink
tests: manual transaction no commit test
Browse files Browse the repository at this point in the history
  • Loading branch information
igchor committed Sep 23, 2020
1 parent 67f0c29 commit 8073cce
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/transaction/transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,38 @@ test_tx_automatic_destructor_throw(nvobj::pool<root> &pop)
UT_ASSERT(rootp->parr == nullptr);
}

/*
* test_tx_manual_no_commit -- test manual transaction with no commit
*/
void
test_tx_manual_no_commit(nvobj::pool<root> &pop)
{
auto rootp = pop.root();

try {
nvobj::transaction::manual tx(pop);
rootp->pfoo = nvobj::make_persistent<foo>();
} catch (...) {
UT_ASSERT(0);
}

UT_ASSERT(rootp->pfoo == nullptr);

try {
nvobj::transaction::manual tx1(pop);
{
nvobj::transaction::manual tx2(pop);
rootp->pfoo = nvobj::make_persistent<foo>();
}

UT_ASSERT(rootp->pfoo == nullptr);
} catch (...) {
UT_ASSERT(0);
}

UT_ASSERT(rootp->pfoo == nullptr);
}

/*
* test_tx_snapshot -- 1) Check if transaction_error is thrown, when snapshot()
* is not called from transaction.
Expand Down Expand Up @@ -1078,6 +1110,8 @@ test(int argc, char *argv[])
test_tx_no_throw_abort_scope<nvobj::transaction::automatic>(pop);
test_tx_automatic_destructor_throw(pop);

test_tx_manual_no_commit(pop);

test_tx_snapshot(pop);

test_tx_callback(pop);
Expand Down

0 comments on commit 8073cce

Please sign in to comment.