blob: 61d2889cf6c60b3d1aa4b7823879803ee613913f [file] [log] [blame]
onqtamb8220c52017-05-16 00:21:15 +03001#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
onqtambace8962019-01-28 15:19:38 +02002#include "doctest.h"
onqtamb8220c52017-05-16 00:21:15 +03003
onqtamf32b5502017-05-24 19:24:44 +03004int fact(int n) {
5 return n <= 1 ? n : fact(n - 1) * n;
6}
onqtamb8220c52017-05-16 00:21:15 +03007
8TEST_CASE("testing the factorial function") {
onqtamf32b5502017-05-24 19:24:44 +03009 CHECK(fact(0) == 1); // should fail
10 CHECK(fact(1) == 1);
11 CHECK(fact(2) == 2);
12 CHECK(fact(3) == 6);
13 CHECK(fact(10) == 3628800);
onqtamb8220c52017-05-16 00:21:15 +030014}