Configuration

doctest is designed to "just work" as much as possible. It also allows configuring how it is built with a set of identifiers.

For most people the only configuration needed is telling doctest which source file should host all the implementation code:

DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN

#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "doctest.h"

This should be done in only one source file! Otherwise there will be linker errors and slower build times.

DOCTEST_CONFIG_IMPLEMENT

if the client wants to supply the main() function (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.

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.

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

DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS

this will disable the short versions of the command line 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

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

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

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

DOCTEST_CONFIG_USE_IOSFWD

the library by default provides a forward declaration of std::ostream in order to support the operator<< stringification 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.

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.

DOCTEST_CONFIG_WITH_NULLPTR DOCTEST_CONFIG_WITH_LONG_LONG DOCTEST_CONFIG_WITH_STATIC_ASSERT

DOCTEST_CONFIG_NO_NULLPTR DOCTEST_CONFIG_NO_LONG_LONG DOCTEST_CONFIG_NO_STATIC_ASSERT

DOCTEST_CONFIG_ASSERTION_PARAMETERS_BY_VALUE DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING DOCTEST_CONFIG_NO_COMPARISON_WARNING_SUPPRESSION

DOCTEST_CONFIG_SUPER_FAST_ASSERTS


Home