blob: 8dd9e3656b98ef7dd6f85d2abaf32681ec82662e [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) {
onqtamcfce1882017-04-02 17:31:55 +03007 doctest::Context context;
8
9 // !!! THIS IS JUST AN EXAMPLE SHOWING HOW DEFAULTS/OVERRIDES ARE SET !!!
onqtam7d5c0d52016-06-02 17:50:59 +030010
11 // defaults
12 context.addFilter("test-case-exclude", "*math*"); // exclude test cases with "math" in the name
onqtam27079bc2017-04-16 23:21:13 +030013 //context.setOption("abort-after", 5); // stop test execution after 5 failed assertions
14 context.setOption("order-by", "file"); // sort the test cases by file and line
onqtam7d5c0d52016-06-02 17:50:59 +030015
16 context.applyCommandLine(argc, argv);
onqtam4a655632016-05-26 14:20:52 +030017
18 // overrides
onqtam4a655632016-05-26 14:20:52 +030019 context.setOption("no-breaks", true); // don't break in the debugger when assertions fail
onqtam4a655632016-05-26 14:20:52 +030020
Martin Moene2e66b612016-05-30 17:18:44 +020021 int res = context.run(); // run queries, or run tests unless --no-run is specified
onqtam4a655632016-05-26 14:20:52 +030022
onqtam7ffa84e2016-05-30 18:42:20 +030023 if(context.shouldExit()) // important - query flags (and --exit) rely on the user doing this
onqtam4a655632016-05-26 14:20:52 +030024 return res; // propagate the result of the tests
25
Martin Moene2e66b612016-05-30 17:18:44 +020026 int client_stuff_return_code = program();
onqtam4a655632016-05-26 14:20:52 +030027 // your program - if the testing framework is integrated in your production code
28
onqtam96bdf712016-09-13 16:45:52 +030029 return res + client_stuff_return_code; // the result from doctest is propagated here as well
onqtam4a655632016-05-26 14:20:52 +030030}
31
32#include <string>
33
34TEST_CASE("[string] testing std::string") {
35 std::string a("omg");
36 CHECK(a == "omg");
37}
38
39TEST_CASE("[math] basic stuff") {
40 CHECK(6 > 5);
41 CHECK(6 > 7);
42}
Martin Moene2e66b612016-05-30 17:18:44 +020043
44int program() {
onqtam4fe9a872016-05-30 18:51:00 +030045 printf("Program code.\n");
Martin Moene2e66b612016-05-30 17:18:44 +020046 return EXIT_SUCCESS;
47}