onqtam | b8220c5 | 2017-05-16 00:21:15 +0300 | [diff] [blame] | 1 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN |
onqtam | 9ae8e02 | 2017-05-24 19:30:28 +0300 | [diff] [blame] | 2 | #include "doctest.h" |
onqtam | b8220c5 | 2017-05-16 00:21:15 +0300 | [diff] [blame] | 3 | |
onqtam | f32b550 | 2017-05-24 19:24:44 +0300 | [diff] [blame] | 4 | int fact(int n) { |
| 5 | return n <= 1 ? n : fact(n - 1) * n; |
| 6 | } |
onqtam | b8220c5 | 2017-05-16 00:21:15 +0300 | [diff] [blame] | 7 | |
| 8 | TEST_CASE("testing the factorial function") { |
onqtam | f32b550 | 2017-05-24 19:24:44 +0300 | [diff] [blame] | 9 | 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); |
onqtam | b8220c5 | 2017-05-16 00:21:15 +0300 | [diff] [blame] | 14 | } |