8#ifndef TWOBLUECUBES_CATCH_CAPTURE_MATCHERS_HPP_INCLUDED
9#define TWOBLUECUBES_CATCH_CAPTURE_MATCHERS_HPP_INCLUDED
21 template<
typename ArgT,
typename MatcherT>
22 class MatchExpr :
public ITransientExpression {
31 m_matcherString( matcherString )
35 auto matcherAsString = m_matcher.toString();
38 os << m_matcherString;
40 os << matcherAsString;
44 using StringMatcher = Matchers::Impl::MatcherBase<std::string>;
48 template<
typename ArgT,
typename MatcherT>
57#define INTERNAL_CHECK_THAT( macroName, matcher, resultDisposition, arg ) \
59 Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(arg) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \
60 INTERNAL_CATCH_TRY { \
61 catchAssertionHandler.handleExpr( Catch::makeMatchExpr( arg, matcher, #matcher##_catch_sr ) ); \
62 } INTERNAL_CATCH_CATCH( catchAssertionHandler ) \
63 INTERNAL_CATCH_REACT( catchAssertionHandler ) \
68#define INTERNAL_CATCH_THROWS_MATCHES( macroName, exceptionType, resultDisposition, matcher, ... ) \
70 Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__) ", " CATCH_INTERNAL_STRINGIFY(exceptionType) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \
71 if( catchAssertionHandler.allowThrows() ) \
73 static_cast<void>(__VA_ARGS__ ); \
74 catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \
76 catch( exceptionType const& ex ) { \
77 catchAssertionHandler.handleExpr( Catch::makeMatchExpr( ex, matcher, #matcher##_catch_sr ) ); \
80 catchAssertionHandler.handleUnexpectedInflightException(); \
83 catchAssertionHandler.handleThrowingCallSkipped(); \
84 INTERNAL_CATCH_REACT( catchAssertionHandler ) \
void streamReconstructedExpression(std::ostream &os) const override
MatchExpr(ArgT const &arg, MatcherT const &matcher, StringRef const &matcherString)
GenericStringRef< CharType > StringRef(const CharType *str)
Mark a character pointer as constant string.
const std::string unprintableString
std::string stringify(const T &e)
auto makeMatchExpr(ArgT const &arg, MatcherT const &matcher, StringRef const &matcherString) -> MatchExpr< ArgT, MatcherT >
Matchers::Impl::MatcherBase< std::string > StringMatcher
void handleExceptionMatchExpr(AssertionHandler &handler, std::string const &str, StringRef const &matcherString)