Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/include/internal
diff options
context:
space:
mode:
authorPhil Nash2013-12-12 23:02:31 +0000
committerPhil Nash2013-12-12 23:02:31 +0000
commit274ed3ea7623978d3d49cd4f211dc761e1a44317 (patch)
tree3942ebb7f6320d99d3708d637625a9597eed09d7 /include/internal
parenta6d74bd55aeff9a2506906e451305364f7a02d34 (diff)
downloadcatch3-274ed3ea7623978d3d49cd4f211dc761e1a44317.tar.gz
Allow FAIL() to be empty
Diffstat (limited to 'include/internal')
-rw-r--r--include/internal/catch_capture.hpp18
-rw-r--r--include/internal/catch_common.h14
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__ ) )