mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Started refactoring ResultInfo/Builder
This commit is contained in:
parent
4104fb735e
commit
36d0da0194
@ -36,7 +36,10 @@ public:
|
||||
}
|
||||
|
||||
ResultInfo getInfo () const {
|
||||
return ResultInfo( "", ResultWas::Info, false, SourceLineInfo(), "SCOPED_INFO", m_oss.str().c_str() );
|
||||
return ResultInfoBuilder()
|
||||
.setResultType( ResultWas::Info )
|
||||
.setMessage( m_oss.str() )
|
||||
.setMacroName( "SCOPED_INFO" );
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -16,12 +16,6 @@ namespace Catch {
|
||||
class ResultInfo {
|
||||
public:
|
||||
ResultInfo();
|
||||
ResultInfo( const char* expr,
|
||||
ResultWas::OfType result,
|
||||
bool isNot,
|
||||
const SourceLineInfo& lineInfo,
|
||||
const char* macroName,
|
||||
const char* message );
|
||||
~ResultInfo();
|
||||
|
||||
bool ok() const;
|
||||
@ -37,6 +31,12 @@ namespace Catch {
|
||||
std::string getTestMacroName() const;
|
||||
|
||||
protected:
|
||||
ResultInfo( const char* expr,
|
||||
ResultWas::OfType result,
|
||||
bool isNot,
|
||||
const SourceLineInfo& lineInfo,
|
||||
const char* macroName,
|
||||
const char* message );
|
||||
|
||||
std::string getExpandedExpressionInternal() const;
|
||||
bool isNotExpression( const char* expr );
|
||||
|
@ -19,23 +19,17 @@ namespace Catch {
|
||||
struct STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison;
|
||||
|
||||
class ResultInfoBuilder : public ResultInfo {
|
||||
|
||||
public:
|
||||
|
||||
ResultInfoBuilder();
|
||||
|
||||
ResultInfoBuilder( const char* expr,
|
||||
bool isNot,
|
||||
const SourceLineInfo& lineInfo,
|
||||
const char* macroName,
|
||||
const char* message = "" );
|
||||
|
||||
void setResultType( ResultWas::OfType result );
|
||||
void setMessage( const std::string& message );
|
||||
void setLineInfo( const SourceLineInfo& lineInfo );
|
||||
void setLhs( const std::string& lhs );
|
||||
void setRhs( const std::string& rhs );
|
||||
void setOp( const std::string& op );
|
||||
ResultInfoBuilder& setResultType( ResultWas::OfType result );
|
||||
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 );
|
||||
|
||||
template<typename RhsT>
|
||||
STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator || ( const RhsT& );
|
||||
@ -44,6 +38,12 @@ public:
|
||||
STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator && ( const RhsT& );
|
||||
|
||||
private:
|
||||
|
||||
ResultInfoBuilder( const char* expr,
|
||||
bool isNot,
|
||||
const SourceLineInfo& lineInfo,
|
||||
const char* macroName );
|
||||
|
||||
friend class ExpressionBuilder;
|
||||
template<typename T> friend class Expression;
|
||||
|
||||
|
@ -12,17 +12,16 @@
|
||||
|
||||
namespace Catch {
|
||||
|
||||
ResultInfoBuilder::ResultInfoBuilder() {}
|
||||
|
||||
ResultInfoBuilder::ResultInfoBuilder( const char* expr,
|
||||
bool isNot,
|
||||
const SourceLineInfo& lineInfo,
|
||||
const char* macroName,
|
||||
const char* message )
|
||||
: ResultInfo( expr, ResultWas::Unknown, isNot, lineInfo, macroName, message )
|
||||
const char* macroName )
|
||||
: ResultInfo( expr, ResultWas::Unknown, isNot, lineInfo, macroName, "" )
|
||||
{}
|
||||
|
||||
void ResultInfoBuilder::setResultType( ResultWas::OfType result ) {
|
||||
ResultInfoBuilder::ResultInfoBuilder() {}
|
||||
|
||||
ResultInfoBuilder& ResultInfoBuilder::setResultType( ResultWas::OfType result ) {
|
||||
// Flip bool results if isNot is set
|
||||
if( m_isNot && result == ResultWas::Ok )
|
||||
m_result = ResultWas::ExpressionFailed;
|
||||
@ -30,26 +29,37 @@ namespace Catch {
|
||||
m_result = ResultWas::Ok;
|
||||
else
|
||||
m_result = result;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void ResultInfoBuilder::setMessage( const std::string& message ) {
|
||||
ResultInfoBuilder& ResultInfoBuilder::setMessage( const std::string& message ) {
|
||||
m_message = message;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void ResultInfoBuilder::setLineInfo( const SourceLineInfo& lineInfo ) {
|
||||
ResultInfoBuilder& ResultInfoBuilder::setLineInfo( const SourceLineInfo& lineInfo ) {
|
||||
m_lineInfo = lineInfo;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void ResultInfoBuilder::setLhs( const std::string& lhs ) {
|
||||
ResultInfoBuilder& ResultInfoBuilder::setLhs( const std::string& lhs ) {
|
||||
m_lhs = lhs;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void ResultInfoBuilder::setRhs( const std::string& rhs ) {
|
||||
ResultInfoBuilder& ResultInfoBuilder::setRhs( const std::string& rhs ) {
|
||||
m_rhs = rhs;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void ResultInfoBuilder::setOp( const std::string& op ) {
|
||||
ResultInfoBuilder& ResultInfoBuilder::setOp( const std::string& op ) {
|
||||
m_op = op;
|
||||
return *this;
|
||||
}
|
||||
|
||||
ResultInfoBuilder& ResultInfoBuilder::setMacroName( const std::string& macroName ) {
|
||||
m_macroName = macroName;
|
||||
return *this;
|
||||
}
|
||||
|
||||
ResultInfoBuilder& ResultInfoBuilder::captureBoolExpression( bool result ) {
|
||||
|
Loading…
Reference in New Issue
Block a user