Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-06-29 07:06:58

0001 #define CATCH_CONFIG_MAIN  // This tells Catch to provide a main() - only do this in one cpp file
0002 #include "catch2/catch.hpp"
0003 
0004 unsigned int Factorial( unsigned int number ) {
0005     return number <= 1 ? number : Factorial(number-1)*number;
0006 }
0007 
0008 TEST_CASE( "Factorials are computed", "[factorial]" ) {
0009     REQUIRE( Factorial(1) == 1 );
0010     REQUIRE( Factorial(2) == 2 );
0011     REQUIRE( Factorial(3) == 6 );
0012     REQUIRE( Factorial(10) == 3628800 );
0013 }