olm/lib/doctest/scripts/hello_world.cpp
Hubert Chathi 8475061136 switch to doctest for unit testing
thanks to Nico Werner, who did most of the porting work
2021-12-22 13:45:33 -05:00

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);
}