18 lines
436 B
C++
Executable File
18 lines
436 B
C++
Executable File
#include "library.h"
|
|
#include <iostream>
|
|
#define CATCH_CONFIG_MAIN
|
|
|
|
unsigned int Factorial( unsigned int number ) {
|
|
return number <= 1 ? number : Factorial(number-1)*number;
|
|
}
|
|
|
|
#ifdef TESTS_BUILD
|
|
#include <catch2/catch.hpp>
|
|
|
|
TEST_CASE( "Factorials are computed", "[factorial]" ) {
|
|
REQUIRE( Factorial(1) == 1 );
|
|
REQUIRE( Factorial(2) == 2 );
|
|
REQUIRE( Factorial(3) == 6 );
|
|
REQUIRE( Factorial(10) == 3628800 );
|
|
}
|
|
#endif |