blob: 5d34230059860d05ce7c9b074a975b2a0aa1e709 [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) {
onqtam7d5c0d52016-06-02 17:50:59 +03007 doctest::Context context; // initialize
8
9 // defaults
10 context.addFilter("test-case-exclude", "*math*"); // exclude test cases with "math" in the name
11 context.setOption("abort-after", 5); // stop test execution after 5 failed assertions
12 context.setOption("sort", "name"); // sort the test cases by their name
13
14 context.applyCommandLine(argc, argv);
onqtam4a655632016-05-26 14:20:52 +030015
16 // overrides
onqtam4a655632016-05-26 14:20:52 +030017 context.setOption("no-breaks", true); // don't break in the debugger when assertions fail
onqtam4a655632016-05-26 14:20:52 +030018
Martin Moene2e66b612016-05-30 17:18:44 +020019 int res = context.run(); // run queries, or run tests unless --no-run is specified
onqtam4a655632016-05-26 14:20:52 +030020
onqtam7ffa84e2016-05-30 18:42:20 +030021 if(context.shouldExit()) // important - query flags (and --exit) rely on the user doing this
onqtam4a655632016-05-26 14:20:52 +030022 return res; // propagate the result of the tests
23
Martin Moene2e66b612016-05-30 17:18:44 +020024 int client_stuff_return_code = program();
onqtam4a655632016-05-26 14:20:52 +030025 // your program - if the testing framework is integrated in your production code
26
27 return res + client_stuff_return_code;
28}
29
30#include <string>
31
32TEST_CASE("[string] testing std::string") {
33 std::string a("omg");
34 CHECK(a == "omg");
35}
36
37TEST_CASE("[math] basic stuff") {
38 CHECK(6 > 5);
39 CHECK(6 > 7);
40}
Martin Moene2e66b612016-05-30 17:18:44 +020041
42int program() {
onqtam4fe9a872016-05-30 18:51:00 +030043 printf("Program code.\n");
Martin Moene2e66b612016-05-30 17:18:44 +020044 return EXIT_SUCCESS;
45}