diff --git a/include/internal/catch_capture.hpp b/include/internal/catch_capture.hpp index 381c0dd0..2c1552e8 100644 --- a/include/internal/catch_capture.hpp +++ b/include/internal/catch_capture.hpp @@ -35,8 +35,8 @@ public: return *this; } - ResultInfo getInfo () const { - return ResultInfoBuilder() + AssertionResult getInfo () const { + return AssertionResultBuilder() .setResultType( ResultWas::Info ) .setMessage( m_oss.str() ) .setMacroName( "SCOPED_INFO" ) diff --git a/include/internal/catch_expression.hpp b/include/internal/catch_expression.hpp index 0fa0920c..33958f9a 100644 --- a/include/internal/catch_expression.hpp +++ b/include/internal/catch_expression.hpp @@ -18,50 +18,50 @@ class Expression { void operator = ( const Expression& ); public: - Expression( ResultInfoBuilder& result, T lhs ) + Expression( AssertionResultBuilder& result, T lhs ) : m_result( result.setLhs( Catch::toString( lhs ) ) ), m_lhs( lhs ) {} template - ResultInfoBuilder& operator == ( const RhsT& rhs ) { + AssertionResultBuilder& operator == ( const RhsT& rhs ) { return captureExpression( rhs ); } template - ResultInfoBuilder& operator != ( const RhsT& rhs ) { + AssertionResultBuilder& operator != ( const RhsT& rhs ) { return captureExpression( rhs ); } template - ResultInfoBuilder& operator < ( const RhsT& rhs ) { + AssertionResultBuilder& operator < ( const RhsT& rhs ) { return captureExpression( rhs ); } template - ResultInfoBuilder& operator > ( const RhsT& rhs ) { + AssertionResultBuilder& operator > ( const RhsT& rhs ) { return captureExpression( rhs ); } template - ResultInfoBuilder& operator <= ( const RhsT& rhs ) { + AssertionResultBuilder& operator <= ( const RhsT& rhs ) { return captureExpression( rhs ); } template - ResultInfoBuilder& operator >= ( const RhsT& rhs ) { + AssertionResultBuilder& operator >= ( const RhsT& rhs ) { return captureExpression( rhs ); } - ResultInfoBuilder& operator == ( bool rhs ) { + AssertionResultBuilder& operator == ( bool rhs ) { return captureExpression( rhs ); } - ResultInfoBuilder& operator != ( bool rhs ) { + AssertionResultBuilder& operator != ( bool rhs ) { return captureExpression( rhs ); } - operator ResultInfoBuilder& () { + operator AssertionResultBuilder& () { return m_result.setResultType( m_lhs ? ResultWas::Ok : ResultWas::ExpressionFailed ); } @@ -73,7 +73,7 @@ public: private: template - ResultInfoBuilder& captureExpression( const RhsT& rhs ) { + AssertionResultBuilder& captureExpression( const RhsT& rhs ) { return m_result .setResultType( Internal::compare( m_lhs, rhs ) ? ResultWas::Ok : ResultWas::ExpressionFailed ) .setRhs( Catch::toString( rhs ) ) @@ -81,7 +81,7 @@ private: } private: - ResultInfoBuilder& m_result; + AssertionResultBuilder& m_result; T m_lhs; }; diff --git a/include/internal/catch_expression_builder.hpp b/include/internal/catch_expression_builder.hpp index 86f68ecb..e04dcae6 100644 --- a/include/internal/catch_expression_builder.hpp +++ b/include/internal/catch_expression_builder.hpp @@ -87,13 +87,13 @@ public: return *this; } - operator ResultInfoBuilder&() { + operator AssertionResultBuilder&() { m_result.setMessage( m_messageStream.str() ); return m_result; } private: - ResultInfoBuilder m_result; + AssertionResultBuilder m_result; std::ostringstream m_messageStream; }; diff --git a/include/internal/catch_interfaces_capture.h b/include/internal/catch_interfaces_capture.h index 07b5ccd9..e8130a82 100644 --- a/include/internal/catch_interfaces_capture.h +++ b/include/internal/catch_interfaces_capture.h @@ -17,14 +17,14 @@ namespace Catch { class TestCaseInfo; class ScopedInfo; - class ResultInfoBuilder; - class ResultInfo; + class AssertionResultBuilder; + class AssertionResult; struct IResultCapture { virtual ~IResultCapture(); - virtual void testEnded( const ResultInfo& result ) = 0; + virtual void testEnded( const AssertionResult& result ) = 0; virtual bool sectionStarted( const std::string& name, const std::string& description, const SourceLineInfo& lineInfo, @@ -36,11 +36,11 @@ namespace Catch { virtual ResultAction::Value acceptResult( bool result ) = 0; virtual ResultAction::Value acceptResult( ResultWas::OfType result ) = 0; - virtual ResultAction::Value acceptExpression( const ResultInfoBuilder& resultInfo ) = 0; + virtual ResultAction::Value acceptExpression( const AssertionResultBuilder& resultInfo ) = 0; virtual void acceptMessage( const std::string& msg ) = 0; virtual std::string getCurrentTestName() const = 0; - virtual const ResultInfo* getLastResult() const = 0; + virtual const AssertionResult* getLastResult() const = 0; }; } diff --git a/include/internal/catch_interfaces_reporter.h b/include/internal/catch_interfaces_reporter.h index 2fb5cc2a..847016ad 100644 --- a/include/internal/catch_interfaces_reporter.h +++ b/include/internal/catch_interfaces_reporter.h @@ -49,23 +49,37 @@ namespace Catch }; class TestCaseInfo; - class ResultInfo; + class AssertionResult; struct IReporter : IShared { virtual ~IReporter(); - virtual bool shouldRedirectStdout() const = 0; + + virtual bool shouldRedirectStdout() const = 0; + virtual void StartTesting() = 0; virtual void EndTesting( const Totals& totals ) = 0; - virtual void StartGroup( const std::string& groupName ) = 0; + + virtual void StartGroup( const std::string& groupName ) = 0; virtual void EndGroup( const std::string& groupName, const Totals& totals ) = 0; + + virtual void StartTestCase( const TestCaseInfo& testInfo ) = 0; + // TestCaseResult + virtual void EndTestCase( const TestCaseInfo& testInfo, const Totals& totals, const std::string& stdOut, const std::string& stdErr ) = 0; + + // SectionInfo virtual void StartSection( const std::string& sectionName, const std::string& description ) = 0; + // Section Result + virtual void EndSection( const std::string& sectionName, const Counts& assertions ) = 0; + + // - merge into SectionResult ? virtual void NoAssertionsInSection( const std::string& sectionName ) = 0; virtual void NoAssertionsInTestCase( const std::string& testName ) = 0; - virtual void EndSection( const std::string& sectionName, const Counts& assertions ) = 0; - virtual void StartTestCase( const TestCaseInfo& testInfo ) = 0; + + // - merge into SectionResult, TestCaseResult, GroupResult & TestRunResult virtual void Aborted() = 0; - virtual void EndTestCase( const TestCaseInfo& testInfo, const Totals& totals, const std::string& stdOut, const std::string& stdErr ) = 0; - virtual void Result( const ResultInfo& result ) = 0; + + // AssertionReslt + virtual void Result( const AssertionResult& result ) = 0; }; struct IReporterFactory { diff --git a/include/internal/catch_resultinfo.h b/include/internal/catch_resultinfo.h index db4e9e6e..f6d244f6 100644 --- a/include/internal/catch_resultinfo.h +++ b/include/internal/catch_resultinfo.h @@ -5,8 +5,8 @@ * Distributed under the Boost Software License, Version 1.0. (See accompanying * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ -#ifndef TWOBLUECUBES_CATCH_RESULTINFO_H_INCLUDED -#define TWOBLUECUBES_CATCH_RESULTINFO_H_INCLUDED +#ifndef TWOBLUECUBES_CATCH_ASSERTIONRESULT_H_INCLUDED +#define TWOBLUECUBES_CATCH_ASSERTIONRESULT_H_INCLUDED #include #include "catch_result_type.h" @@ -25,11 +25,11 @@ namespace Catch { ResultWas::OfType resultType; }; - class ResultInfo { + class AssertionResult { public: - ResultInfo(); - ResultInfo( const ResultData& data ); - ~ResultInfo(); + AssertionResult(); + AssertionResult( const ResultData& data ); + ~AssertionResult(); bool ok() const; ResultWas::OfType getResultType() const; @@ -49,4 +49,4 @@ namespace Catch { } // end namespace Catch -#endif // TWOBLUECUBES_CATCH_RESULTINFO_H_INCLUDED +#endif // TWOBLUECUBES_CATCH_ASSERTIONRESULT_H_INCLUDED diff --git a/include/internal/catch_resultinfo.hpp b/include/internal/catch_resultinfo.hpp index b7ec8c2f..bc322983 100644 --- a/include/internal/catch_resultinfo.hpp +++ b/include/internal/catch_resultinfo.hpp @@ -5,63 +5,63 @@ * Distributed under the Boost Software License, Version 1.0. (See accompanying * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ -#ifndef TWOBLUECUBES_CATCH_RESULTINFO_HPP_INCLUDED -#define TWOBLUECUBES_CATCH_RESULTINFO_HPP_INCLUDED +#ifndef TWOBLUECUBES_CATCH_ASSERTIONRESULT_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_ASSERTIONRESULT_HPP_INCLUDED #include "catch_resultinfo.h" namespace Catch { - ResultInfo::ResultInfo() {} + AssertionResult::AssertionResult() {} - ResultInfo::ResultInfo( const ResultData& data ) : m_data( data ) {} + AssertionResult::AssertionResult( const ResultData& data ) : m_data( data ) {} - ResultInfo::~ResultInfo() {} + AssertionResult::~AssertionResult() {} - bool ResultInfo::ok() const { + bool AssertionResult::ok() const { return isOk( m_data.resultType ); } - ResultWas::OfType ResultInfo::getResultType() const { + ResultWas::OfType AssertionResult::getResultType() const { return m_data.resultType; } - bool ResultInfo::hasExpression() const { + bool AssertionResult::hasExpression() const { return !m_data.capturedExpression.empty(); } - bool ResultInfo::hasMessage() const { + bool AssertionResult::hasMessage() const { return !m_data.message.empty(); } - std::string ResultInfo::getExpression() const { + std::string AssertionResult::getExpression() const { return m_data.capturedExpression; } - bool ResultInfo::hasExpandedExpression() const { + bool AssertionResult::hasExpandedExpression() const { return hasExpression() && getExpandedExpression() != getExpression(); } - std::string ResultInfo::getExpandedExpression() const { + std::string AssertionResult::getExpandedExpression() const { return m_data.reconstructedExpression; } - std::string ResultInfo::getMessage() const { + std::string AssertionResult::getMessage() const { return m_data.message; } - std::string ResultInfo::getFilename() const { + std::string AssertionResult::getFilename() const { return m_data.lineInfo.file; } - std::size_t ResultInfo::getLine() const { + std::size_t AssertionResult::getLine() const { return m_data.lineInfo.line; } - std::string ResultInfo::getTestMacroName() const { + std::string AssertionResult::getTestMacroName() const { return m_data.macroName; } } // end namespace Catch -#endif // TWOBLUECUBES_CATCH_RESULTINFO_HPP_INCLUDED +#endif // TWOBLUECUBES_CATCH_ASSERTIONRESULT_HPP_INCLUDED diff --git a/include/internal/catch_resultinfo_builder.h b/include/internal/catch_resultinfo_builder.h index cf2014ec..d4c42918 100644 --- a/include/internal/catch_resultinfo_builder.h +++ b/include/internal/catch_resultinfo_builder.h @@ -5,8 +5,8 @@ * Distributed under the Boost Software License, Version 1.0. (See accompanying * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ -#ifndef TWOBLUECUBES_CATCH_RESULTINFO_BUILDER_H_INCLUDED -#define TWOBLUECUBES_CATCH_RESULTINFO_BUILDER_H_INCLUDED +#ifndef TWOBLUECUBES_CATCH_ASSERTIONRESULT_BUILDER_H_INCLUDED +#define TWOBLUECUBES_CATCH_ASSERTIONRESULT_BUILDER_H_INCLUDED #include "catch_tostring.hpp" #include "catch_resultinfo.h" @@ -18,24 +18,24 @@ namespace Catch { struct STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison; -class ResultInfoBuilder { +class AssertionResultBuilder { public: - ResultInfoBuilder(); + AssertionResultBuilder(); - ResultInfoBuilder& setResultType( ResultWas::OfType result ); - ResultInfoBuilder& setCapturedExpression( const std::string& capturedExpression ); - ResultInfoBuilder& setIsFalse( bool isFalse ); - ResultInfoBuilder& setMessage( const std::string& message ); - ResultInfoBuilder& setLineInfo( const SourceLineInfo& lineInfo ); - ResultInfoBuilder& setLhs( const std::string& lhs ); - ResultInfoBuilder& setRhs( const std::string& rhs ); - ResultInfoBuilder& setOp( const std::string& op ); - ResultInfoBuilder& setMacroName( const std::string& macroName ); + AssertionResultBuilder& setResultType( ResultWas::OfType result ); + AssertionResultBuilder& setCapturedExpression( const std::string& capturedExpression ); + AssertionResultBuilder& setIsFalse( bool isFalse ); + AssertionResultBuilder& setMessage( const std::string& message ); + AssertionResultBuilder& setLineInfo( const SourceLineInfo& lineInfo ); + AssertionResultBuilder& setLhs( const std::string& lhs ); + AssertionResultBuilder& setRhs( const std::string& rhs ); + AssertionResultBuilder& setOp( const std::string& op ); + AssertionResultBuilder& setMacroName( const std::string& macroName ); std::string reconstructExpression() const; - ResultInfo build() const; + AssertionResult build() const; // Disable attempts to use || and && in expressions (without parantheses) template @@ -55,4 +55,4 @@ private: } // end namespace Catch -#endif // TWOBLUECUBES_CATCH_RESULTINFO_BUILDER_H_INCLUDED +#endif // TWOBLUECUBES_CATCH_ASSERTIONRESULT_BUILDER_H_INCLUDED diff --git a/include/internal/catch_resultinfo_builder.hpp b/include/internal/catch_resultinfo_builder.hpp index 4da4d5d2..368abe0b 100644 --- a/include/internal/catch_resultinfo_builder.hpp +++ b/include/internal/catch_resultinfo_builder.hpp @@ -5,16 +5,16 @@ * Distributed under the Boost Software License, Version 1.0. (See accompanying * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ -#ifndef TWOBLUECUBES_CATCH_RESULTINFO_BUILDER_HPP_INCLUDED -#define TWOBLUECUBES_CATCH_RESULTINFO_BUILDER_HPP_INCLUDED +#ifndef TWOBLUECUBES_CATCH_ASSERTIONRESULT_BUILDER_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_ASSERTIONRESULT_BUILDER_HPP_INCLUDED #include "catch_resultinfo_builder.h" namespace Catch { - ResultInfoBuilder::ResultInfoBuilder() {} + AssertionResultBuilder::AssertionResultBuilder() {} - ResultInfoBuilder& ResultInfoBuilder::setResultType( ResultWas::OfType result ) { + AssertionResultBuilder& AssertionResultBuilder::setResultType( ResultWas::OfType result ) { // Flip bool results if isFalse is set if( m_isFalse && result == ResultWas::Ok ) m_data.resultType = ResultWas::ExpressionFailed; @@ -24,46 +24,46 @@ namespace Catch { m_data.resultType = result; return *this; } - ResultInfoBuilder& ResultInfoBuilder::setCapturedExpression( const std::string& capturedExpression ) { + AssertionResultBuilder& AssertionResultBuilder::setCapturedExpression( const std::string& capturedExpression ) { m_data.capturedExpression = capturedExpression; return *this; } - ResultInfoBuilder& ResultInfoBuilder::setIsFalse( bool isFalse ) { + AssertionResultBuilder& AssertionResultBuilder::setIsFalse( bool isFalse ) { m_isFalse = isFalse; return *this; } - ResultInfoBuilder& ResultInfoBuilder::setMessage( const std::string& message ) { + AssertionResultBuilder& AssertionResultBuilder::setMessage( const std::string& message ) { m_data.message = message; return *this; } - ResultInfoBuilder& ResultInfoBuilder::setLineInfo( const SourceLineInfo& lineInfo ) { + AssertionResultBuilder& AssertionResultBuilder::setLineInfo( const SourceLineInfo& lineInfo ) { m_data.lineInfo = lineInfo; return *this; } - ResultInfoBuilder& ResultInfoBuilder::setMacroName( const std::string& macroName ) { + AssertionResultBuilder& AssertionResultBuilder::setMacroName( const std::string& macroName ) { m_data.macroName = macroName; return *this; } - ResultInfoBuilder& ResultInfoBuilder::setLhs( const std::string& lhs ) { + AssertionResultBuilder& AssertionResultBuilder::setLhs( const std::string& lhs ) { m_lhs = lhs; return *this; } - ResultInfoBuilder& ResultInfoBuilder::setRhs( const std::string& rhs ) { + AssertionResultBuilder& AssertionResultBuilder::setRhs( const std::string& rhs ) { m_rhs = rhs; return *this; } - ResultInfoBuilder& ResultInfoBuilder::setOp( const std::string& op ) { + AssertionResultBuilder& AssertionResultBuilder::setOp( const std::string& op ) { m_op = op; return *this; } - ResultInfo ResultInfoBuilder::build() const + AssertionResult AssertionResultBuilder::build() const { ResultData data = m_data; data.reconstructedExpression = reconstructExpression(); @@ -77,10 +77,10 @@ namespace Catch { data.reconstructedExpression = "!(" + data.reconstructedExpression + ")"; } } - return ResultInfo( data ); + return AssertionResult( data ); } - std::string ResultInfoBuilder::reconstructExpression() const { + std::string AssertionResultBuilder::reconstructExpression() const { if( m_op == "" ) return m_lhs.empty() ? m_data.capturedExpression : m_op + m_lhs; else if( m_op == "matches" ) @@ -99,4 +99,4 @@ namespace Catch { } // end namespace Catch -#endif // TWOBLUECUBES_CATCH_RESULTINFO_BUILDER_HPP_INCLUDED +#endif // TWOBLUECUBES_CATCH_ASSERTIONRESULT_BUILDER_HPP_INCLUDED diff --git a/include/internal/catch_runner_impl.hpp b/include/internal/catch_runner_impl.hpp index ef446c3a..4c7f19ad 100644 --- a/include/internal/catch_runner_impl.hpp +++ b/include/internal/catch_runner_impl.hpp @@ -140,7 +140,7 @@ namespace Catch { return actOnCurrentResult(); } - virtual ResultAction::Value acceptExpression( const ResultInfoBuilder& resultInfo ) { + virtual ResultAction::Value acceptExpression( const AssertionResultBuilder& resultInfo ) { m_currentResult = resultInfo; return actOnCurrentResult(); } @@ -149,7 +149,7 @@ namespace Catch { m_currentResult.setMessage( msg ); } - virtual void testEnded( const ResultInfo& result ) { + virtual void testEnded( const AssertionResult& result ) { if( result.getResultType() == ResultWas::Ok ) { m_totals.assertions.passed++; } @@ -163,8 +163,8 @@ namespace Catch { m_reporter->Result( (*it)->getInfo() ); } { - std::vector::const_iterator it = m_info.begin(); - std::vector::const_iterator itEnd = m_info.end(); + std::vector::const_iterator it = m_info.begin(); + std::vector::const_iterator itEnd = m_info.end(); for(; it != itEnd; ++it ) m_reporter->Result( *it ); } @@ -229,7 +229,7 @@ namespace Catch { : ""; } - virtual const ResultInfo* getLastResult() const { + virtual const AssertionResult* getLastResult() const { return &m_lastResult; } @@ -245,7 +245,7 @@ namespace Catch { m_lastResult = m_currentResult.build(); testEnded( m_lastResult ); - m_currentResult = ResultInfoBuilder(); + m_currentResult = AssertionResultBuilder(); ResultAction::Value action = ResultAction::None; @@ -293,14 +293,14 @@ namespace Catch { private: IMutableContext& m_context; RunningTest* m_runningTest; - ResultInfoBuilder m_currentResult; - ResultInfo m_lastResult; + AssertionResultBuilder m_currentResult; + AssertionResult m_lastResult; const Config& m_config; Totals m_totals; Ptr m_reporter; std::vector m_scopedInfos; - std::vector m_info; + std::vector m_info; IRunner* m_prevRunner; IResultCapture* m_prevResultCapture; const IConfig* m_prevConfig; diff --git a/include/reporters/catch_reporter_basic.hpp b/include/reporters/catch_reporter_basic.hpp index 2729510c..8a09606a 100644 --- a/include/reporters/catch_reporter_basic.hpp +++ b/include/reporters/catch_reporter_basic.hpp @@ -159,7 +159,7 @@ namespace Catch { m_sectionSpans.pop_back(); } - virtual void Result( const ResultInfo& resultInfo ) { + virtual void Result( const AssertionResult& resultInfo ) { if( !m_config.includeSuccessfulResults && resultInfo.getResultType() == ResultWas::Ok ) return; diff --git a/include/reporters/catch_reporter_junit.hpp b/include/reporters/catch_reporter_junit.hpp index 4e66dddf..8e35e279 100644 --- a/include/reporters/catch_reporter_junit.hpp +++ b/include/reporters/catch_reporter_junit.hpp @@ -97,7 +97,7 @@ namespace Catch { m_currentStats->m_testCaseStats.push_back( TestCaseStats( testInfo.getName() ) ); } - virtual void Result( const Catch::ResultInfo& resultInfo ) { + virtual void Result( const Catch::AssertionResult& resultInfo ) { if( resultInfo.getResultType() != ResultWas::Ok || m_config.includeSuccessfulResults ) { TestCaseStats& testCaseStats = m_currentStats->m_testCaseStats.back(); TestStats stats; diff --git a/include/reporters/catch_reporter_xml.hpp b/include/reporters/catch_reporter_xml.hpp index 8329b95d..d74b591b 100644 --- a/include/reporters/catch_reporter_xml.hpp +++ b/include/reporters/catch_reporter_xml.hpp @@ -75,7 +75,7 @@ namespace Catch { m_currentTestSuccess = true; } - virtual void Result( const Catch::ResultInfo& resultInfo ) { + virtual void Result( const Catch::AssertionResult& resultInfo ) { if( !m_config.includeSuccessfulResults && resultInfo.getResultType() == ResultWas::Ok ) return; diff --git a/projects/SelfTest/catch_self_test.cpp b/projects/SelfTest/catch_self_test.cpp index 7e910cd4..58c064c6 100644 --- a/projects/SelfTest/catch_self_test.cpp +++ b/projects/SelfTest/catch_self_test.cpp @@ -31,7 +31,7 @@ namespace Catch{ return totals; } - void MockReporter::Result( const ResultInfo& resultInfo ) { + void MockReporter::Result( const AssertionResult& resultInfo ) { if( resultInfo.getResultType() == ResultWas::Ok ) return; diff --git a/projects/SelfTest/catch_self_test.hpp b/projects/SelfTest/catch_self_test.hpp index 93ba26ee..c0f9a271 100644 --- a/projects/SelfTest/catch_self_test.hpp +++ b/projects/SelfTest/catch_self_test.hpp @@ -95,7 +95,7 @@ namespace Catch { closeLabel( recordTestCases, testInfo.getName() ); } - virtual void Result( const ResultInfo& resultInfo ); + virtual void Result( const AssertionResult& resultInfo ); private: