Add partial implementation of CATCH_CONFIG_DISABLE

* Assertions are defined into (void)(0) no-op
* SECTIONs are defined away (leaving {} as scope)
* TEST_CASEs and TEST_CASE_METHODs are not registered.
* REGISTER_TEST_CASE is defined into (void)(0) no-op
* METHOD_AS_TEST_CASE is defined away
This commit is contained in:
Martin Hořeňovský
2017-08-27 17:03:32 +02:00
parent 2a13593885
commit 053c29a2b8
5 changed files with 165 additions and 0 deletions

View File

@@ -73,6 +73,7 @@ This can be useful on certain platforms that do not provide the standard iostrea
CATCH_CONFIG_POSIX_SIGNALS // Enable handling POSIX signals
CATCH_CONFIG_WINDOWS_CRTDBG // Enable leak checking using Windows's CRT Debug Heap
CATCH_CONFIG_DISABLE_STRINGIFICATION // Disable stringifying the original expression
CATCH_CONFIG_DISABLE // Disables assertions and test case registration
Currently Catch enables `CATCH_CONFIG_WINDOWS_SEH` only when compiled with MSVC, because some versions of MinGW do not have the necessary Win32 API support.
@@ -97,6 +98,13 @@ _Note: If you define `CATCH_CONFIG_DISABLE_MATCHERS` in the same file as Catch's
## `CATCH_CONFIG_DISABLE_STRINGIFICATION`
This toggle enables a workaround for VS 2017 bug. For details see [known limitations](limitations.md#Visual Studio 2017 -- raw string literal in assert fails to compile)
## `CATCH_CONFIG_DISABLE`
This toggle removes most of Catch from given file. This means that `TEST_CASE`s are not registered and assertions are turned into no-ops. Useful for keeping tests within implementation files (ie for functions with internal linkage), instead of in external files.
This feature is considered experimental and might change at any point.
_Inspired by Doctest's `DOCTEST_CONFIG_DISABLE`_
# Windows header clutter
On Windows Catch includes `windows.h`. To minimize global namespace clutter in the implementation file, it defines `NOMINMAX` and `WIN32_LEAN_AND_MEAN` before including it. You can control this behaviour via two macros: