Solved: 07 - Loops
Added a contract precondition to factorial
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user