Browse Source

Test naming updated (fixes #60).

main
offa 7 years ago
parent
commit
a75bc2df64
3 changed files with 16 additions and 16 deletions
  1. +4
    -4
      test/ScopeExitTest.cpp
  2. +6
    -6
      test/ScopeFailTest.cpp
  3. +6
    -6
      test/ScopeSuccessTest.cpp

+ 4
- 4
test/ScopeExitTest.cpp View File

} }




TEST_CASE("deleter called on destruction", "[ScopeExit]")
TEST_CASE("exit function called on destruction", "[ScopeExit]")
{ {
REQUIRE_CALL(m, deleter()); REQUIRE_CALL(m, deleter());
auto guard = sr::make_scope_exit(deleter); auto guard = sr::make_scope_exit(deleter);
static_cast<void>(guard); static_cast<void>(guard);
} }


TEST_CASE("deleter lambda called on destruction", "[ScopeExit]")
TEST_CASE("exit function lambda called on destruction", "[ScopeExit]")
{ {
CallMock cm; CallMock cm;
REQUIRE_CALL(cm, deleter()); REQUIRE_CALL(cm, deleter());
static_cast<void>(guard); static_cast<void>(guard);
} }


TEST_CASE("deleter called and rethrow on copy exception", "[ScopeExit]")
TEST_CASE("exit function called and rethrow on copy exception", "[ScopeExit]")
{ {
REQUIRE_THROWS([] { REQUIRE_THROWS([] {
const ThrowOnCopyMock noMove; const ThrowOnCopyMock noMove;
}()); }());
} }


TEST_CASE("deleter is not called if released", "[ScopeExit]")
TEST_CASE("exit function is not called if released", "[ScopeExit]")
{ {
REQUIRE_CALL(m, deleter()).TIMES(0); REQUIRE_CALL(m, deleter()).TIMES(0);
auto guard = sr::make_scope_exit(deleter); auto guard = sr::make_scope_exit(deleter);

+ 6
- 6
test/ScopeFailTest.cpp View File

} }




TEST_CASE("deleter called on destruction", "[ScopeFail]")
TEST_CASE("exit function called on destruction", "[ScopeFail]")
{ {
REQUIRE_CALL(m, deleter()).TIMES(0); REQUIRE_CALL(m, deleter()).TIMES(0);
auto guard = sr::make_scope_fail(deleter); auto guard = sr::make_scope_fail(deleter);
static_cast<void>(guard); static_cast<void>(guard);
} }


TEST_CASE("deleter lambda called on destruction", "[ScopeFail]")
TEST_CASE("exit function lambda called on destruction", "[ScopeFail]")
{ {
CallMock cm; CallMock cm;
REQUIRE_CALL(cm, deleter()).TIMES(0); REQUIRE_CALL(cm, deleter()).TIMES(0);
static_cast<void>(guard); static_cast<void>(guard);
} }


TEST_CASE("deleter called and rethrow on copy exception", "[ScopeFail]")
TEST_CASE("exit function called and rethrow on copy exception", "[ScopeFail]")
{ {
REQUIRE_THROWS([] { REQUIRE_THROWS([] {
const ThrowOnCopyMock noMove; const ThrowOnCopyMock noMove;
}()); }());
} }


TEST_CASE("deleter is not called if released", "[ScopeFail]")
TEST_CASE("exit function is not called if released", "[ScopeFail]")
{ {
REQUIRE_CALL(m, deleter()).TIMES(0); REQUIRE_CALL(m, deleter()).TIMES(0);
auto guard = sr::make_scope_fail(deleter); auto guard = sr::make_scope_fail(deleter);
static_cast<void>(guard); static_cast<void>(guard);
} }


TEST_CASE("deleter called on exception", "[ScopeFail]")
TEST_CASE("exit function called on exception", "[ScopeFail]")
{ {
try try
{ {
} }
} }


TEST_CASE("deleter not called on pending exception", "[ScopeFail]")
TEST_CASE("exit function not called on pending exception", "[ScopeFail]")
{ {
try try
{ {

+ 6
- 6
test/ScopeSuccessTest.cpp View File

} }




TEST_CASE("deleter called on destruction", "[ScopeSuccess]")
TEST_CASE("exit function called on destruction", "[ScopeSuccess]")
{ {
REQUIRE_CALL(m, deleter()); REQUIRE_CALL(m, deleter());
auto guard = sr::make_scope_success(deleter); auto guard = sr::make_scope_success(deleter);
static_cast<void>(guard); static_cast<void>(guard);
} }


TEST_CASE("deleter lambda called on destruction", "[ScopeSuccess]")
TEST_CASE("exit function lambda called on destruction", "[ScopeSuccess]")
{ {
CallMock cm; CallMock cm;
REQUIRE_CALL(cm, deleter()); REQUIRE_CALL(cm, deleter());
static_cast<void>(guard); static_cast<void>(guard);
} }


TEST_CASE("deleter not called and rethrow on copy exception", "[ScopeSuccess]")
TEST_CASE("exit function not called and rethrow on copy exception", "[ScopeSuccess]")
{ {
REQUIRE_THROWS([] { REQUIRE_THROWS([] {
const ThrowOnCopyMock noMove; const ThrowOnCopyMock noMove;
}()); }());
} }


TEST_CASE("deleter is not called if released", "[ScopeSuccess]")
TEST_CASE("exit function is not called if released", "[ScopeSuccess]")
{ {
REQUIRE_CALL(m, deleter()).TIMES(0); REQUIRE_CALL(m, deleter()).TIMES(0);
auto guard = sr::make_scope_success(deleter); auto guard = sr::make_scope_success(deleter);
static_cast<void>(guard); static_cast<void>(guard);
} }


TEST_CASE("deleter not called on exception", "[ScopeFail]")
TEST_CASE("exit function not called on exception", "[ScopeFail]")
{ {
try try
{ {
} }
} }


TEST_CASE("deleter called on pending exception", "[ScopeFail]")
TEST_CASE("exit function called on pending exception", "[ScopeFail]")
{ {
try try
{ {

Loading…
Cancel
Save