mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-22 11:23:29 +01:00
Remove unused StringRef argument from MatchExpr
Apart from cleaning up the code, this change also improves the compilation time of `UsageTests/Matchers.tests.cpp` by about 2%.
This commit is contained in:
parent
943c6e3dee
commit
6e77e16ea8
@ -76,8 +76,8 @@ namespace Catch {
|
||||
|
||||
// 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
|
||||
void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str, StringRef matcherString ) {
|
||||
handleExceptionMatchExpr( handler, Matchers::Equals( str ), matcherString );
|
||||
void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str ) {
|
||||
handleExceptionMatchExpr( handler, Matchers::Equals( str ) );
|
||||
}
|
||||
|
||||
} // namespace Catch
|
||||
|
@ -64,7 +64,7 @@ namespace Catch {
|
||||
auto allowThrows() const -> bool;
|
||||
};
|
||||
|
||||
void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str, StringRef matcherString );
|
||||
void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str );
|
||||
|
||||
} // namespace Catch
|
||||
|
||||
|
@ -147,7 +147,7 @@
|
||||
catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \
|
||||
} \
|
||||
catch( ... ) { \
|
||||
Catch::handleExceptionMatchExpr( catchAssertionHandler, matcher, #matcher##_catch_sr ); \
|
||||
Catch::handleExceptionMatchExpr( catchAssertionHandler, matcher ); \
|
||||
} \
|
||||
else \
|
||||
catchAssertionHandler.handleThrowingCallSkipped(); \
|
||||
|
@ -16,9 +16,9 @@ namespace Catch {
|
||||
// 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
|
||||
// the Equals matcher (so the header does not mention matchers)
|
||||
void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher, StringRef matcherString ) {
|
||||
void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher ) {
|
||||
std::string exceptionMessage = Catch::translateActiveException();
|
||||
MatchExpr<std::string, StringMatcher const&> expr( CATCH_MOVE(exceptionMessage), matcher, matcherString );
|
||||
MatchExpr<std::string, StringMatcher const&> expr( CATCH_MOVE(exceptionMessage), matcher );
|
||||
handler.handleExpr( expr );
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,6 @@
|
||||
#define CATCH_MATCHERS_IMPL_HPP_INCLUDED
|
||||
|
||||
#include <catch2/internal/catch_test_macro_impl.hpp>
|
||||
#include <catch2/internal/catch_stringref.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
namespace Catch {
|
||||
@ -18,13 +17,11 @@ namespace Catch {
|
||||
class MatchExpr : public ITransientExpression {
|
||||
ArgT && m_arg;
|
||||
MatcherT const& m_matcher;
|
||||
StringRef m_matcherString;
|
||||
public:
|
||||
MatchExpr( ArgT && arg, MatcherT const& matcher, StringRef matcherString )
|
||||
MatchExpr( ArgT && arg, MatcherT const& matcher )
|
||||
: ITransientExpression{ true, matcher.match( arg ) }, // not forwarding arg here on purpose
|
||||
m_arg( CATCH_FORWARD(arg) ),
|
||||
m_matcher( matcher ),
|
||||
m_matcherString( matcherString )
|
||||
m_matcher( matcher )
|
||||
{}
|
||||
|
||||
void streamReconstructedExpression( std::ostream& os ) const override {
|
||||
@ -41,11 +38,11 @@ namespace Catch {
|
||||
|
||||
using StringMatcher = Matchers::MatcherBase<std::string>;
|
||||
|
||||
void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher, StringRef matcherString );
|
||||
void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher );
|
||||
|
||||
template<typename ArgT, typename MatcherT>
|
||||
auto makeMatchExpr( ArgT && arg, MatcherT const& matcher, StringRef matcherString ) -> MatchExpr<ArgT, MatcherT> {
|
||||
return MatchExpr<ArgT, MatcherT>( CATCH_FORWARD(arg), matcher, matcherString );
|
||||
auto makeMatchExpr( ArgT && arg, MatcherT const& matcher ) -> MatchExpr<ArgT, MatcherT> {
|
||||
return MatchExpr<ArgT, MatcherT>( CATCH_FORWARD(arg), matcher );
|
||||
}
|
||||
|
||||
} // namespace Catch
|
||||
@ -56,7 +53,7 @@ namespace Catch {
|
||||
do { \
|
||||
Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(arg) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \
|
||||
INTERNAL_CATCH_TRY { \
|
||||
catchAssertionHandler.handleExpr( Catch::makeMatchExpr( arg, matcher, #matcher##_catch_sr ) ); \
|
||||
catchAssertionHandler.handleExpr( Catch::makeMatchExpr( arg, matcher ) ); \
|
||||
} INTERNAL_CATCH_CATCH( catchAssertionHandler ) \
|
||||
INTERNAL_CATCH_REACT( catchAssertionHandler ) \
|
||||
} while( false )
|
||||
@ -72,7 +69,7 @@ namespace Catch {
|
||||
catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \
|
||||
} \
|
||||
catch( exceptionType const& ex ) { \
|
||||
catchAssertionHandler.handleExpr( Catch::makeMatchExpr( ex, matcher, #matcher##_catch_sr ) ); \
|
||||
catchAssertionHandler.handleExpr( Catch::makeMatchExpr( ex, matcher ) ); \
|
||||
} \
|
||||
catch( ... ) { \
|
||||
catchAssertionHandler.handleUnexpectedInflightException(); \
|
||||
|
Loading…
Reference in New Issue
Block a user