Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
010-TestCase.cpp File Reference
#include <catch2/catch.hpp>
Include dependency graph for 010-TestCase.cpp:

Go to the source code of this file.

Macros

#define CATCH_CONFIG_MAIN
 

Functions

int Factorial (int number)
 
 TEST_CASE ("Factorial of 0 is 1 (fail)", "[single-file]")
 
 TEST_CASE ("Factorials of 1 and higher are computed (pass)", "[single-file]")
 

Macro Definition Documentation

◆ CATCH_CONFIG_MAIN

#define CATCH_CONFIG_MAIN

Definition at line 4 of file 010-TestCase.cpp.

Function Documentation

◆ Factorial()

int Factorial ( int number)

Definition at line 8 of file 010-TestCase.cpp.

8 {
9 return number <= 1 ? number : Factorial( number - 1 ) * number; // fail
10// return number <= 1 ? 1 : Factorial( number - 1 ) * number; // pass
11}
int Factorial(int number)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TEST_CASE() [1/2]

TEST_CASE ( "Factorial of 0 is 1 (fail)" ,
"" [single-file] )

Definition at line 13 of file 010-TestCase.cpp.

13 {
14 REQUIRE( Factorial(0) == 1 );
15}
#define REQUIRE(...)
Definition catch.hpp:185
Here is the call graph for this function:

◆ TEST_CASE() [2/2]

TEST_CASE ( "Factorials of 1 and higher are computed (pass)" ,
"" [single-file] )

Definition at line 17 of file 010-TestCase.cpp.

17 {
18 REQUIRE( Factorial(1) == 1 );
19 REQUIRE( Factorial(2) == 2 );
20 REQUIRE( Factorial(3) == 6 );
21 REQUIRE( Factorial(10) == 3628800 );
22}
Here is the call graph for this function: