8475061136
thanks to Nico Werner, who did most of the porting work
14 lines
322 B
C++
14 lines
322 B
C++
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
|
|
#include "doctest.h"
|
|
|
|
int fact(int n) {
|
|
return n <= 1 ? n : fact(n - 1) * n;
|
|
}
|
|
|
|
TEST_CASE("testing the factorial function") {
|
|
CHECK(fact(0) == 1); // should fail
|
|
CHECK(fact(1) == 1);
|
|
CHECK(fact(2) == 2);
|
|
CHECK(fact(3) == 6);
|
|
CHECK(fact(10) == 3628800);
|
|
}
|