mirror of
https://github.com/catchorg/Catch2.git
synced 2025-04-28 19:53:52 +00:00
Compare commits
4 Commits
28f6698ec8
...
0c0f73a48d
Author | SHA1 | Date | |
---|---|---|---|
|
0c0f73a48d | ||
|
61e16416a9 | ||
|
074017f5ad | ||
|
0a89e7f0c4 |
@ -17,13 +17,6 @@ namespace Catch {
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
Catch::MessageBuilder::MessageBuilder( StringRef const& macroName,
|
|
||||||
SourceLineInfo const& lineInfo,
|
|
||||||
ResultWas::OfType type )
|
|
||||||
:m_info(macroName, lineInfo, type) {}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
ScopedMessage::ScopedMessage( MessageBuilder const& builder ):
|
ScopedMessage::ScopedMessage( MessageBuilder const& builder ):
|
||||||
m_info( builder.m_info ) {
|
m_info( builder.m_info ) {
|
||||||
|
@ -34,9 +34,11 @@ namespace Catch {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct MessageBuilder : MessageStream {
|
struct MessageBuilder : MessageStream {
|
||||||
MessageBuilder( StringRef const& macroName,
|
MessageBuilder( StringRef macroName,
|
||||||
SourceLineInfo const& lineInfo,
|
SourceLineInfo const& lineInfo,
|
||||||
ResultWas::OfType type );
|
ResultWas::OfType type ):
|
||||||
|
m_info(macroName, lineInfo, type) {}
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
MessageBuilder& operator << ( T const& value ) {
|
MessageBuilder& operator << ( T const& value ) {
|
||||||
|
@ -63,7 +63,7 @@ namespace Catch {
|
|||||||
virtual void handleMessage
|
virtual void handleMessage
|
||||||
( AssertionInfo const& info,
|
( AssertionInfo const& info,
|
||||||
ResultWas::OfType resultType,
|
ResultWas::OfType resultType,
|
||||||
StringRef const& message,
|
StringRef message,
|
||||||
AssertionReaction& reaction ) = 0;
|
AssertionReaction& reaction ) = 0;
|
||||||
virtual void handleUnexpectedExceptionNotThrown
|
virtual void handleUnexpectedExceptionNotThrown
|
||||||
( AssertionInfo const& info,
|
( AssertionInfo const& info,
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
AssertionHandler::AssertionHandler
|
AssertionHandler::AssertionHandler
|
||||||
( StringRef const& macroName,
|
( StringRef macroName,
|
||||||
SourceLineInfo const& lineInfo,
|
SourceLineInfo const& lineInfo,
|
||||||
StringRef capturedExpression,
|
StringRef capturedExpression,
|
||||||
ResultDisposition::Flags resultDisposition )
|
ResultDisposition::Flags resultDisposition )
|
||||||
@ -29,7 +29,7 @@ namespace Catch {
|
|||||||
void AssertionHandler::handleExpr( ITransientExpression const& expr ) {
|
void AssertionHandler::handleExpr( ITransientExpression const& expr ) {
|
||||||
m_resultCapture.handleExpr( m_assertionInfo, expr, m_reaction );
|
m_resultCapture.handleExpr( m_assertionInfo, expr, m_reaction );
|
||||||
}
|
}
|
||||||
void AssertionHandler::handleMessage(ResultWas::OfType resultType, StringRef const& message) {
|
void AssertionHandler::handleMessage(ResultWas::OfType resultType, StringRef message) {
|
||||||
m_resultCapture.handleMessage( m_assertionInfo, resultType, message, m_reaction );
|
m_resultCapture.handleMessage( m_assertionInfo, resultType, message, m_reaction );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ namespace Catch {
|
|||||||
|
|
||||||
// This is the overload that takes a string and infers the Equals matcher from it
|
// This is the overload that takes a string and infers the Equals matcher from it
|
||||||
// The more general overload, that takes any string matcher, is in catch_capture_matchers.cpp
|
// The more general overload, that takes any string matcher, is in catch_capture_matchers.cpp
|
||||||
void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str, StringRef const& matcherString ) {
|
void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str, StringRef matcherString ) {
|
||||||
handleExceptionMatchExpr( handler, Matchers::Equals( str ), matcherString );
|
handleExceptionMatchExpr( handler, Matchers::Equals( str ), matcherString );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ namespace Catch {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
AssertionHandler
|
AssertionHandler
|
||||||
( StringRef const& macroName,
|
( StringRef macroName,
|
||||||
SourceLineInfo const& lineInfo,
|
SourceLineInfo const& lineInfo,
|
||||||
StringRef capturedExpression,
|
StringRef capturedExpression,
|
||||||
ResultDisposition::Flags resultDisposition );
|
ResultDisposition::Flags resultDisposition );
|
||||||
@ -49,7 +49,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
void handleExpr( ITransientExpression const& expr );
|
void handleExpr( ITransientExpression const& expr );
|
||||||
|
|
||||||
void handleMessage(ResultWas::OfType resultType, StringRef const& message);
|
void handleMessage(ResultWas::OfType resultType, StringRef message);
|
||||||
|
|
||||||
void handleExceptionThrownAsExpected();
|
void handleExceptionThrownAsExpected();
|
||||||
void handleUnexpectedExceptionNotThrown();
|
void handleUnexpectedExceptionNotThrown();
|
||||||
@ -64,7 +64,7 @@ namespace Catch {
|
|||||||
auto allowThrows() const -> bool;
|
auto allowThrows() const -> bool;
|
||||||
};
|
};
|
||||||
|
|
||||||
void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str, StringRef const& matcherString );
|
void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str, StringRef matcherString );
|
||||||
|
|
||||||
} // namespace Catch
|
} // namespace Catch
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@ Catch::LeakDetector::~LeakDetector() {
|
|||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
MessageInfo::MessageInfo( StringRef const& _macroName,
|
MessageInfo::MessageInfo( StringRef _macroName,
|
||||||
SourceLineInfo const& _lineInfo,
|
SourceLineInfo const& _lineInfo,
|
||||||
ResultWas::OfType _type )
|
ResultWas::OfType _type )
|
||||||
: macroName( _macroName ),
|
: macroName( _macroName ),
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
struct MessageInfo {
|
struct MessageInfo {
|
||||||
MessageInfo( StringRef const& _macroName,
|
MessageInfo( StringRef _macroName,
|
||||||
SourceLineInfo const& _lineInfo,
|
SourceLineInfo const& _lineInfo,
|
||||||
ResultWas::OfType _type );
|
ResultWas::OfType _type );
|
||||||
|
|
||||||
|
@ -519,7 +519,7 @@ namespace Catch {
|
|||||||
void RunContext::handleMessage(
|
void RunContext::handleMessage(
|
||||||
AssertionInfo const& info,
|
AssertionInfo const& info,
|
||||||
ResultWas::OfType resultType,
|
ResultWas::OfType resultType,
|
||||||
StringRef const& message,
|
StringRef message,
|
||||||
AssertionReaction& reaction
|
AssertionReaction& reaction
|
||||||
) {
|
) {
|
||||||
m_reporter->assertionStarting( info );
|
m_reporter->assertionStarting( info );
|
||||||
|
@ -54,7 +54,7 @@ namespace Catch {
|
|||||||
void handleMessage
|
void handleMessage
|
||||||
( AssertionInfo const& info,
|
( AssertionInfo const& info,
|
||||||
ResultWas::OfType resultType,
|
ResultWas::OfType resultType,
|
||||||
StringRef const& message,
|
StringRef message,
|
||||||
AssertionReaction& reaction ) override;
|
AssertionReaction& reaction ) override;
|
||||||
void handleUnexpectedExceptionNotThrown
|
void handleUnexpectedExceptionNotThrown
|
||||||
( AssertionInfo const& info,
|
( AssertionInfo const& info,
|
||||||
|
@ -149,7 +149,7 @@ namespace {
|
|||||||
m_testAsFunction();
|
m_testAsFunction();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string extractClassName( StringRef const& classOrQualifiedMethodName ) {
|
std::string extractClassName( StringRef classOrQualifiedMethodName ) {
|
||||||
std::string className(classOrQualifiedMethodName);
|
std::string className(classOrQualifiedMethodName);
|
||||||
if( startsWith( className, '&' ) )
|
if( startsWith( className, '&' ) )
|
||||||
{
|
{
|
||||||
|
@ -64,7 +64,7 @@ namespace Catch {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
std::string extractClassName( StringRef const& classOrQualifiedMethodName );
|
std::string extractClassName( StringRef classOrQualifiedMethodName );
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ namespace Catch {
|
|||||||
return Detail::unique_ptr<ITestInvoker>( new TestInvokerAsFunction( testAsFunction ));
|
return Detail::unique_ptr<ITestInvoker>( new TestInvokerAsFunction( testAsFunction ));
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoReg::AutoReg( Detail::unique_ptr<ITestInvoker> invoker, SourceLineInfo const& lineInfo, StringRef const& classOrMethod, NameAndTags const& nameAndTags ) noexcept {
|
AutoReg::AutoReg( Detail::unique_ptr<ITestInvoker> invoker, SourceLineInfo const& lineInfo, StringRef classOrMethod, NameAndTags const& nameAndTags ) noexcept {
|
||||||
CATCH_TRY {
|
CATCH_TRY {
|
||||||
getMutableRegistryHub()
|
getMutableRegistryHub()
|
||||||
.registerTest(
|
.registerTest(
|
||||||
|
@ -46,15 +46,15 @@ Detail::unique_ptr<ITestInvoker> makeTestInvoker( void (C::*testAsMethod)() ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct NameAndTags {
|
struct NameAndTags {
|
||||||
NameAndTags(StringRef const& name_ = StringRef(),
|
constexpr NameAndTags( StringRef name_ = StringRef(),
|
||||||
StringRef const& tags_ = StringRef()) noexcept:
|
StringRef tags_ = StringRef() ) noexcept:
|
||||||
name(name_), tags(tags_) {}
|
name( name_ ), tags( tags_ ) {}
|
||||||
StringRef name;
|
StringRef name;
|
||||||
StringRef tags;
|
StringRef tags;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AutoReg : Detail::NonCopyable {
|
struct AutoReg : Detail::NonCopyable {
|
||||||
AutoReg( Detail::unique_ptr<ITestInvoker> invoker, SourceLineInfo const& lineInfo, StringRef const& classOrMethod, NameAndTags const& nameAndTags ) noexcept;
|
AutoReg( Detail::unique_ptr<ITestInvoker> invoker, SourceLineInfo const& lineInfo, StringRef classOrMethod, NameAndTags const& nameAndTags ) noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
@ -29,7 +29,7 @@ namespace Catch {
|
|||||||
// This is the general overload that takes a any string matcher
|
// This is the general overload that takes a any string matcher
|
||||||
// There is another overload, in catch_assertionhandler.h/.cpp, that only takes a string and infers
|
// There is another overload, in catch_assertionhandler.h/.cpp, that only takes a string and infers
|
||||||
// the Equals matcher (so the header does not mention matchers)
|
// the Equals matcher (so the header does not mention matchers)
|
||||||
void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher, StringRef const& matcherString ) {
|
void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher, StringRef matcherString ) {
|
||||||
std::string exceptionMessage = Catch::translateActiveException();
|
std::string exceptionMessage = Catch::translateActiveException();
|
||||||
MatchExpr<std::string, StringMatcher const&> expr( std::move(exceptionMessage), matcher, matcherString );
|
MatchExpr<std::string, StringMatcher const&> expr( std::move(exceptionMessage), matcher, matcherString );
|
||||||
handler.handleExpr( expr );
|
handler.handleExpr( expr );
|
||||||
|
@ -19,7 +19,7 @@ namespace Catch {
|
|||||||
MatcherT const& m_matcher;
|
MatcherT const& m_matcher;
|
||||||
StringRef m_matcherString;
|
StringRef m_matcherString;
|
||||||
public:
|
public:
|
||||||
MatchExpr( ArgT && arg, MatcherT const& matcher, StringRef const& matcherString )
|
MatchExpr( ArgT && arg, MatcherT const& matcher, StringRef matcherString )
|
||||||
: ITransientExpression{ true, matcher.match( arg ) }, // not forwarding arg here on purpose
|
: ITransientExpression{ true, matcher.match( arg ) }, // not forwarding arg here on purpose
|
||||||
m_arg( std::forward<ArgT>(arg) ),
|
m_arg( std::forward<ArgT>(arg) ),
|
||||||
m_matcher( matcher ),
|
m_matcher( matcher ),
|
||||||
@ -43,10 +43,10 @@ namespace Catch {
|
|||||||
|
|
||||||
using StringMatcher = Matchers::MatcherBase<std::string>;
|
using StringMatcher = Matchers::MatcherBase<std::string>;
|
||||||
|
|
||||||
void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher, StringRef const& matcherString );
|
void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher, StringRef matcherString );
|
||||||
|
|
||||||
template<typename ArgT, typename MatcherT>
|
template<typename ArgT, typename MatcherT>
|
||||||
auto makeMatchExpr( ArgT && arg, MatcherT const& matcher, StringRef const& matcherString ) -> MatchExpr<ArgT, MatcherT> {
|
auto makeMatchExpr( ArgT && arg, MatcherT const& matcher, StringRef matcherString ) -> MatchExpr<ArgT, MatcherT> {
|
||||||
return MatchExpr<ArgT, MatcherT>( std::forward<ArgT>(arg), matcher, matcherString );
|
return MatchExpr<ArgT, MatcherT>( std::forward<ArgT>(arg), matcher, matcherString );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user