Solved: 07 - Loops

Added a contract precondition to factorial
This commit is contained in:
David Gil de Gómez Pérez
2026-08-12 14:47:10 +03:00
parent ba6d3ea5d4
commit 88cc7728a6
3 changed files with 36 additions and 14 deletions
@@ -9,6 +9,12 @@ TEST(Loops, SumRange) {
TEST(Loops, Factorial) {
EXPECT_EQ(control_flow::factorial(0), 1);
EXPECT_EQ(control_flow::factorial(5), 120);
// Breach of contract
EXPECT_DEATH(
{
(void)control_flow::factorial(-1);
},
"contract violation");
}
TEST(Loops, CountOccurrences) {