浏览代码

Test naming updated (fixes #60).

main
offa 7 年前
父节点
当前提交
a75bc2df64
共有 3 个文件被更改,包括 16 次插入16 次删除
  1. +4
    -4
      test/ScopeExitTest.cpp
  2. +6
    -6
      test/ScopeFailTest.cpp
  3. +6
    -6
      test/ScopeSuccessTest.cpp

+ 4
- 4
test/ScopeExitTest.cpp 查看文件

} }




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 查看文件

} }




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 查看文件

} }




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
{ {

正在加载...
取消
保存