mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 13:26:10 +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
|
// 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 matcherString ) {
|
void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str ) {
|
||||||
handleExceptionMatchExpr( handler, Matchers::Equals( str ), matcherString );
|
handleExceptionMatchExpr( handler, Matchers::Equals( str ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Catch
|
} // namespace Catch
|
||||||
|
@ -64,7 +64,7 @@ namespace Catch {
|
|||||||
auto allowThrows() const -> bool;
|
auto allowThrows() const -> bool;
|
||||||
};
|
};
|
||||||
|
|
||||||
void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str, StringRef matcherString );
|
void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str );
|
||||||
|
|
||||||
} // namespace Catch
|
} // namespace Catch
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@
|
|||||||
catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \
|
catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \
|
||||||
} \
|
} \
|
||||||
catch( ... ) { \
|
catch( ... ) { \
|
||||||
Catch::handleExceptionMatchExpr( catchAssertionHandler, matcher, #matcher##_catch_sr ); \
|
Catch::handleExceptionMatchExpr( catchAssertionHandler, matcher ); \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
catchAssertionHandler.handleThrowingCallSkipped(); \
|
catchAssertionHandler.handleThrowingCallSkipped(); \
|
||||||
|
@ -16,9 +16,9 @@ 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 matcherString ) {
|
void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher ) {
|
||||||
std::string exceptionMessage = Catch::translateActiveException();
|
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 );
|
handler.handleExpr( expr );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
#define CATCH_MATCHERS_IMPL_HPP_INCLUDED
|
#define CATCH_MATCHERS_IMPL_HPP_INCLUDED
|
||||||
|
|
||||||
#include <catch2/internal/catch_test_macro_impl.hpp>
|
#include <catch2/internal/catch_test_macro_impl.hpp>
|
||||||
#include <catch2/internal/catch_stringref.hpp>
|
|
||||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
@ -18,13 +17,11 @@ namespace Catch {
|
|||||||
class MatchExpr : public ITransientExpression {
|
class MatchExpr : public ITransientExpression {
|
||||||
ArgT && m_arg;
|
ArgT && m_arg;
|
||||||
MatcherT const& m_matcher;
|
MatcherT const& m_matcher;
|
||||||
StringRef m_matcherString;
|
|
||||||
public:
|
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
|
: ITransientExpression{ true, matcher.match( arg ) }, // not forwarding arg here on purpose
|
||||||
m_arg( CATCH_FORWARD(arg) ),
|
m_arg( CATCH_FORWARD(arg) ),
|
||||||
m_matcher( matcher ),
|
m_matcher( matcher )
|
||||||
m_matcherString( matcherString )
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void streamReconstructedExpression( std::ostream& os ) const override {
|
void streamReconstructedExpression( std::ostream& os ) const override {
|
||||||
@ -41,11 +38,11 @@ namespace Catch {
|
|||||||
|
|
||||||
using StringMatcher = Matchers::MatcherBase<std::string>;
|
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>
|
template<typename ArgT, typename MatcherT>
|
||||||
auto makeMatchExpr( ArgT && arg, MatcherT const& matcher, StringRef matcherString ) -> MatchExpr<ArgT, MatcherT> {
|
auto makeMatchExpr( ArgT && arg, MatcherT const& matcher ) -> MatchExpr<ArgT, MatcherT> {
|
||||||
return MatchExpr<ArgT, MatcherT>( CATCH_FORWARD(arg), matcher, matcherString );
|
return MatchExpr<ArgT, MatcherT>( CATCH_FORWARD(arg), matcher );
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Catch
|
} // namespace Catch
|
||||||
@ -56,7 +53,7 @@ namespace Catch {
|
|||||||
do { \
|
do { \
|
||||||
Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(arg) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \
|
Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(arg) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \
|
||||||
INTERNAL_CATCH_TRY { \
|
INTERNAL_CATCH_TRY { \
|
||||||
catchAssertionHandler.handleExpr( Catch::makeMatchExpr( arg, matcher, #matcher##_catch_sr ) ); \
|
catchAssertionHandler.handleExpr( Catch::makeMatchExpr( arg, matcher ) ); \
|
||||||
} INTERNAL_CATCH_CATCH( catchAssertionHandler ) \
|
} INTERNAL_CATCH_CATCH( catchAssertionHandler ) \
|
||||||
INTERNAL_CATCH_REACT( catchAssertionHandler ) \
|
INTERNAL_CATCH_REACT( catchAssertionHandler ) \
|
||||||
} while( false )
|
} while( false )
|
||||||
@ -72,7 +69,7 @@ namespace Catch {
|
|||||||
catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \
|
catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \
|
||||||
} \
|
} \
|
||||||
catch( exceptionType const& ex ) { \
|
catch( exceptionType const& ex ) { \
|
||||||
catchAssertionHandler.handleExpr( Catch::makeMatchExpr( ex, matcher, #matcher##_catch_sr ) ); \
|
catchAssertionHandler.handleExpr( Catch::makeMatchExpr( ex, matcher ) ); \
|
||||||
} \
|
} \
|
||||||
catch( ... ) { \
|
catch( ... ) { \
|
||||||
catchAssertionHandler.handleUnexpectedInflightException(); \
|
catchAssertionHandler.handleUnexpectedInflightException(); \
|
||||||
|
Loading…
Reference in New Issue
Block a user