Skip to content

Commit

Permalink
tests: check properly if math::iterativeFactorial throws
Browse files Browse the repository at this point in the history
  • Loading branch information
vil02 committed Oct 2, 2023
1 parent 1bea453 commit e4ada59
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions math/iterative_factorial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,14 @@ static void test() {
std::cout << "Exception test \n"
"Input: 21 \n"
"Expected output: Exception thrown \n";

bool wasExceptionThrown = false;
try {
math::iterativeFactorial(21);
} catch (const std::invalid_argument& e) {
std::cout << "Exception thrown successfully \nContent: " << e.what()
<< '\n';
} catch (const std::invalid_argument&) {
wasExceptionThrown = true;
}
assert(wasExceptionThrown);

std::cout << "All tests have passed successfully.\n";
}
Expand Down

0 comments on commit e4ada59

Please sign in to comment.