Skip to content

Commit

Permalink
Added TEST ExceptUnwindExecInFunc
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio3rs committed Jul 5, 2024
1 parent df49b8d commit 1bb5f89
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/test_ExceptUnwindExec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,26 @@ TEST(ExceptUnwindTest, ExceptUnwindExec) {
EXPECT_EQ(calledTimes, 0);
}

[[noreturn]] static void someErrorFun(int &counter) {
ExceptUnwindExec exec([&counter]() -> void {
++counter;
std::cerr << "someErrorFun" << std::endl;
});

throw std::runtime_error("Test");
}

TEST(ExceptUnwindTest, ExceptUnwindExecInFunc) {
int counter = 0;
try {
someErrorFun(counter);
} catch (const std::exception &e) {
std::cerr << __FILE__ << " " << e.what() << std::endl;
}

EXPECT_EQ(counter, 1);
}

TEST(ExceptUnwindTest, ExceptUnwindExecThrow) {
int calledTimes = 0;
auto callbackfn = [&]() -> void { ++calledTimes; };
Expand Down

0 comments on commit 1bb5f89

Please sign in to comment.