mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Renamed ResultInfo -> AssertionResult
This commit is contained in:
parent
175da3ef64
commit
d16955f63a
@ -35,8 +35,8 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultInfo getInfo () const {
|
AssertionResult getInfo () const {
|
||||||
return ResultInfoBuilder()
|
return AssertionResultBuilder()
|
||||||
.setResultType( ResultWas::Info )
|
.setResultType( ResultWas::Info )
|
||||||
.setMessage( m_oss.str() )
|
.setMessage( m_oss.str() )
|
||||||
.setMacroName( "SCOPED_INFO" )
|
.setMacroName( "SCOPED_INFO" )
|
||||||
|
@ -18,50 +18,50 @@ class Expression {
|
|||||||
void operator = ( const Expression& );
|
void operator = ( const Expression& );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Expression( ResultInfoBuilder& result, T lhs )
|
Expression( AssertionResultBuilder& result, T lhs )
|
||||||
: m_result( result.setLhs( Catch::toString( lhs ) ) ),
|
: m_result( result.setLhs( Catch::toString( lhs ) ) ),
|
||||||
m_lhs( lhs )
|
m_lhs( lhs )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template<typename RhsT>
|
template<typename RhsT>
|
||||||
ResultInfoBuilder& operator == ( const RhsT& rhs ) {
|
AssertionResultBuilder& operator == ( const RhsT& rhs ) {
|
||||||
return captureExpression<Internal::IsEqualTo>( rhs );
|
return captureExpression<Internal::IsEqualTo>( rhs );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename RhsT>
|
template<typename RhsT>
|
||||||
ResultInfoBuilder& operator != ( const RhsT& rhs ) {
|
AssertionResultBuilder& operator != ( const RhsT& rhs ) {
|
||||||
return captureExpression<Internal::IsNotEqualTo>( rhs );
|
return captureExpression<Internal::IsNotEqualTo>( rhs );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename RhsT>
|
template<typename RhsT>
|
||||||
ResultInfoBuilder& operator < ( const RhsT& rhs ) {
|
AssertionResultBuilder& operator < ( const RhsT& rhs ) {
|
||||||
return captureExpression<Internal::IsLessThan>( rhs );
|
return captureExpression<Internal::IsLessThan>( rhs );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename RhsT>
|
template<typename RhsT>
|
||||||
ResultInfoBuilder& operator > ( const RhsT& rhs ) {
|
AssertionResultBuilder& operator > ( const RhsT& rhs ) {
|
||||||
return captureExpression<Internal::IsGreaterThan>( rhs );
|
return captureExpression<Internal::IsGreaterThan>( rhs );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename RhsT>
|
template<typename RhsT>
|
||||||
ResultInfoBuilder& operator <= ( const RhsT& rhs ) {
|
AssertionResultBuilder& operator <= ( const RhsT& rhs ) {
|
||||||
return captureExpression<Internal::IsLessThanOrEqualTo>( rhs );
|
return captureExpression<Internal::IsLessThanOrEqualTo>( rhs );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename RhsT>
|
template<typename RhsT>
|
||||||
ResultInfoBuilder& operator >= ( const RhsT& rhs ) {
|
AssertionResultBuilder& operator >= ( const RhsT& rhs ) {
|
||||||
return captureExpression<Internal::IsGreaterThanOrEqualTo>( rhs );
|
return captureExpression<Internal::IsGreaterThanOrEqualTo>( rhs );
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultInfoBuilder& operator == ( bool rhs ) {
|
AssertionResultBuilder& operator == ( bool rhs ) {
|
||||||
return captureExpression<Internal::IsEqualTo>( rhs );
|
return captureExpression<Internal::IsEqualTo>( rhs );
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultInfoBuilder& operator != ( bool rhs ) {
|
AssertionResultBuilder& operator != ( bool rhs ) {
|
||||||
return captureExpression<Internal::IsNotEqualTo>( rhs );
|
return captureExpression<Internal::IsNotEqualTo>( rhs );
|
||||||
}
|
}
|
||||||
|
|
||||||
operator ResultInfoBuilder& () {
|
operator AssertionResultBuilder& () {
|
||||||
return m_result.setResultType( m_lhs ? ResultWas::Ok : ResultWas::ExpressionFailed );
|
return m_result.setResultType( m_lhs ? ResultWas::Ok : ResultWas::ExpressionFailed );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
template<Internal::Operator Op, typename RhsT>
|
template<Internal::Operator Op, typename RhsT>
|
||||||
ResultInfoBuilder& captureExpression( const RhsT& rhs ) {
|
AssertionResultBuilder& captureExpression( const RhsT& rhs ) {
|
||||||
return m_result
|
return m_result
|
||||||
.setResultType( Internal::compare<Op>( m_lhs, rhs ) ? ResultWas::Ok : ResultWas::ExpressionFailed )
|
.setResultType( Internal::compare<Op>( m_lhs, rhs ) ? ResultWas::Ok : ResultWas::ExpressionFailed )
|
||||||
.setRhs( Catch::toString( rhs ) )
|
.setRhs( Catch::toString( rhs ) )
|
||||||
@ -81,7 +81,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ResultInfoBuilder& m_result;
|
AssertionResultBuilder& m_result;
|
||||||
T m_lhs;
|
T m_lhs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -87,13 +87,13 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
operator ResultInfoBuilder&() {
|
operator AssertionResultBuilder&() {
|
||||||
m_result.setMessage( m_messageStream.str() );
|
m_result.setMessage( m_messageStream.str() );
|
||||||
return m_result;
|
return m_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ResultInfoBuilder m_result;
|
AssertionResultBuilder m_result;
|
||||||
std::ostringstream m_messageStream;
|
std::ostringstream m_messageStream;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -17,14 +17,14 @@ namespace Catch {
|
|||||||
|
|
||||||
class TestCaseInfo;
|
class TestCaseInfo;
|
||||||
class ScopedInfo;
|
class ScopedInfo;
|
||||||
class ResultInfoBuilder;
|
class AssertionResultBuilder;
|
||||||
class ResultInfo;
|
class AssertionResult;
|
||||||
|
|
||||||
struct IResultCapture {
|
struct IResultCapture {
|
||||||
|
|
||||||
virtual ~IResultCapture();
|
virtual ~IResultCapture();
|
||||||
|
|
||||||
virtual void testEnded( const ResultInfo& result ) = 0;
|
virtual void testEnded( const AssertionResult& result ) = 0;
|
||||||
virtual bool sectionStarted( const std::string& name,
|
virtual bool sectionStarted( const std::string& name,
|
||||||
const std::string& description,
|
const std::string& description,
|
||||||
const SourceLineInfo& lineInfo,
|
const SourceLineInfo& lineInfo,
|
||||||
@ -36,11 +36,11 @@ namespace Catch {
|
|||||||
|
|
||||||
virtual ResultAction::Value acceptResult( bool result ) = 0;
|
virtual ResultAction::Value acceptResult( bool result ) = 0;
|
||||||
virtual ResultAction::Value acceptResult( ResultWas::OfType 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 void acceptMessage( const std::string& msg ) = 0;
|
||||||
|
|
||||||
virtual std::string getCurrentTestName() const = 0;
|
virtual std::string getCurrentTestName() const = 0;
|
||||||
virtual const ResultInfo* getLastResult() const = 0;
|
virtual const AssertionResult* getLastResult() const = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,23 +49,37 @@ namespace Catch
|
|||||||
};
|
};
|
||||||
|
|
||||||
class TestCaseInfo;
|
class TestCaseInfo;
|
||||||
class ResultInfo;
|
class AssertionResult;
|
||||||
|
|
||||||
struct IReporter : IShared {
|
struct IReporter : IShared {
|
||||||
virtual ~IReporter();
|
virtual ~IReporter();
|
||||||
virtual bool shouldRedirectStdout() const = 0;
|
|
||||||
|
virtual bool shouldRedirectStdout() const = 0;
|
||||||
|
|
||||||
virtual void StartTesting() = 0;
|
virtual void StartTesting() = 0;
|
||||||
virtual void EndTesting( const Totals& totals ) = 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 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;
|
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 NoAssertionsInSection( const std::string& sectionName ) = 0;
|
||||||
virtual void NoAssertionsInTestCase( const std::string& testName ) = 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 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 {
|
struct IReporterFactory {
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
* 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)
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*/
|
*/
|
||||||
#ifndef TWOBLUECUBES_CATCH_RESULTINFO_H_INCLUDED
|
#ifndef TWOBLUECUBES_CATCH_ASSERTIONRESULT_H_INCLUDED
|
||||||
#define TWOBLUECUBES_CATCH_RESULTINFO_H_INCLUDED
|
#define TWOBLUECUBES_CATCH_ASSERTIONRESULT_H_INCLUDED
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "catch_result_type.h"
|
#include "catch_result_type.h"
|
||||||
@ -25,11 +25,11 @@ namespace Catch {
|
|||||||
ResultWas::OfType resultType;
|
ResultWas::OfType resultType;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ResultInfo {
|
class AssertionResult {
|
||||||
public:
|
public:
|
||||||
ResultInfo();
|
AssertionResult();
|
||||||
ResultInfo( const ResultData& data );
|
AssertionResult( const ResultData& data );
|
||||||
~ResultInfo();
|
~AssertionResult();
|
||||||
|
|
||||||
bool ok() const;
|
bool ok() const;
|
||||||
ResultWas::OfType getResultType() const;
|
ResultWas::OfType getResultType() const;
|
||||||
@ -49,4 +49,4 @@ namespace Catch {
|
|||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_RESULTINFO_H_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_ASSERTIONRESULT_H_INCLUDED
|
||||||
|
@ -5,63 +5,63 @@
|
|||||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
* 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)
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*/
|
*/
|
||||||
#ifndef TWOBLUECUBES_CATCH_RESULTINFO_HPP_INCLUDED
|
#ifndef TWOBLUECUBES_CATCH_ASSERTIONRESULT_HPP_INCLUDED
|
||||||
#define TWOBLUECUBES_CATCH_RESULTINFO_HPP_INCLUDED
|
#define TWOBLUECUBES_CATCH_ASSERTIONRESULT_HPP_INCLUDED
|
||||||
|
|
||||||
#include "catch_resultinfo.h"
|
#include "catch_resultinfo.h"
|
||||||
|
|
||||||
namespace Catch {
|
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 );
|
return isOk( m_data.resultType );
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultWas::OfType ResultInfo::getResultType() const {
|
ResultWas::OfType AssertionResult::getResultType() const {
|
||||||
return m_data.resultType;
|
return m_data.resultType;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ResultInfo::hasExpression() const {
|
bool AssertionResult::hasExpression() const {
|
||||||
return !m_data.capturedExpression.empty();
|
return !m_data.capturedExpression.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ResultInfo::hasMessage() const {
|
bool AssertionResult::hasMessage() const {
|
||||||
return !m_data.message.empty();
|
return !m_data.message.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ResultInfo::getExpression() const {
|
std::string AssertionResult::getExpression() const {
|
||||||
return m_data.capturedExpression;
|
return m_data.capturedExpression;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ResultInfo::hasExpandedExpression() const {
|
bool AssertionResult::hasExpandedExpression() const {
|
||||||
return hasExpression() && getExpandedExpression() != getExpression();
|
return hasExpression() && getExpandedExpression() != getExpression();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ResultInfo::getExpandedExpression() const {
|
std::string AssertionResult::getExpandedExpression() const {
|
||||||
return m_data.reconstructedExpression;
|
return m_data.reconstructedExpression;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ResultInfo::getMessage() const {
|
std::string AssertionResult::getMessage() const {
|
||||||
return m_data.message;
|
return m_data.message;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ResultInfo::getFilename() const {
|
std::string AssertionResult::getFilename() const {
|
||||||
return m_data.lineInfo.file;
|
return m_data.lineInfo.file;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t ResultInfo::getLine() const {
|
std::size_t AssertionResult::getLine() const {
|
||||||
return m_data.lineInfo.line;
|
return m_data.lineInfo.line;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ResultInfo::getTestMacroName() const {
|
std::string AssertionResult::getTestMacroName() const {
|
||||||
return m_data.macroName;
|
return m_data.macroName;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_RESULTINFO_HPP_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_ASSERTIONRESULT_HPP_INCLUDED
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
* 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)
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*/
|
*/
|
||||||
#ifndef TWOBLUECUBES_CATCH_RESULTINFO_BUILDER_H_INCLUDED
|
#ifndef TWOBLUECUBES_CATCH_ASSERTIONRESULT_BUILDER_H_INCLUDED
|
||||||
#define TWOBLUECUBES_CATCH_RESULTINFO_BUILDER_H_INCLUDED
|
#define TWOBLUECUBES_CATCH_ASSERTIONRESULT_BUILDER_H_INCLUDED
|
||||||
|
|
||||||
#include "catch_tostring.hpp"
|
#include "catch_tostring.hpp"
|
||||||
#include "catch_resultinfo.h"
|
#include "catch_resultinfo.h"
|
||||||
@ -18,24 +18,24 @@ namespace Catch {
|
|||||||
|
|
||||||
struct STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison;
|
struct STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison;
|
||||||
|
|
||||||
class ResultInfoBuilder {
|
class AssertionResultBuilder {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ResultInfoBuilder();
|
AssertionResultBuilder();
|
||||||
|
|
||||||
ResultInfoBuilder& setResultType( ResultWas::OfType result );
|
AssertionResultBuilder& setResultType( ResultWas::OfType result );
|
||||||
ResultInfoBuilder& setCapturedExpression( const std::string& capturedExpression );
|
AssertionResultBuilder& setCapturedExpression( const std::string& capturedExpression );
|
||||||
ResultInfoBuilder& setIsFalse( bool isFalse );
|
AssertionResultBuilder& setIsFalse( bool isFalse );
|
||||||
ResultInfoBuilder& setMessage( const std::string& message );
|
AssertionResultBuilder& setMessage( const std::string& message );
|
||||||
ResultInfoBuilder& setLineInfo( const SourceLineInfo& lineInfo );
|
AssertionResultBuilder& setLineInfo( const SourceLineInfo& lineInfo );
|
||||||
ResultInfoBuilder& setLhs( const std::string& lhs );
|
AssertionResultBuilder& setLhs( const std::string& lhs );
|
||||||
ResultInfoBuilder& setRhs( const std::string& rhs );
|
AssertionResultBuilder& setRhs( const std::string& rhs );
|
||||||
ResultInfoBuilder& setOp( const std::string& op );
|
AssertionResultBuilder& setOp( const std::string& op );
|
||||||
ResultInfoBuilder& setMacroName( const std::string& macroName );
|
AssertionResultBuilder& setMacroName( const std::string& macroName );
|
||||||
|
|
||||||
std::string reconstructExpression() const;
|
std::string reconstructExpression() const;
|
||||||
|
|
||||||
ResultInfo build() const;
|
AssertionResult build() const;
|
||||||
|
|
||||||
// Disable attempts to use || and && in expressions (without parantheses)
|
// Disable attempts to use || and && in expressions (without parantheses)
|
||||||
template<typename RhsT>
|
template<typename RhsT>
|
||||||
@ -55,4 +55,4 @@ private:
|
|||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_RESULTINFO_BUILDER_H_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_ASSERTIONRESULT_BUILDER_H_INCLUDED
|
||||||
|
@ -5,16 +5,16 @@
|
|||||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
* 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)
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*/
|
*/
|
||||||
#ifndef TWOBLUECUBES_CATCH_RESULTINFO_BUILDER_HPP_INCLUDED
|
#ifndef TWOBLUECUBES_CATCH_ASSERTIONRESULT_BUILDER_HPP_INCLUDED
|
||||||
#define TWOBLUECUBES_CATCH_RESULTINFO_BUILDER_HPP_INCLUDED
|
#define TWOBLUECUBES_CATCH_ASSERTIONRESULT_BUILDER_HPP_INCLUDED
|
||||||
|
|
||||||
#include "catch_resultinfo_builder.h"
|
#include "catch_resultinfo_builder.h"
|
||||||
|
|
||||||
namespace Catch {
|
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
|
// Flip bool results if isFalse is set
|
||||||
if( m_isFalse && result == ResultWas::Ok )
|
if( m_isFalse && result == ResultWas::Ok )
|
||||||
m_data.resultType = ResultWas::ExpressionFailed;
|
m_data.resultType = ResultWas::ExpressionFailed;
|
||||||
@ -24,46 +24,46 @@ namespace Catch {
|
|||||||
m_data.resultType = result;
|
m_data.resultType = result;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
ResultInfoBuilder& ResultInfoBuilder::setCapturedExpression( const std::string& capturedExpression ) {
|
AssertionResultBuilder& AssertionResultBuilder::setCapturedExpression( const std::string& capturedExpression ) {
|
||||||
m_data.capturedExpression = capturedExpression;
|
m_data.capturedExpression = capturedExpression;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
ResultInfoBuilder& ResultInfoBuilder::setIsFalse( bool isFalse ) {
|
AssertionResultBuilder& AssertionResultBuilder::setIsFalse( bool isFalse ) {
|
||||||
m_isFalse = isFalse;
|
m_isFalse = isFalse;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultInfoBuilder& ResultInfoBuilder::setMessage( const std::string& message ) {
|
AssertionResultBuilder& AssertionResultBuilder::setMessage( const std::string& message ) {
|
||||||
m_data.message = message;
|
m_data.message = message;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultInfoBuilder& ResultInfoBuilder::setLineInfo( const SourceLineInfo& lineInfo ) {
|
AssertionResultBuilder& AssertionResultBuilder::setLineInfo( const SourceLineInfo& lineInfo ) {
|
||||||
m_data.lineInfo = lineInfo;
|
m_data.lineInfo = lineInfo;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultInfoBuilder& ResultInfoBuilder::setMacroName( const std::string& macroName ) {
|
AssertionResultBuilder& AssertionResultBuilder::setMacroName( const std::string& macroName ) {
|
||||||
m_data.macroName = macroName;
|
m_data.macroName = macroName;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultInfoBuilder& ResultInfoBuilder::setLhs( const std::string& lhs ) {
|
AssertionResultBuilder& AssertionResultBuilder::setLhs( const std::string& lhs ) {
|
||||||
m_lhs = lhs;
|
m_lhs = lhs;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultInfoBuilder& ResultInfoBuilder::setRhs( const std::string& rhs ) {
|
AssertionResultBuilder& AssertionResultBuilder::setRhs( const std::string& rhs ) {
|
||||||
m_rhs = rhs;
|
m_rhs = rhs;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultInfoBuilder& ResultInfoBuilder::setOp( const std::string& op ) {
|
AssertionResultBuilder& AssertionResultBuilder::setOp( const std::string& op ) {
|
||||||
m_op = op;
|
m_op = op;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultInfo ResultInfoBuilder::build() const
|
AssertionResult AssertionResultBuilder::build() const
|
||||||
{
|
{
|
||||||
ResultData data = m_data;
|
ResultData data = m_data;
|
||||||
data.reconstructedExpression = reconstructExpression();
|
data.reconstructedExpression = reconstructExpression();
|
||||||
@ -77,10 +77,10 @@ namespace Catch {
|
|||||||
data.reconstructedExpression = "!(" + data.reconstructedExpression + ")";
|
data.reconstructedExpression = "!(" + data.reconstructedExpression + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ResultInfo( data );
|
return AssertionResult( data );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ResultInfoBuilder::reconstructExpression() const {
|
std::string AssertionResultBuilder::reconstructExpression() const {
|
||||||
if( m_op == "" )
|
if( m_op == "" )
|
||||||
return m_lhs.empty() ? m_data.capturedExpression : m_op + m_lhs;
|
return m_lhs.empty() ? m_data.capturedExpression : m_op + m_lhs;
|
||||||
else if( m_op == "matches" )
|
else if( m_op == "matches" )
|
||||||
@ -99,4 +99,4 @@ namespace Catch {
|
|||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_RESULTINFO_BUILDER_HPP_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_ASSERTIONRESULT_BUILDER_HPP_INCLUDED
|
||||||
|
@ -140,7 +140,7 @@ namespace Catch {
|
|||||||
return actOnCurrentResult();
|
return actOnCurrentResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ResultAction::Value acceptExpression( const ResultInfoBuilder& resultInfo ) {
|
virtual ResultAction::Value acceptExpression( const AssertionResultBuilder& resultInfo ) {
|
||||||
m_currentResult = resultInfo;
|
m_currentResult = resultInfo;
|
||||||
return actOnCurrentResult();
|
return actOnCurrentResult();
|
||||||
}
|
}
|
||||||
@ -149,7 +149,7 @@ namespace Catch {
|
|||||||
m_currentResult.setMessage( msg );
|
m_currentResult.setMessage( msg );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void testEnded( const ResultInfo& result ) {
|
virtual void testEnded( const AssertionResult& result ) {
|
||||||
if( result.getResultType() == ResultWas::Ok ) {
|
if( result.getResultType() == ResultWas::Ok ) {
|
||||||
m_totals.assertions.passed++;
|
m_totals.assertions.passed++;
|
||||||
}
|
}
|
||||||
@ -163,8 +163,8 @@ namespace Catch {
|
|||||||
m_reporter->Result( (*it)->getInfo() );
|
m_reporter->Result( (*it)->getInfo() );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::vector<ResultInfo>::const_iterator it = m_info.begin();
|
std::vector<AssertionResult>::const_iterator it = m_info.begin();
|
||||||
std::vector<ResultInfo>::const_iterator itEnd = m_info.end();
|
std::vector<AssertionResult>::const_iterator itEnd = m_info.end();
|
||||||
for(; it != itEnd; ++it )
|
for(; it != itEnd; ++it )
|
||||||
m_reporter->Result( *it );
|
m_reporter->Result( *it );
|
||||||
}
|
}
|
||||||
@ -229,7 +229,7 @@ namespace Catch {
|
|||||||
: "";
|
: "";
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual const ResultInfo* getLastResult() const {
|
virtual const AssertionResult* getLastResult() const {
|
||||||
return &m_lastResult;
|
return &m_lastResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,7 +245,7 @@ namespace Catch {
|
|||||||
m_lastResult = m_currentResult.build();
|
m_lastResult = m_currentResult.build();
|
||||||
testEnded( m_lastResult );
|
testEnded( m_lastResult );
|
||||||
|
|
||||||
m_currentResult = ResultInfoBuilder();
|
m_currentResult = AssertionResultBuilder();
|
||||||
|
|
||||||
ResultAction::Value action = ResultAction::None;
|
ResultAction::Value action = ResultAction::None;
|
||||||
|
|
||||||
@ -293,14 +293,14 @@ namespace Catch {
|
|||||||
private:
|
private:
|
||||||
IMutableContext& m_context;
|
IMutableContext& m_context;
|
||||||
RunningTest* m_runningTest;
|
RunningTest* m_runningTest;
|
||||||
ResultInfoBuilder m_currentResult;
|
AssertionResultBuilder m_currentResult;
|
||||||
ResultInfo m_lastResult;
|
AssertionResult m_lastResult;
|
||||||
|
|
||||||
const Config& m_config;
|
const Config& m_config;
|
||||||
Totals m_totals;
|
Totals m_totals;
|
||||||
Ptr<IReporter> m_reporter;
|
Ptr<IReporter> m_reporter;
|
||||||
std::vector<ScopedInfo*> m_scopedInfos;
|
std::vector<ScopedInfo*> m_scopedInfos;
|
||||||
std::vector<ResultInfo> m_info;
|
std::vector<AssertionResult> m_info;
|
||||||
IRunner* m_prevRunner;
|
IRunner* m_prevRunner;
|
||||||
IResultCapture* m_prevResultCapture;
|
IResultCapture* m_prevResultCapture;
|
||||||
const IConfig* m_prevConfig;
|
const IConfig* m_prevConfig;
|
||||||
|
@ -159,7 +159,7 @@ namespace Catch {
|
|||||||
m_sectionSpans.pop_back();
|
m_sectionSpans.pop_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Result( const ResultInfo& resultInfo ) {
|
virtual void Result( const AssertionResult& resultInfo ) {
|
||||||
if( !m_config.includeSuccessfulResults && resultInfo.getResultType() == ResultWas::Ok )
|
if( !m_config.includeSuccessfulResults && resultInfo.getResultType() == ResultWas::Ok )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ namespace Catch {
|
|||||||
m_currentStats->m_testCaseStats.push_back( TestCaseStats( testInfo.getName() ) );
|
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 ) {
|
if( resultInfo.getResultType() != ResultWas::Ok || m_config.includeSuccessfulResults ) {
|
||||||
TestCaseStats& testCaseStats = m_currentStats->m_testCaseStats.back();
|
TestCaseStats& testCaseStats = m_currentStats->m_testCaseStats.back();
|
||||||
TestStats stats;
|
TestStats stats;
|
||||||
|
@ -75,7 +75,7 @@ namespace Catch {
|
|||||||
m_currentTestSuccess = true;
|
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 )
|
if( !m_config.includeSuccessfulResults && resultInfo.getResultType() == ResultWas::Ok )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ namespace Catch{
|
|||||||
return totals;
|
return totals;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MockReporter::Result( const ResultInfo& resultInfo ) {
|
void MockReporter::Result( const AssertionResult& resultInfo ) {
|
||||||
if( resultInfo.getResultType() == ResultWas::Ok )
|
if( resultInfo.getResultType() == ResultWas::Ok )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ namespace Catch {
|
|||||||
closeLabel( recordTestCases, testInfo.getName() );
|
closeLabel( recordTestCases, testInfo.getName() );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Result( const ResultInfo& resultInfo );
|
virtual void Result( const AssertionResult& resultInfo );
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user