mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 12:55:40 +02:00
Some tidy-up
This commit is contained in:
@@ -67,8 +67,8 @@ public:
|
||||
m_resultBuilder << value;
|
||||
return *this;
|
||||
}
|
||||
AssertionResultData getInfo () const {
|
||||
return m_resultBuilder.build( AssertionInfo() ); // !TBD
|
||||
AssertionResult buildResult( const AssertionInfo& assertionInfo ) const {
|
||||
return m_resultBuilder.buildResult( assertionInfo );
|
||||
}
|
||||
|
||||
private:
|
||||
|
@@ -11,7 +11,8 @@
|
||||
#include "catch_expression_lhs.hpp"
|
||||
|
||||
namespace Catch {
|
||||
|
||||
|
||||
// Captures the LHS of the expression and wraps it in an Expression Lhs object
|
||||
class ExpressionDecomposer {
|
||||
public:
|
||||
|
||||
|
@@ -20,6 +20,9 @@ namespace Catch {
|
||||
inline void setResultIfBoolean( ExpressionResultBuilder& result, bool value ) {
|
||||
result.setResultType( value );
|
||||
}
|
||||
|
||||
// Wraps the LHS of an expression and captures the operator and RHS (if any) - wrapping them all
|
||||
// in an ExpressionResultBuilder object
|
||||
template<typename T>
|
||||
class ExpressionLhs {
|
||||
void operator = ( const ExpressionLhs& );
|
||||
@@ -67,7 +70,7 @@ public:
|
||||
return captureExpression<Internal::IsNotEqualTo>( rhs );
|
||||
}
|
||||
|
||||
ExpressionResultBuilder negate( bool shouldNegate ) {
|
||||
ExpressionResultBuilder& negate( bool shouldNegate ) {
|
||||
return m_result.negate( shouldNegate );
|
||||
}
|
||||
|
||||
|
@@ -15,7 +15,9 @@
|
||||
#include "catch_common.h"
|
||||
|
||||
namespace Catch {
|
||||
|
||||
|
||||
// Wraps the (stringised versions of) the lhs, operator and rhs of an expression - as well as
|
||||
// the result of evaluating it. This is used to build an AssertionResult object
|
||||
class ExpressionResultBuilder {
|
||||
public:
|
||||
|
||||
@@ -39,7 +41,7 @@ public:
|
||||
|
||||
std::string reconstructExpression( const AssertionInfo& info ) const;
|
||||
|
||||
AssertionResultData build( const AssertionInfo& info ) const;
|
||||
AssertionResult buildResult( const AssertionInfo& info ) const;
|
||||
|
||||
private:
|
||||
AssertionResultData m_data;
|
||||
|
@@ -54,7 +54,7 @@ namespace Catch {
|
||||
m_exprComponents.op = op;
|
||||
return *this;
|
||||
}
|
||||
AssertionResultData ExpressionResultBuilder::build( const AssertionInfo& info ) const
|
||||
AssertionResult ExpressionResultBuilder::buildResult( const AssertionInfo& info ) const
|
||||
{
|
||||
assert( m_data.resultType != ResultWas::Unknown );
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Catch {
|
||||
else
|
||||
data.reconstructedExpression = "!(" + data.reconstructedExpression + ")";
|
||||
}
|
||||
return data;
|
||||
return AssertionResult( info, data );
|
||||
}
|
||||
std::string ExpressionResultBuilder::reconstructExpression( const AssertionInfo& info ) const {
|
||||
if( m_exprComponents.op == "" )
|
||||
|
@@ -151,19 +151,19 @@ namespace Catch {
|
||||
std::vector<ScopedInfo*>::const_iterator it = m_scopedInfos.begin();
|
||||
std::vector<ScopedInfo*>::const_iterator itEnd = m_scopedInfos.end();
|
||||
for(; it != itEnd; ++it )
|
||||
m_reporter->Result( AssertionResult( m_assertionInfo, (*it)->getInfo() ) );
|
||||
m_reporter->Result( (*it)->buildResult( m_assertionInfo ) );
|
||||
}
|
||||
{
|
||||
std::vector<AssertionResult>::const_iterator it = m_info.begin();
|
||||
std::vector<AssertionResult>::const_iterator itEnd = m_info.end();
|
||||
std::vector<AssertionResult>::const_iterator it = m_assertionResults.begin();
|
||||
std::vector<AssertionResult>::const_iterator itEnd = m_assertionResults.end();
|
||||
for(; it != itEnd; ++it )
|
||||
m_reporter->Result( *it );
|
||||
}
|
||||
m_info.clear();
|
||||
m_assertionResults.clear();
|
||||
}
|
||||
|
||||
if( result.getResultType() == ResultWas::Info )
|
||||
m_info.push_back( result );
|
||||
m_assertionResults.push_back( result );
|
||||
else
|
||||
m_reporter->Result( result );
|
||||
}
|
||||
@@ -233,7 +233,7 @@ namespace Catch {
|
||||
private:
|
||||
|
||||
ResultAction::Value actOnCurrentResult() {
|
||||
m_lastResult = AssertionResult( m_assertionInfo, m_currentResult.build( m_assertionInfo ) );
|
||||
m_lastResult = m_currentResult.buildResult( m_assertionInfo );
|
||||
testEnded( m_lastResult );
|
||||
|
||||
m_currentResult = ExpressionResultBuilder();
|
||||
@@ -281,7 +281,7 @@ namespace Catch {
|
||||
<< translateActiveException();
|
||||
actOnCurrentResult();
|
||||
}
|
||||
m_info.clear();
|
||||
m_assertionResults.clear();
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -294,7 +294,7 @@ namespace Catch {
|
||||
Totals m_totals;
|
||||
Ptr<IReporter> m_reporter;
|
||||
std::vector<ScopedInfo*> m_scopedInfos;
|
||||
std::vector<AssertionResult> m_info;
|
||||
std::vector<AssertionResult> m_assertionResults;
|
||||
IRunner* m_prevRunner;
|
||||
IResultCapture* m_prevResultCapture;
|
||||
const IConfig* m_prevConfig;
|
||||
|
Reference in New Issue
Block a user