blob: 1f02cec832ecfe41671366adbabc45d6ffa11688 [file] [log] [blame]
onqtam4a655632016-05-26 14:20:52 +03001#define DOCTEST_CONFIG_IMPLEMENT
2#include "doctest.h"
3
Martin Moene2e66b612016-05-30 17:18:44 +02004int program();
5
onqtam4a655632016-05-26 14:20:52 +03006int main(int argc, char** argv) {
7 doctest::Context context(argc, argv); // initialize
8
9 // overrides
10 context.addFilter("test-case-exclude", "*math*"); // exclude test cases with "math" in the name
11 context.setOption("no-breaks", true); // don't break in the debugger when assertions fail
12 context.setOption("abort-after", 5); // stop test execution after 5 failed assertions
13 context.setOption("sort", "name"); // sort the test cases by their name
14
Martin Moene2e66b612016-05-30 17:18:44 +020015 int res = context.run(); // run queries, or run tests unless --no-run is specified
onqtam4a655632016-05-26 14:20:52 +030016
onqtam7ffa84e2016-05-30 18:42:20 +030017 if(context.shouldExit()) // important - query flags (and --exit) rely on the user doing this
onqtam4a655632016-05-26 14:20:52 +030018 return res; // propagate the result of the tests
19
Martin Moene2e66b612016-05-30 17:18:44 +020020 int client_stuff_return_code = program();
onqtam4a655632016-05-26 14:20:52 +030021 // your program - if the testing framework is integrated in your production code
22
23 return res + client_stuff_return_code;
24}
25
26#include <string>
27
28TEST_CASE("[string] testing std::string") {
29 std::string a("omg");
30 CHECK(a == "omg");
31}
32
33TEST_CASE("[math] basic stuff") {
34 CHECK(6 > 5);
35 CHECK(6 > 7);
36}
Martin Moene2e66b612016-05-30 17:18:44 +020037
38int program() {
onqtam4fe9a872016-05-30 18:51:00 +030039 printf("Program code.\n");
Martin Moene2e66b612016-05-30 17:18:44 +020040 return EXIT_SUCCESS;
41}