MCPcopy Create free account
hub / github.com/catchorg/Catch2 / Factorial

Function Factorial

examples/020-TestCase-2.cpp:15–18  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13#include <catch2/catch_test_macros.hpp>
14
15static int Factorial( int number ) {
16 return number <= 1 ? number : Factorial( number - 1 ) * number; // fail
17// return number <= 1 ? 1 : Factorial( number - 1 ) * number; // pass
18}
19
20TEST_CASE( "2: Factorial of 0 is 1 (fail)", "[multi-file:2]" ) {
21 REQUIRE( Factorial(0) == 1 );

Callers 1

020-TestCase-2.cppFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected