ResultInfo -> AssertionResult filenames and variables

This commit is contained in:
Phil Nash
2012-10-16 08:31:05 +01:00
parent d16955f63a
commit c597a893fa
15 changed files with 74 additions and 74 deletions

View File

@@ -8,7 +8,7 @@
#ifndef TWOBLUECUBES_CATCH_ASSERTIONRESULT_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_ASSERTIONRESULT_HPP_INCLUDED
#include "catch_resultinfo.h"
#include "catch_assertionresult.h"
namespace Catch {

View File

@@ -9,7 +9,7 @@
#define TWOBLUECUBES_CATCH_ASSERTIONRESULT_BUILDER_H_INCLUDED
#include "catch_tostring.hpp"
#include "catch_resultinfo.h"
#include "catch_assertionresult.h"
#include "catch_result_type.h"
#include "catch_evaluate.hpp"
#include "catch_common.h"

View File

@@ -8,7 +8,7 @@
#ifndef TWOBLUECUBES_CATCH_ASSERTIONRESULT_BUILDER_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_ASSERTIONRESULT_BUILDER_HPP_INCLUDED
#include "catch_resultinfo_builder.h"
#include "catch_assertionresult_builder.h"
namespace Catch {

View File

@@ -8,7 +8,7 @@
#ifndef TWOBLUECUBES_CATCH_EXPRESSION_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_EXPRESSION_HPP_INCLUDED
#include "catch_resultinfo_builder.h"
#include "catch_assertionresult_builder.h"
#include "catch_evaluate.hpp"
namespace Catch {

View File

@@ -9,9 +9,9 @@
#define TWOBLUECUBES_CATCH_EXPRESSION_BUILDER_HPP_INCLUDED
#include "catch_expression.hpp"
#include "catch_resultinfo_builder.h"
#include "catch_assertionresult_builder.h"
#include "catch_tostring.hpp"
#include "catch_resultinfo.h"
#include "catch_assertionresult.h"
#include "catch_result_type.h"
#include "catch_context.h"
#include "catch_common.h"

View File

@@ -22,8 +22,8 @@
#include "catch_context_impl.hpp"
#include "catch_console_colour_impl.hpp"
#include "catch_generators_impl.hpp"
#include "catch_resultinfo.hpp"
#include "catch_resultinfo_builder.hpp"
#include "catch_assertionresult.hpp"
#include "catch_assertionresult_builder.hpp"
#include "catch_test_case_info.hpp"
#include "catch_tags.hpp"

View File

@@ -36,7 +36,7 @@ namespace Catch {
virtual ResultAction::Value acceptResult( bool result ) = 0;
virtual ResultAction::Value acceptResult( ResultWas::OfType result ) = 0;
virtual ResultAction::Value acceptExpression( const AssertionResultBuilder& resultInfo ) = 0;
virtual ResultAction::Value acceptExpression( const AssertionResultBuilder& assertionResult ) = 0;
virtual void acceptMessage( const std::string& msg ) = 0;
virtual std::string getCurrentTestName() const = 0;

View File

@@ -140,8 +140,8 @@ namespace Catch {
return actOnCurrentResult();
}
virtual ResultAction::Value acceptExpression( const AssertionResultBuilder& resultInfo ) {
m_currentResult = resultInfo;
virtual ResultAction::Value acceptExpression( const AssertionResultBuilder& assertionResult ) {
m_currentResult = assertionResult;
return actOnCurrentResult();
}

View File

@@ -159,21 +159,21 @@ namespace Catch {
m_sectionSpans.pop_back();
}
virtual void Result( const AssertionResult& resultInfo ) {
if( !m_config.includeSuccessfulResults && resultInfo.getResultType() == ResultWas::Ok )
virtual void Result( const AssertionResult& assertionResult ) {
if( !m_config.includeSuccessfulResults && assertionResult.getResultType() == ResultWas::Ok )
return;
startSpansLazily();
if( !resultInfo.getFilename().empty() ) {
if( !assertionResult.getFilename().empty() ) {
TextColour colour( TextColour::FileName );
m_config.stream << SourceLineInfo( resultInfo.getFilename(), resultInfo.getLine() );
m_config.stream << SourceLineInfo( assertionResult.getFilename(), assertionResult.getLine() );
}
if( resultInfo.hasExpression() ) {
if( assertionResult.hasExpression() ) {
TextColour colour( TextColour::OriginalExpression );
m_config.stream << resultInfo.getExpression();
if( resultInfo.ok() ) {
m_config.stream << assertionResult.getExpression();
if( assertionResult.ok() ) {
TextColour successColour( TextColour::Success );
m_config.stream << " succeeded";
}
@@ -182,36 +182,36 @@ namespace Catch {
m_config.stream << " failed";
}
}
switch( resultInfo.getResultType() ) {
switch( assertionResult.getResultType() ) {
case ResultWas::ThrewException:
{
TextColour colour( TextColour::Error );
if( resultInfo.hasExpression() )
if( assertionResult.hasExpression() )
m_config.stream << " with unexpected";
else
m_config.stream << "Unexpected";
m_config.stream << " exception with message: '" << resultInfo.getMessage() << "'";
m_config.stream << " exception with message: '" << assertionResult.getMessage() << "'";
}
break;
case ResultWas::DidntThrowException:
{
TextColour colour( TextColour::Error );
if( resultInfo.hasExpression() )
if( assertionResult.hasExpression() )
m_config.stream << " because no exception was thrown where one was expected";
else
m_config.stream << "No exception thrown where one was expected";
}
break;
case ResultWas::Info:
streamVariableLengthText( "info", resultInfo.getMessage() );
streamVariableLengthText( "info", assertionResult.getMessage() );
break;
case ResultWas::Warning:
m_config.stream << "warning:\n'" << resultInfo.getMessage() << "'";
m_config.stream << "warning:\n'" << assertionResult.getMessage() << "'";
break;
case ResultWas::ExplicitFailure:
{
TextColour colour( TextColour::Error );
m_config.stream << "failed with message: '" << resultInfo.getMessage() << "'";
m_config.stream << "failed with message: '" << assertionResult.getMessage() << "'";
}
break;
case ResultWas::Unknown: // These cases are here to prevent compiler warnings
@@ -219,8 +219,8 @@ namespace Catch {
case ResultWas::FailureBit:
case ResultWas::ExpressionFailed:
case ResultWas::Exception:
if( !resultInfo.hasExpression() ) {
if( resultInfo.ok() ) {
if( !assertionResult.hasExpression() ) {
if( assertionResult.ok() ) {
TextColour colour( TextColour::Success );
m_config.stream << " succeeded";
}
@@ -232,14 +232,14 @@ namespace Catch {
break;
}
if( resultInfo.hasExpandedExpression() ) {
if( assertionResult.hasExpandedExpression() ) {
m_config.stream << " for: ";
if( resultInfo.getExpandedExpression().size() > 40 )
if( assertionResult.getExpandedExpression().size() > 40 )
m_config.stream << "\n";
if( resultInfo.getExpandedExpression().size() < 70 )
if( assertionResult.getExpandedExpression().size() < 70 )
m_config.stream << "\t";
TextColour colour( TextColour::ReconstructedExpression );
m_config.stream << resultInfo.getExpandedExpression();
m_config.stream << assertionResult.getExpandedExpression();
}
m_config.stream << std::endl;
}

View File

@@ -97,19 +97,19 @@ namespace Catch {
m_currentStats->m_testCaseStats.push_back( TestCaseStats( testInfo.getName() ) );
}
virtual void Result( const Catch::AssertionResult& resultInfo ) {
if( resultInfo.getResultType() != ResultWas::Ok || m_config.includeSuccessfulResults ) {
virtual void Result( const Catch::AssertionResult& assertionResult ) {
if( assertionResult.getResultType() != ResultWas::Ok || m_config.includeSuccessfulResults ) {
TestCaseStats& testCaseStats = m_currentStats->m_testCaseStats.back();
TestStats stats;
std::ostringstream oss;
if( !resultInfo.getMessage().empty() )
oss << resultInfo.getMessage() << " at ";
oss << SourceLineInfo( resultInfo.getFilename(), resultInfo.getLine() );
if( !assertionResult.getMessage().empty() )
oss << assertionResult.getMessage() << " at ";
oss << SourceLineInfo( assertionResult.getFilename(), assertionResult.getLine() );
stats.m_content = oss.str();
stats.m_message = resultInfo.getExpandedExpression();
stats.m_resultType = resultInfo.getTestMacroName();
stats.m_message = assertionResult.getExpandedExpression();
stats.m_resultType = assertionResult.getTestMacroName();
switch( resultInfo.getResultType() ) {
switch( assertionResult.getResultType() ) {
case ResultWas::ThrewException:
stats.m_element = "error";
m_currentStats->m_errorsCount++;

View File

@@ -75,42 +75,42 @@ namespace Catch {
m_currentTestSuccess = true;
}
virtual void Result( const Catch::AssertionResult& resultInfo ) {
if( !m_config.includeSuccessfulResults && resultInfo.getResultType() == ResultWas::Ok )
virtual void Result( const Catch::AssertionResult& assertionResult ) {
if( !m_config.includeSuccessfulResults && assertionResult.getResultType() == ResultWas::Ok )
return;
if( resultInfo.hasExpression() ) {
if( assertionResult.hasExpression() ) {
m_xml.startElement( "Expression" )
.writeAttribute( "success", resultInfo.ok() )
.writeAttribute( "filename", resultInfo.getFilename() )
.writeAttribute( "line", resultInfo.getLine() );
.writeAttribute( "success", assertionResult.ok() )
.writeAttribute( "filename", assertionResult.getFilename() )
.writeAttribute( "line", assertionResult.getLine() );
m_xml.scopedElement( "Original" )
.writeText( resultInfo.getExpression() );
.writeText( assertionResult.getExpression() );
m_xml.scopedElement( "Expanded" )
.writeText( resultInfo.getExpandedExpression() );
m_currentTestSuccess &= resultInfo.ok();
.writeText( assertionResult.getExpandedExpression() );
m_currentTestSuccess &= assertionResult.ok();
}
switch( resultInfo.getResultType() ) {
switch( assertionResult.getResultType() ) {
case ResultWas::ThrewException:
m_xml.scopedElement( "Exception" )
.writeAttribute( "filename", resultInfo.getFilename() )
.writeAttribute( "line", resultInfo.getLine() )
.writeText( resultInfo.getMessage() );
.writeAttribute( "filename", assertionResult.getFilename() )
.writeAttribute( "line", assertionResult.getLine() )
.writeText( assertionResult.getMessage() );
m_currentTestSuccess = false;
break;
case ResultWas::Info:
m_xml.scopedElement( "Info" )
.writeText( resultInfo.getMessage() );
.writeText( assertionResult.getMessage() );
break;
case ResultWas::Warning:
m_xml.scopedElement( "Warning" )
.writeText( resultInfo.getMessage() );
.writeText( assertionResult.getMessage() );
break;
case ResultWas::ExplicitFailure:
m_xml.scopedElement( "Failure" )
.writeText( resultInfo.getMessage() );
.writeText( assertionResult.getMessage() );
m_currentTestSuccess = false;
break;
case ResultWas::Unknown:
@@ -121,7 +121,7 @@ namespace Catch {
case ResultWas::DidntThrowException:
break;
}
if( resultInfo.hasExpression() )
if( assertionResult.hasExpression() )
m_xml.endElement();
}