diff options
| author | Phil Nash | 2013-12-12 23:02:31 +0000 |
|---|---|---|
| committer | Phil Nash | 2013-12-12 23:02:31 +0000 |
| commit | 274ed3ea7623978d3d49cd4f211dc761e1a44317 (patch) | |
| tree | 3942ebb7f6320d99d3708d637625a9597eed09d7 /include/internal | |
| parent | a6d74bd55aeff9a2506906e451305364f7a02d34 (diff) | |
| download | catch3-274ed3ea7623978d3d49cd4f211dc761e1a44317.tar.gz | |
Allow FAIL() to be empty
Diffstat (limited to 'include/internal')
| -rw-r--r-- | include/internal/catch_capture.hpp | 18 | ||||
| -rw-r--r-- | include/internal/catch_common.h | 14 |
2 files changed, 27 insertions, 5 deletions
diff --git a/include/internal/catch_capture.hpp b/include/internal/catch_capture.hpp index a352a622..3b2cfdf7 100644 --- a/include/internal/catch_capture.hpp +++ b/include/internal/catch_capture.hpp @@ -149,11 +149,19 @@ struct TestFailureException{}; /////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_MSG( log, messageType, resultDisposition, macroName ) \ - do { \ - INTERNAL_CATCH_ACCEPT_INFO( "", macroName, resultDisposition ); \ - INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( messageType ) << log, resultDisposition, true ) \ - } while( Catch::isTrue( false ) ) +#ifdef CATCH_CONFIG_VARIADIC_MACROS + #define INTERNAL_CATCH_MSG( messageType, resultDisposition, macroName, ... ) \ + do { \ + INTERNAL_CATCH_ACCEPT_INFO( "", macroName, resultDisposition ); \ + INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( messageType ) << __VA_ARGS__ +::Catch::StreamEndStop(), resultDisposition, true ) \ + } while( Catch::isTrue( false ) ) +#else + #define INTERNAL_CATCH_MSG( messageType, resultDisposition, macroName, log ) \ + do { \ + INTERNAL_CATCH_ACCEPT_INFO( "", macroName, resultDisposition ); \ + INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( messageType ) << log +::Catch::StreamEndStop(), resultDisposition, true ) \ + } while( Catch::isTrue( false ) ) +#endif /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_INFO( log, macroName ) \ diff --git a/include/internal/catch_common.h b/include/internal/catch_common.h index 5b091b0a..a823bd64 100644 --- a/include/internal/catch_common.h +++ b/include/internal/catch_common.h @@ -91,6 +91,20 @@ namespace Catch { inline bool isTrue( bool value ){ return value; } void throwLogicError( std::string const& message, SourceLineInfo const& locationInfo ); + + // Use this in variadic streaming macros to allow + // >> +StreamEndStop + // as well as + // >> stuff +StreamEndStop + struct StreamEndStop { + std::string operator+() { + return std::string(); + } + }; + template<typename T> + T const& operator + ( T const& value, StreamEndStop ) { + return value; + } } #define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FILE__, static_cast<std::size_t>( __LINE__ ) ) |