blob: bd94da746c64678ed4edd59aeb0507774d0398a3 [file] [log] [blame]
onqtamb43aa042017-03-13 19:04:08 +02001#define DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL
2#include "doctest.h"
3
4#include <cstdio>
onqtam4a655632016-05-26 14:20:52 +03005
6TEST_CASE("executable") {
7 printf("I am a test from the executable!\n");
onqtam05bcc372017-03-17 02:10:38 +02008 throw 'a';
onqtam4a655632016-05-26 14:20:52 +03009}
10
onqtamb43aa042017-03-13 19:04:08 +020011#ifdef _WIN32
12#define WIN32_LEAN_AND_MEAN
13#include <windows.h>
14#ifdef _MSC_VER
15#define LoadDynamicLib(lib) LoadLibrary(lib ".dll")
16#else // _MSC_VER
17#define LoadDynamicLib(lib) LoadLibrary("lib" lib ".dll")
18#endif // _MSC_VER
onqtamb43aa042017-03-13 19:04:08 +020019#else // _WIN32
20#include <dlfcn.h>
21#ifdef __APPLE__
22#define LoadDynamicLib(lib) dlopen("lib" lib ".dylib", RTLD_NOW)
23#else // __APPLE__
24#define LoadDynamicLib(lib) dlopen("lib" lib ".so", RTLD_NOW)
25#endif // __APPLE__
onqtamb43aa042017-03-13 19:04:08 +020026#endif // _WIN32
27
onqtam05bcc372017-03-17 02:10:38 +020028// set an exception translator for double
29REGISTER_EXCEPTION_TRANSLATOR(double& e) {
30 return doctest::String("double: ") + doctest::toString(e);
31}
32
onqtam4a655632016-05-26 14:20:52 +030033int main(int argc, char** argv) {
onqtamb43aa042017-03-13 19:04:08 +020034 // force the use of a symbol from the dll so tests from it get registered
35 DOCTEST_SYMBOL_IMPORT void from_dll(); from_dll();
36
37 LoadDynamicLib("plugin"); // load the plugin so tests from it get registered
38
onqtam4a655632016-05-26 14:20:52 +030039 doctest::Context context(argc, argv);
40 int res = context.run();
41
onqtam96bdf712016-09-13 16:45:52 +030042 if(context.shouldExit()) // important - query flags (and --exit) rely on the user doing this
43 return res; // propagate the result of the tests
44
45 return res; // the result from doctest is propagated here as well
onqtam4a655632016-05-26 14:20:52 +030046}