Skip to content

Commit 4fe4cf4

Browse files
committed
tests: check properly if math::iterativeFactorial throws
1 parent 5be56ee commit 4fe4cf4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

math/iterative_factorial.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,14 @@ static void test() {
101101
std::cout << "Exception test \n"
102102
"Input: 21 \n"
103103
"Expected output: Exception thrown \n";
104+
105+
bool wasExceptionThrown = false;
104106
try {
105107
math::iterativeFactorial(21);
106-
} catch (const std::invalid_argument& e) {
107-
std::cout << "Exception thrown successfully \nContent: " << e.what()
108-
<< '\n';
108+
} catch (const std::invalid_argument&) {
109+
wasExceptionThrown = true;
109110
}
111+
assert(wasExceptionThrown);
110112

111113
std::cout << "All tests have passed successfully.\n";
112114
}

0 commit comments

Comments
 (0)