mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Remove "second argument" from result builder and assertion result
This is not quite complete removal (it doesn't pass approval tests), but it should be representative of full perf improvements from doing so
This commit is contained in:
parent
dcab8a5971
commit
0eb101e165
@ -43,14 +43,12 @@ namespace Catch {
|
|||||||
AssertionInfo( char const * _macroName,
|
AssertionInfo( char const * _macroName,
|
||||||
SourceLineInfo const& _lineInfo,
|
SourceLineInfo const& _lineInfo,
|
||||||
char const * _capturedExpression,
|
char const * _capturedExpression,
|
||||||
ResultDisposition::Flags _resultDisposition,
|
ResultDisposition::Flags _resultDisposition);
|
||||||
char const * _secondArg = "");
|
|
||||||
|
|
||||||
char const * macroName;
|
char const * macroName;
|
||||||
SourceLineInfo lineInfo;
|
SourceLineInfo lineInfo;
|
||||||
char const * capturedExpression;
|
char const * capturedExpression;
|
||||||
ResultDisposition::Flags resultDisposition;
|
ResultDisposition::Flags resultDisposition;
|
||||||
char const * secondArg;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AssertionResultData
|
struct AssertionResultData
|
||||||
|
@ -16,13 +16,11 @@ namespace Catch {
|
|||||||
AssertionInfo::AssertionInfo( char const * _macroName,
|
AssertionInfo::AssertionInfo( char const * _macroName,
|
||||||
SourceLineInfo const& _lineInfo,
|
SourceLineInfo const& _lineInfo,
|
||||||
char const * _capturedExpression,
|
char const * _capturedExpression,
|
||||||
ResultDisposition::Flags _resultDisposition,
|
ResultDisposition::Flags _resultDisposition)
|
||||||
char const * _secondArg)
|
|
||||||
: macroName( _macroName ),
|
: macroName( _macroName ),
|
||||||
lineInfo( _lineInfo ),
|
lineInfo( _lineInfo ),
|
||||||
capturedExpression( _capturedExpression ),
|
capturedExpression( _capturedExpression ),
|
||||||
resultDisposition( _resultDisposition ),
|
resultDisposition( _resultDisposition )
|
||||||
secondArg( _secondArg )
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
AssertionResult::AssertionResult() {}
|
AssertionResult::AssertionResult() {}
|
||||||
@ -64,15 +62,16 @@ namespace Catch {
|
|||||||
|
|
||||||
std::string AssertionResult::getExpression() const {
|
std::string AssertionResult::getExpression() const {
|
||||||
if (isFalseTest(m_info.resultDisposition))
|
if (isFalseTest(m_info.resultDisposition))
|
||||||
return '!' + capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg);
|
return '!' + std::string(m_info.capturedExpression);
|
||||||
else
|
else
|
||||||
return capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg);
|
return std::string(m_info.capturedExpression);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string AssertionResult::getExpressionInMacro() const {
|
std::string AssertionResult::getExpressionInMacro() const {
|
||||||
if( m_info.macroName[0] == 0 )
|
if( m_info.macroName[0] == 0 )
|
||||||
return capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg);
|
return std::string(m_info.capturedExpression);
|
||||||
else
|
else
|
||||||
return std::string(m_info.macroName) + "( " + capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg) + " )";
|
return std::string(m_info.macroName) + "( " + m_info.capturedExpression + " )";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AssertionResult::hasExpandedExpression() const {
|
bool AssertionResult::hasExpandedExpression() const {
|
||||||
|
@ -107,7 +107,7 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_THROWS( macroName, resultDisposition, matcher, expr ) \
|
#define INTERNAL_CATCH_THROWS( macroName, resultDisposition, matcher, expr ) \
|
||||||
do { \
|
do { \
|
||||||
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition, #matcher ); \
|
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr ", " #matcher, resultDisposition); \
|
||||||
if( __catchResult.allowThrows() ) \
|
if( __catchResult.allowThrows() ) \
|
||||||
try { \
|
try { \
|
||||||
static_cast<void>(expr); \
|
static_cast<void>(expr); \
|
||||||
|
@ -37,8 +37,7 @@ namespace Catch {
|
|||||||
ResultBuilder( char const* macroName,
|
ResultBuilder( char const* macroName,
|
||||||
SourceLineInfo const& lineInfo,
|
SourceLineInfo const& lineInfo,
|
||||||
char const* capturedExpression,
|
char const* capturedExpression,
|
||||||
ResultDisposition::Flags resultDisposition,
|
ResultDisposition::Flags resultDisposition);
|
||||||
char const* secondArg = "" );
|
|
||||||
~ResultBuilder();
|
~ResultBuilder();
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -21,9 +21,8 @@ namespace Catch {
|
|||||||
ResultBuilder::ResultBuilder( char const* macroName,
|
ResultBuilder::ResultBuilder( char const* macroName,
|
||||||
SourceLineInfo const& lineInfo,
|
SourceLineInfo const& lineInfo,
|
||||||
char const* capturedExpression,
|
char const* capturedExpression,
|
||||||
ResultDisposition::Flags resultDisposition,
|
ResultDisposition::Flags resultDisposition)
|
||||||
char const* secondArg )
|
: m_assertionInfo( macroName, lineInfo, capturedExpression, resultDisposition),
|
||||||
: m_assertionInfo( macroName, lineInfo, capturedExpression, resultDisposition, secondArg ),
|
|
||||||
m_shouldDebugBreak( false ),
|
m_shouldDebugBreak( false ),
|
||||||
m_shouldThrow( false ),
|
m_shouldThrow( false ),
|
||||||
m_guardException( false )
|
m_guardException( false )
|
||||||
@ -77,7 +76,7 @@ namespace Catch {
|
|||||||
assert( !isFalseTest( m_assertionInfo.resultDisposition ) );
|
assert( !isFalseTest( m_assertionInfo.resultDisposition ) );
|
||||||
AssertionResultData data = m_data;
|
AssertionResultData data = m_data;
|
||||||
data.resultType = ResultWas::Ok;
|
data.resultType = ResultWas::Ok;
|
||||||
data.reconstructedExpression = capturedExpressionWithSecondArgument(m_assertionInfo.capturedExpression, m_assertionInfo.secondArg);
|
data.reconstructedExpression = m_assertionInfo.capturedExpression;
|
||||||
|
|
||||||
std::string actualMessage = Catch::translateActiveException();
|
std::string actualMessage = Catch::translateActiveException();
|
||||||
if( !matcher.match( actualMessage ) ) {
|
if( !matcher.match( actualMessage ) ) {
|
||||||
@ -149,7 +148,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ResultBuilder::reconstructExpression( std::string& dest ) const {
|
void ResultBuilder::reconstructExpression( std::string& dest ) const {
|
||||||
dest = capturedExpressionWithSecondArgument(m_assertionInfo.capturedExpression, m_assertionInfo.secondArg);
|
dest = m_assertionInfo.capturedExpression;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResultBuilder::setExceptionGuard() {
|
void ResultBuilder::setExceptionGuard() {
|
||||||
|
Loading…
Reference in New Issue
Block a user