mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-23 03:43:28 +01:00
ResultInfo -> AssertionResult filenames and variables
This commit is contained in:
parent
d16955f63a
commit
c597a893fa
@ -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 {
|
||||
|
@ -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"
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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++;
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -31,11 +31,11 @@ namespace Catch{
|
||||
return totals;
|
||||
}
|
||||
|
||||
void MockReporter::Result( const AssertionResult& resultInfo ) {
|
||||
if( resultInfo.getResultType() == ResultWas::Ok )
|
||||
void MockReporter::Result( const AssertionResult& assertionResult ) {
|
||||
if( assertionResult.getResultType() == ResultWas::Ok )
|
||||
return;
|
||||
|
||||
switch( resultInfo.getResultType() ) {
|
||||
switch( assertionResult.getResultType() ) {
|
||||
case ResultWas::Info:
|
||||
m_log << "Info";
|
||||
break;
|
||||
@ -70,14 +70,14 @@ namespace Catch{
|
||||
break;
|
||||
}
|
||||
|
||||
if( resultInfo.hasExpression() )
|
||||
m_log << resultInfo.getExpression();
|
||||
if( assertionResult.hasExpression() )
|
||||
m_log << assertionResult.getExpression();
|
||||
|
||||
if( resultInfo.hasMessage() )
|
||||
m_log << "'" << resultInfo.getMessage() << "'";
|
||||
if( assertionResult.hasMessage() )
|
||||
m_log << "'" << assertionResult.getMessage() << "'";
|
||||
|
||||
if( resultInfo.hasExpandedExpression() )
|
||||
m_log << resultInfo.getExpandedExpression();
|
||||
if( assertionResult.hasExpandedExpression() )
|
||||
m_log << assertionResult.getExpandedExpression();
|
||||
}
|
||||
|
||||
void MockReporter::openLabel( const std::string& label, const std::string& arg ) {
|
||||
|
@ -95,7 +95,7 @@ namespace Catch {
|
||||
closeLabel( recordTestCases, testInfo.getName() );
|
||||
}
|
||||
|
||||
virtual void Result( const AssertionResult& resultInfo );
|
||||
virtual void Result( const AssertionResult& assertionResult );
|
||||
|
||||
|
||||
private:
|
||||
|
@ -105,7 +105,7 @@
|
||||
4A6D0C5A149B3E3D00DB3EAA /* catch_reporter_registrars.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_reporter_registrars.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||
4A6D0C5B149B3E3D00DB3EAA /* catch_reporter_registry.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_reporter_registry.hpp; sourceTree = "<group>"; };
|
||||
4A6D0C5C149B3E3D00DB3EAA /* catch_result_type.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_result_type.h; sourceTree = "<group>"; };
|
||||
4A6D0C5D149B3E3D00DB3EAA /* catch_resultinfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_resultinfo.h; sourceTree = "<group>"; };
|
||||
4A6D0C5D149B3E3D00DB3EAA /* catch_assertionresult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_assertionresult.h; sourceTree = "<group>"; };
|
||||
4A6D0C5E149B3E3D00DB3EAA /* catch_runner_impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_runner_impl.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||
4A6D0C5F149B3E3D00DB3EAA /* catch_section.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_section.hpp; sourceTree = "<group>"; };
|
||||
4A6D0C60149B3E3D00DB3EAA /* catch_stream.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_stream.hpp; sourceTree = "<group>"; };
|
||||
@ -120,10 +120,10 @@
|
||||
4A8E4DCC160A344100194CBD /* catch_tags.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_tags.hpp; sourceTree = "<group>"; };
|
||||
4A8E4DD0160A352200194CBD /* catch_tags.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = catch_tags.cpp; path = ../../../SelfTest/SurrogateCpps/catch_tags.cpp; sourceTree = "<group>"; };
|
||||
4A90B59B15D0F61A00EF71BC /* catch_interfaces_generators.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_interfaces_generators.h; sourceTree = "<group>"; };
|
||||
4A90B59D15D24FE900EF71BC /* catch_resultinfo.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_resultinfo.hpp; sourceTree = "<group>"; };
|
||||
4A90B59E15D2521E00EF71BC /* catch_resultinfo_builder.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_resultinfo_builder.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||
4A90B59D15D24FE900EF71BC /* catch_assertionresult.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_assertionresult.hpp; sourceTree = "<group>"; };
|
||||
4A90B59E15D2521E00EF71BC /* catch_assertionresult_builder.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_assertionresult_builder.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||
4A9D84B11558FC0400FBB209 /* catch_tostring.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_tostring.hpp; sourceTree = "<group>"; };
|
||||
4A9D84B315599AC900FBB209 /* catch_resultinfo_builder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = catch_resultinfo_builder.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
||||
4A9D84B315599AC900FBB209 /* catch_assertionresult_builder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = catch_assertionresult_builder.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
||||
4AA7FF4115F3E89D009AD7F9 /* BDDTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BDDTests.cpp; sourceTree = "<group>"; };
|
||||
4AB1C73514F97BDA00F31DF7 /* catch_console_colour_impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_console_colour_impl.hpp; sourceTree = "<group>"; };
|
||||
4AB1C73714F97C1300F31DF7 /* catch_console_colour.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_console_colour.hpp; sourceTree = "<group>"; };
|
||||
@ -275,8 +275,8 @@
|
||||
4A6D0C62149B3E3D00DB3EAA /* catch_test_case_registry_impl.hpp */,
|
||||
4AB1C73514F97BDA00F31DF7 /* catch_console_colour_impl.hpp */,
|
||||
4A4B0F9B15CEF8C400AE2392 /* catch_notimplemented_exception.hpp */,
|
||||
4A90B59D15D24FE900EF71BC /* catch_resultinfo.hpp */,
|
||||
4A90B59E15D2521E00EF71BC /* catch_resultinfo_builder.hpp */,
|
||||
4A90B59D15D24FE900EF71BC /* catch_assertionresult.hpp */,
|
||||
4A90B59E15D2521E00EF71BC /* catch_assertionresult_builder.hpp */,
|
||||
4A084F1C15DACEEA0027E631 /* catch_test_case_info.hpp */,
|
||||
);
|
||||
name = impl;
|
||||
@ -288,8 +288,8 @@
|
||||
4A6D0C4D149B3E3D00DB3EAA /* catch_evaluate.hpp */,
|
||||
4A6D0C4F149B3E3D00DB3EAA /* catch_generators.hpp */,
|
||||
4A6D0C5C149B3E3D00DB3EAA /* catch_result_type.h */,
|
||||
4A6D0C5D149B3E3D00DB3EAA /* catch_resultinfo.h */,
|
||||
4A9D84B315599AC900FBB209 /* catch_resultinfo_builder.h */,
|
||||
4A6D0C5D149B3E3D00DB3EAA /* catch_assertionresult.h */,
|
||||
4A9D84B315599AC900FBB209 /* catch_assertionresult_builder.h */,
|
||||
4A6D0C5F149B3E3D00DB3EAA /* catch_section.hpp */,
|
||||
4A3D7DD01503869D005F9203 /* catch_matchers.hpp */,
|
||||
4A9D84B11558FC0400FBB209 /* catch_tostring.hpp */,
|
||||
|
Loading…
Reference in New Issue
Block a user