File: hello_world.cpp

package info (click to toggle)
doctest 1.2.9%2Brepack0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 4,264 kB
  • sloc: cpp: 9,836; python: 363; makefile: 14
file content (14 lines) | stat: -rw-r--r-- 322 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#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);
}