onqtam | 4a65563 | 2016-05-26 14:20:52 +0300 | [diff] [blame] | 1 | #define DOCTEST_CONFIG_IMPLEMENT |
| 2 | #include "doctest.h" |
| 3 | |
| 4 | int main(int argc, char** argv) { |
onqtam | cfce188 | 2017-04-02 17:31:55 +0300 | [diff] [blame] | 5 | doctest::Context context; |
| 6 | |
| 7 | // !!! THIS IS JUST AN EXAMPLE SHOWING HOW DEFAULTS/OVERRIDES ARE SET !!! |
onqtam | 7d5c0d5 | 2016-06-02 17:50:59 +0300 | [diff] [blame] | 8 | |
| 9 | // defaults |
| 10 | context.addFilter("test-case-exclude", "*math*"); // exclude test cases with "math" in their name |
| 11 | context.setOption("no-breaks", true); // don't break in the debugger when assertions fail |
| 12 | |
| 13 | context.applyCommandLine(argc, argv); |
onqtam | 4a65563 | 2016-05-26 14:20:52 +0300 | [diff] [blame] | 14 | |
| 15 | // overrides |
onqtam | cfce188 | 2017-04-02 17:31:55 +0300 | [diff] [blame] | 16 | context.setOption("abort-after", 5); // stop test execution after 5 failed assertions |
| 17 | context.setOption("order_by", "name"); // sort the test cases by their name |
onqtam | 4a65563 | 2016-05-26 14:20:52 +0300 | [diff] [blame] | 18 | |
| 19 | int res = context.run(); // run |
| 20 | |
onqtam | f720d43 | 2016-05-31 17:51:10 +0300 | [diff] [blame] | 21 | if(context.shouldExit()) // important - query flags (and --exit) rely on the user doing this |
onqtam | 4a65563 | 2016-05-26 14:20:52 +0300 | [diff] [blame] | 22 | return res; // propagate the result of the tests |
| 23 | |
| 24 | int client_stuff_return_code = 0; |
| 25 | // your program - if the testing framework is integrated in your production code |
| 26 | |
onqtam | 96bdf71 | 2016-09-13 16:45:52 +0300 | [diff] [blame] | 27 | return res + client_stuff_return_code; // the result from doctest is propagated here as well |
onqtam | 4a65563 | 2016-05-26 14:20:52 +0300 | [diff] [blame] | 28 | } |