onqtam | 8126b56 | 2016-05-27 17:01:15 +0300 | [diff] [blame^] | 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <title>configuration</title> |
| 4 | <xmp theme="united" style="display:none;"> |
| 5 | |
| 6 | ## Configuration |
| 7 | |
| 8 | **doctest** is designed to "just work" as much as possible. It exposes a small set of defines for configuring how it is built. |
| 9 | |
| 10 | For most people the only configuration needed is telling **doctest** which source file should host all the implementation code: |
| 11 | |
| 12 | - **```DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN```** |
| 13 | |
| 14 | ``` |
| 15 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN |
| 16 | #include "doctest.h" |
| 17 | ``` |
| 18 | |
| 19 | This should be done in only one source file! Otherwise there will be linker errors and slower build times. |
| 20 | |
| 21 | - **```DOCTEST_CONFIG_IMPLEMENT```** - if the client wants to [**supply the ```main()``` function**](main.html) (either to set an option with some value from the code or to integrate the framework into his existing project codebase) this define should be used. |
| 22 | |
| 23 | - **```DOCTEST_CONFIG_DISABLE```** - the next most important configuration option - when defined globally in the whole project before the inclusion of the framework header - everything testing - related is removed from the binary - including most of the framework implementation and every test case written anywhere! This is one of the most unique features of **doctest**. |
| 24 | |
| 25 | - **```DOCTEST_CONFIG_NO_SHORT_MACRO_NAMES```** - this will remove all macros from **doctest** that don't have the **```DOCTEST_```** prefix - like **```CHECK```**, **```TEST_CASE```** and **```SUBCASE```**. Then only the full macro names will be available - **```DOCTEST_CHECK```**, **```DOCTEST_TEST_CASE```** and **```DOCTEST_SUBCASE```**. The user is free to make his own short versions of these macros - [**example**](../../examples/alternative_macros/) |
| 26 | |
| 27 | - **```DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS```** - this will disable the short versions of the [**command line**](commandline.html) options and only the versions with ```-dt-``` prefix will be parsed by **doctest** - this is possible for easy interoperability with client command line option handling when the testing framework is integrated within a client codebase - so there are no clashes and so that the user can exclude everything starting with ```-dt-``` from their option parsing. This configuration option is relevant only for the source file where the library is implemented |
| 28 | |
| 29 | - **```DOCTEST_CONFIG_COLORS_NONE```** - this will remove support for colors in the console output of the framework. This configuration option is relevant only for the source file where the library is implemented |
| 30 | |
| 31 | - **```DOCTEST_CONFIG_COLORS_WINDOWS```** - this will force the support for colors in the console output to use the Windows APIs and headers. This configuration option is relevant only for the source file where the library is implemented |
| 32 | |
| 33 | - **```DOCTEST_CONFIG_COLORS_ANSI```** - this will force the support for colors in the console output to use ANSI escape codes. This configuration option is relevant only for the source file where the library is implemented |
| 34 | |
| 35 | - **```DOCTEST_CONFIG_USE_IOSFWD```** - the library by default provides a forward declaration of ```std::ostream``` in order to support the ```operator<<``` [**stringification**](stringification.html) mechanism. This is forbidden by the standard (even though it works everywhere on all tested compilers). However if the user wishes to be 100% standards compliant - then this configuration option can be used to force the inclusion of ```<iosfwd>```. It should be defined everywhere before the framework header is included. |
| 36 | |
| 37 | - **```DOCTEST_CONFIG_WITH_LONG_LONG```** - by default the library includes support for stringifying ```long long``` only if the value of ```__cplusplus``` is at least ```201103L``` (C++11) or if the compiler is MSVC 2003 or newer. Many compilers that don't fully support C++11 have it as an extension but it errors for GCC/Clang when the ```-std=c++98``` option is used and this cannot be detected with the preprocessor in any way. Use this configuration option if your compiler supports ```long long``` but doesn't yet support the full C++11 standard. It should be defined everywhere before the framework header is included. |
| 38 | |
| 39 | --------------- |
| 40 | |
| 41 | [Home](readme.html#reference) |
| 42 | |
| 43 | |
| 44 | </xmp> |
| 45 | <script src="strapdown.js/strapdown.js"></script> |
| 46 | </html> |