onqtam | 862a3bb | 2016-04-27 18:19:00 +0300 | [diff] [blame] | 1 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
|
hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 2 | #include "doctest.h"
|
| 3 |
|
onqtam | e4c75fc | 2016-05-21 01:24:48 +0300 | [diff] [blame^] | 4 | static int factorial(int number) { return number <= 1 ? number : factorial(number - 1) * number; }
|
hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 5 |
|
onqtam | e4c75fc | 2016-05-21 01:24:48 +0300 | [diff] [blame^] | 6 | TEST_CASE("testing the factorial function") {
|
| 7 | CHECK(factorial(0) == 1);
|
| 8 | CHECK(factorial(1) == 1);
|
| 9 | CHECK(factorial(2) == 2);
|
| 10 | CHECK(factorial(3) == 6);
|
| 11 | CHECK(factorial(10) == 3628800);
|
hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 12 | }
|