diff options
| author | Martin Hořeňovský | 2017-07-28 21:34:34 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2017-07-28 21:34:34 +0200 |
| commit | 0ca4cfb7432d37dbca4164c274a6b4f6e37d2dd4 (patch) | |
| tree | 80fbcb75f48ca7ddf6695f2ba8e2a454187111d0 /include/internal | |
| parent | 35c1301bd58222eace4afe61b666b580a0814d4e (diff) | |
| download | catch3-0ca4cfb7432d37dbca4164c274a6b4f6e37d2dd4.tar.gz | |
Introduce compile time toggle to remove Matchers from TU
The toggle is `CATCH_CONFIG_DISABLE_MATCHERS` and the only use is
to speed up compilation of small TUs. For large ones it is likely
insignificant, because the speed up is constant relative to
number of tests/assertions in TU.
Diffstat (limited to 'include/internal')
| -rw-r--r-- | include/internal/catch_capture.hpp | 7 | ||||
| -rw-r--r-- | include/internal/catch_matchers.cpp | 4 | ||||
| -rw-r--r-- | include/internal/catch_matchers.hpp | 4 | ||||
| -rw-r--r-- | include/internal/catch_matchers_string.cpp | 4 | ||||
| -rw-r--r-- | include/internal/catch_matchers_string.h | 4 | ||||
| -rw-r--r-- | include/internal/catch_matchers_vector.h | 5 | ||||
| -rw-r--r-- | include/internal/catch_objc.hpp | 4 | ||||
| -rw-r--r-- | include/internal/catch_result_builder.cpp | 4 | ||||
| -rw-r--r-- | include/internal/catch_result_builder.h | 2 |
9 files changed, 33 insertions, 5 deletions
diff --git a/include/internal/catch_capture.hpp b/include/internal/catch_capture.hpp index 1c862505..fa6952e4 100644 --- a/include/internal/catch_capture.hpp +++ b/include/internal/catch_capture.hpp @@ -42,7 +42,7 @@ INTERNAL_CATCH_REACT( __catchResult ) \ } while( Catch::isTrue( false && static_cast<bool>( !!(expr) ) ) ) // expr here is never evaluated at runtime but it forces the compiler to give it a look // The double negation silences MSVC's C4800 warning, the static_cast forces short-circuit evaluation if the type has overloaded &&. - +#if defined(CATCH_CONFIG_DISABLE_MATCHERS) #define INTERNAL_CHECK_THAT_NO_TRY( macroName, matcher, resultDisposition, arg ) \ do { \ Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #arg ", " #matcher, resultDisposition ); \ @@ -51,7 +51,7 @@ __catchResult.unsetExceptionGuard(); \ INTERNAL_CATCH_REACT( __catchResult ) \ } while( Catch::alwaysFalse() ) - +#endif // CATCH_CONFIG_DISABLE_MATCHERS #else /////////////////////////////////////////////////////////////////////////////// // In the event of a failure works out if the debugger needs to be invoked @@ -155,6 +155,7 @@ #define INTERNAL_CATCH_INFO( macroName, log ) \ Catch::ScopedMessage INTERNAL_CATCH_UNIQUE_NAME( scopedMessage ) = Catch::MessageBuilder( macroName, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log; +#if defined(CATCH_CONFIG_DISABLE_MATCHERS) /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CHECK_THAT( macroName, matcher, resultDisposition, arg ) \ do { \ @@ -204,7 +205,7 @@ __catchResult.captureResult( Catch::ResultWas::Ok ); \ INTERNAL_CATCH_REACT( __catchResult ) \ } while( Catch::alwaysFalse() ) - +#endif // CATCH_CONFIG_DISABLE_MATCHERS #endif // TWOBLUECUBES_CATCH_CAPTURE_HPP_INCLUDED diff --git a/include/internal/catch_matchers.cpp b/include/internal/catch_matchers.cpp index 38ae8c77..a2620bc5 100644 --- a/include/internal/catch_matchers.cpp +++ b/include/internal/catch_matchers.cpp @@ -5,6 +5,8 @@ * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ +#if defined(CATCH_CONFIG_DISABLE_MATCHERS) + #include "catch_matchers.hpp" namespace Catch { @@ -24,3 +26,5 @@ using namespace Matchers; using Matchers::Impl::MatcherBase; } // namespace Catch + +#endif // CATCH_CONFIG_DISABLE_MATCHERS
\ No newline at end of file diff --git a/include/internal/catch_matchers.hpp b/include/internal/catch_matchers.hpp index 4f41cb01..37787a9c 100644 --- a/include/internal/catch_matchers.hpp +++ b/include/internal/catch_matchers.hpp @@ -8,6 +8,8 @@ #ifndef TWOBLUECUBES_CATCH_MATCHERS_HPP_INCLUDED #define TWOBLUECUBES_CATCH_MATCHERS_HPP_INCLUDED +#if defined(CATCH_CONFIG_DISABLE_MATCHERS) + #include "catch_common.h" #include <vector> @@ -179,4 +181,6 @@ using Matchers::Impl::MatcherBase; } // namespace Catch +#endif // CATCH_CONFIG_DISABLE_MATCHERS + #endif // TWOBLUECUBES_CATCH_MATCHERS_HPP_INCLUDED diff --git a/include/internal/catch_matchers_string.cpp b/include/internal/catch_matchers_string.cpp index 2f8ffdb8..54f44d6d 100644 --- a/include/internal/catch_matchers_string.cpp +++ b/include/internal/catch_matchers_string.cpp @@ -6,6 +6,8 @@ * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ +#if defined(CATCH_CONFIG_DISABLE_MATCHERS) + #include "catch_matchers_string.h" #include "catch_string_manip.h" @@ -92,3 +94,5 @@ namespace Matchers { } // namespace Matchers } // namespace Catch + +#endif // CATCH_CONFIG_DISABLE_MATCHERS diff --git a/include/internal/catch_matchers_string.h b/include/internal/catch_matchers_string.h index eca35789..ab3f1c44 100644 --- a/include/internal/catch_matchers_string.h +++ b/include/internal/catch_matchers_string.h @@ -8,6 +8,8 @@ #ifndef TWOBLUECUBES_CATCH_MATCHERS_STRING_H_INCLUDED #define TWOBLUECUBES_CATCH_MATCHERS_STRING_H_INCLUDED +#if defined(CATCH_CONFIG_DISABLE_MATCHERS) + #include "catch_matchers.hpp" #include <string> @@ -66,4 +68,6 @@ namespace Matchers { } // namespace Matchers } // namespace Catch +#endif // CATCH_CONFIG_DISABLE_MATCHERS + #endif // TWOBLUECUBES_CATCH_MATCHERS_STRING_H_INCLUDED diff --git a/include/internal/catch_matchers_vector.h b/include/internal/catch_matchers_vector.h index 4bf39d70..de1c52b2 100644 --- a/include/internal/catch_matchers_vector.h +++ b/include/internal/catch_matchers_vector.h @@ -8,6 +8,9 @@ #ifndef TWOBLUECUBES_CATCH_MATCHERS_VECTOR_H_INCLUDED #define TWOBLUECUBES_CATCH_MATCHERS_VECTOR_H_INCLUDED +#if defined(CATCH_CONFIG_DISABLE_MATCHERS) + + #include "catch_matchers.hpp" namespace Catch { @@ -112,4 +115,6 @@ namespace Matchers { } // namespace Matchers } // namespace Catch +#endif // CATCH_CONFIG_DISABLE_MATCHERS + #endif // TWOBLUECUBES_CATCH_MATCHERS_VECTOR_H_INCLUDED diff --git a/include/internal/catch_objc.hpp b/include/internal/catch_objc.hpp index 350dc72c..2a8ec2f9 100644 --- a/include/internal/catch_objc.hpp +++ b/include/internal/catch_objc.hpp @@ -101,6 +101,8 @@ namespace Catch { return noTestMethods; } +#if defined(CATCH_CONFIG_DISABLE_MATCHERS) + namespace Matchers { namespace Impl { namespace NSStringMatchers { @@ -189,6 +191,8 @@ namespace Catch { using namespace Matchers; +#endif // CATCH_CONFIG_DISABLE_MATCHERS + } // namespace Catch /////////////////////////////////////////////////////////////////////////////// diff --git a/include/internal/catch_result_builder.cpp b/include/internal/catch_result_builder.cpp index a1fed54e..cf0b1b16 100644 --- a/include/internal/catch_result_builder.cpp +++ b/include/internal/catch_result_builder.cpp @@ -72,7 +72,7 @@ namespace Catch { setResultType( resultType ); captureExpression(); } - +#if defined(CATCH_CONFIG_DISABLE_MATCHERS) void ResultBuilder::captureExpectedException( std::string const& expectedMessage ) { if( expectedMessage.empty() ) captureExpectedException( Matchers::Impl::MatchAllOf<std::string>() ); @@ -96,7 +96,7 @@ namespace Catch { AssertionResult result( m_assertionInfo, data ); handleResult( result ); } - +#endif // CATCH_CONFIG_DISABLE_MATCHERS void ResultBuilder::captureExpression() { AssertionResult result = build(); handleResult( result ); diff --git a/include/internal/catch_result_builder.h b/include/internal/catch_result_builder.h index 45bc8920..2b5dd145 100644 --- a/include/internal/catch_result_builder.h +++ b/include/internal/catch_result_builder.h @@ -58,8 +58,10 @@ namespace Catch { void useActiveException( ResultDisposition::Flags resultDisposition = ResultDisposition::Normal ); void captureResult( ResultWas::OfType resultType ); void captureExpression(); +#if defined(CATCH_CONFIG_DISABLE_MATCHERS) void captureExpectedException( std::string const& expectedMessage ); void captureExpectedException( Matchers::Impl::MatcherBase<std::string> const& matcher ); +#endif // CATCH_CONFIG_DISABLE_MATCHERS void handleResult( AssertionResult const& result ); void react(); bool shouldDebugBreak() const; |