Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorPhil Nash2012-10-26 09:05:36 +0100
committerPhil Nash2012-10-26 09:05:36 +0100
commit355b5e546d2f64dd0abbc0134dd3579ce6c28cea (patch)
tree42a0b5c2045650d2496ad7b1f7048864934c6306 /include
parentf847186ebbf0e7eeabd99925574c8988add600fb (diff)
downloadcatch3-355b5e546d2f64dd0abbc0134dd3579ce6c28cea.tar.gz
Some tidy-up
Diffstat (limited to 'include')
-rw-r--r--include/internal/catch_capture.hpp4
-rw-r--r--include/internal/catch_expression_decomposer.hpp3
-rw-r--r--include/internal/catch_expression_lhs.hpp5
-rw-r--r--include/internal/catch_expressionresult_builder.h6
-rw-r--r--include/internal/catch_expressionresult_builder.hpp4
-rw-r--r--include/internal/catch_runner_impl.hpp16
6 files changed, 22 insertions, 16 deletions
diff --git a/include/internal/catch_capture.hpp b/include/internal/catch_capture.hpp
index e724cd43..43452dd7 100644
--- a/include/internal/catch_capture.hpp
+++ b/include/internal/catch_capture.hpp
@@ -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:
diff --git a/include/internal/catch_expression_decomposer.hpp b/include/internal/catch_expression_decomposer.hpp
index 3df9c25e..1d8ca73d 100644
--- a/include/internal/catch_expression_decomposer.hpp
+++ b/include/internal/catch_expression_decomposer.hpp
@@ -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:
diff --git a/include/internal/catch_expression_lhs.hpp b/include/internal/catch_expression_lhs.hpp
index d85579d1..f7c4fb14 100644
--- a/include/internal/catch_expression_lhs.hpp
+++ b/include/internal/catch_expression_lhs.hpp
@@ -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 );
}
diff --git a/include/internal/catch_expressionresult_builder.h b/include/internal/catch_expressionresult_builder.h
index 5c63b3ee..23b84646 100644
--- a/include/internal/catch_expressionresult_builder.h
+++ b/include/internal/catch_expressionresult_builder.h
@@ -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;
diff --git a/include/internal/catch_expressionresult_builder.hpp b/include/internal/catch_expressionresult_builder.hpp
index ecaeddf6..69471289 100644
--- a/include/internal/catch_expressionresult_builder.hpp
+++ b/include/internal/catch_expressionresult_builder.hpp
@@ -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 == "" )
diff --git a/include/internal/catch_runner_impl.hpp b/include/internal/catch_runner_impl.hpp
index 489bc5d7..1bae7f66 100644
--- a/include/internal/catch_runner_impl.hpp
+++ b/include/internal/catch_runner_impl.hpp
@@ -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;