Created
February 20, 2022 21:39
-
-
Save xealits/f07d486b889205cf07cb0c194b68a944 to your computer and use it in GitHub Desktop.
C/C++ doctest with separate implementation file and source with tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL | |
#include "doctest.h" | |
//int factorial(int number) { return number <= 1 ? number : factorial(number - 1) * number; } | |
int factorial(int number) { return number <= 1 ? 1 : factorial(number - 1) * number; } | |
TEST_CASE("testing the factorial function") { | |
CHECK(factorial(0) == 1); | |
CHECK(factorial(1) == 1); | |
CHECK(factorial(2) == 2); | |
CHECK(factorial(3) == 6); | |
CHECK(factorial(10) == 3628800); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN | |
#include "doctest.h" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment