blob: 1ec07236e8faea9b48ccfac3acd4e4c7c2388558 [file] [log] [blame]
onqtam4a655632016-05-26 14:20:52 +03001#define DOCTEST_CONFIG_DISABLE
2
3#define DOCTEST_CONFIG_IMPLEMENT
4#include "doctest.h"
5
onqtam05bcc372017-03-17 02:10:38 +02006// set an exception translator for double - as a reference
7REGISTER_EXCEPTION_TRANSLATOR(double& e) {
8 return doctest::String("double: ") + doctest::toString(e);
9}
10
onqtam246e8172017-03-17 02:48:12 +020011static doctest::String intTranslator(int ex) { return doctest::String("int: ") + doctest::toString(ex); }
12
onqtam4a655632016-05-26 14:20:52 +030013int main(int argc, char** argv) {
onqtam05bcc372017-03-17 02:10:38 +020014 // set an exception translator for int
onqtam246e8172017-03-17 02:48:12 +020015 doctest::registerExceptionTranslator(intTranslator);
onqtam05bcc372017-03-17 02:10:38 +020016
onqtamcfce1882017-04-02 17:31:55 +030017 doctest::Context context;
18
19 // !!! THIS IS JUST AN EXAMPLE SHOWING HOW DEFAULTS/OVERRIDES ARE SET !!!
onqtam7d5c0d52016-06-02 17:50:59 +030020
21 // defaults
22 context.addFilter("test-case-exclude", "*math*"); // exclude test cases with "math" in the name
23 context.setOption("no-breaks", true); // don't break in the debugger when assertions fail
24
25 context.applyCommandLine(argc, argv);
onqtam4a655632016-05-26 14:20:52 +030026
27 // overrides
onqtamcfce1882017-04-02 17:31:55 +030028 context.setOption("abort-after", 5); // stop test execution after 5 failed assertions
29 context.setOption("order_by", "name"); // sort the test cases by their name
onqtam4a655632016-05-26 14:20:52 +030030
31 int res = context.run(); // run
32
onqtamf720d432016-05-31 17:51:10 +030033 if(context.shouldExit()) // important - query flags (and --exit) rely on the user doing this
onqtam4a655632016-05-26 14:20:52 +030034 return res; // propagate the result of the tests
35
36 int client_stuff_return_code = 0;
37 // your program - if the testing framework is integrated in your production code
38
onqtam96bdf712016-09-13 16:45:52 +030039 return res + client_stuff_return_code; // the result from doctest is propagated here as well
onqtam4a655632016-05-26 14:20:52 +030040}