mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-29 16:53:30 +01:00
parent
28d3881ff9
commit
8a52a39fdc
@ -1,6 +1,6 @@
|
|||||||
![catch logo](catch-logo-small.png)
|
![catch logo](catch-logo-small.png)
|
||||||
|
|
||||||
*v1.0 build 5 (master branch)*
|
*v1.0 build 6 (master branch)*
|
||||||
|
|
||||||
# New release with significant changes
|
# New release with significant changes
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
// These numbers are maintained by a script
|
// These numbers are maintained by a script
|
||||||
Version libraryVersion( 1, 0, 5, "master" );
|
Version libraryVersion( 1, 0, 6, "master" );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* CATCH v1.0 build 5 (master branch)
|
* CATCH v1.0 build 6 (master branch)
|
||||||
* Generated: 2013-07-05 08:38:07.926803
|
* Generated: 2013-07-25 08:10:27.710799
|
||||||
* ----------------------------------------------------------
|
* ----------------------------------------------------------
|
||||||
* This file has been merged from multiple headers. Please don't edit it directly
|
* This file has been merged from multiple headers. Please don't edit it directly
|
||||||
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
|
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
|
||||||
@ -2248,12 +2248,18 @@ namespace Catch {
|
|||||||
nullableValue = new( storage ) T( *_other );
|
nullableValue = new( storage ) T( *_other );
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
Option& operator = ( T const& _value ) {
|
||||||
|
reset();
|
||||||
|
nullableValue = new( storage ) T( _value );
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
void reset() {
|
void reset() {
|
||||||
if( nullableValue )
|
if( nullableValue )
|
||||||
nullableValue->~T();
|
nullableValue->~T();
|
||||||
nullableValue = NULL;
|
nullableValue = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
T& operator*() { return *nullableValue; }
|
T& operator*() { return *nullableValue; }
|
||||||
T const& operator*() const { return *nullableValue; }
|
T const& operator*() const { return *nullableValue; }
|
||||||
T* operator->() { return nullableValue; }
|
T* operator->() { return nullableValue; }
|
||||||
@ -4549,214 +4555,143 @@ namespace Catch {
|
|||||||
// #included from: internal/catch_runner_impl.hpp
|
// #included from: internal/catch_runner_impl.hpp
|
||||||
#define TWOBLUECUBES_CATCH_RUNNER_IMPL_HPP_INCLUDED
|
#define TWOBLUECUBES_CATCH_RUNNER_IMPL_HPP_INCLUDED
|
||||||
|
|
||||||
// #included from: catch_running_test.hpp
|
// #included from: catch_test_case_tracker.hpp
|
||||||
#define TWOBLUECUBES_CATCH_RUNNING_TEST_HPP_INCLUDED
|
#define TWOBLUECUBES_CATCH_TEST_CASE_TRACKER_HPP_INCLUDED
|
||||||
|
|
||||||
// #included from: catch_section_info.hpp
|
|
||||||
#define TWOBLUECUBES_CATCH_SECTION_INFO_HPP_INCLUDED
|
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
namespace SectionTracking {
|
||||||
|
|
||||||
|
class TrackedSection {
|
||||||
|
|
||||||
|
typedef std::map<std::string, TrackedSection> TrackedSections;
|
||||||
|
|
||||||
class RunningSection {
|
|
||||||
public:
|
public:
|
||||||
|
enum RunState {
|
||||||
typedef std::vector<RunningSection*> SubSections;
|
NotStarted,
|
||||||
|
Executing,
|
||||||
enum State {
|
ExecutingChildren,
|
||||||
Root,
|
Completed
|
||||||
Unknown,
|
|
||||||
Branch,
|
|
||||||
TestedBranch,
|
|
||||||
TestedLeaf
|
|
||||||
};
|
};
|
||||||
|
|
||||||
RunningSection( RunningSection* parent, std::string const& name )
|
TrackedSection( std::string const& name, TrackedSection* parent )
|
||||||
: m_state( Unknown ),
|
: m_name( name ), m_runState( NotStarted ), m_parent( parent )
|
||||||
m_parent( parent ),
|
|
||||||
m_name( name )
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
RunningSection( std::string const& name )
|
RunState runState() const { return m_runState; }
|
||||||
: m_state( Root ),
|
|
||||||
m_parent( NULL ),
|
|
||||||
m_name( name )
|
|
||||||
{}
|
|
||||||
|
|
||||||
~RunningSection() {
|
void addChild( std::string const& childName ) {
|
||||||
deleteAll( m_subSections );
|
m_children.insert( std::make_pair( childName, TrackedSection( childName, this ) ) );
|
||||||
|
}
|
||||||
|
TrackedSection* getChild( std::string const& childName ) {
|
||||||
|
return &m_children.find( childName )->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getName() const {
|
void enter() {
|
||||||
return m_name;
|
if( m_runState == NotStarted )
|
||||||
|
m_runState = Executing;
|
||||||
}
|
}
|
||||||
|
void leave() {
|
||||||
bool shouldRun() const {
|
for( TrackedSections::const_iterator it = m_children.begin(), itEnd = m_children.end();
|
||||||
return m_state < TestedBranch;
|
it != itEnd;
|
||||||
|
++it )
|
||||||
|
if( it->second.runState() != Completed ) {
|
||||||
|
m_runState = ExecutingChildren;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
m_runState = Completed;
|
||||||
bool isBranch() const {
|
|
||||||
return m_state == Branch;
|
|
||||||
}
|
}
|
||||||
|
TrackedSection* getParent() {
|
||||||
const RunningSection* getParent() const {
|
|
||||||
return m_parent;
|
return m_parent;
|
||||||
}
|
}
|
||||||
|
bool hasChildren() const {
|
||||||
bool hasUntestedSections() const {
|
return !m_children.empty();
|
||||||
if( m_state == Unknown )
|
|
||||||
return true;
|
|
||||||
for( SubSections::const_iterator it = m_subSections.begin();
|
|
||||||
it != m_subSections.end();
|
|
||||||
++it)
|
|
||||||
if( (*it)->hasUntestedSections() )
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mutable methods:
|
|
||||||
|
|
||||||
RunningSection* getParent() {
|
|
||||||
return m_parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
RunningSection* findOrAddSubSection( std::string const& name, bool& changed ) {
|
|
||||||
for( SubSections::const_iterator it = m_subSections.begin();
|
|
||||||
it != m_subSections.end();
|
|
||||||
++it)
|
|
||||||
if( (*it)->getName() == name )
|
|
||||||
return *it;
|
|
||||||
RunningSection* subSection = new RunningSection( this, name );
|
|
||||||
m_subSections.push_back( subSection );
|
|
||||||
m_state = Branch;
|
|
||||||
changed = true;
|
|
||||||
return subSection;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ran() {
|
|
||||||
if( m_state >= Branch )
|
|
||||||
return false;
|
|
||||||
m_state = TestedLeaf;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ranToCompletion() {
|
|
||||||
if( m_state == Branch && !hasUntestedSections() )
|
|
||||||
m_state = TestedBranch;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
State m_state;
|
|
||||||
RunningSection* m_parent;
|
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
SubSections m_subSections;
|
RunState m_runState;
|
||||||
};
|
TrackedSections m_children;
|
||||||
}
|
TrackedSection* m_parent;
|
||||||
|
|
||||||
namespace Catch {
|
|
||||||
|
|
||||||
class RunningTest {
|
|
||||||
|
|
||||||
enum RunStatus {
|
|
||||||
NothingRun,
|
|
||||||
EncounteredASection,
|
|
||||||
RanAtLeastOneSection,
|
|
||||||
RanToCompletionWithSections,
|
|
||||||
RanToCompletionWithNoSections
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class TestCaseTracker {
|
||||||
public:
|
public:
|
||||||
explicit RunningTest( TestCase const& info )
|
TestCaseTracker( std::string const& testCaseName )
|
||||||
: m_info( info ),
|
: m_testCase( testCaseName, NULL ),
|
||||||
m_runStatus( RanAtLeastOneSection ),
|
m_currentSection( &m_testCase ),
|
||||||
m_rootSection( info.getTestCaseInfo().name ),
|
m_completedASectionThisRun( false )
|
||||||
m_currentSection( &m_rootSection ),
|
|
||||||
m_changed( false )
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool wasSectionSeen() const {
|
bool enterSection( std::string const& name ) {
|
||||||
return m_runStatus == RanAtLeastOneSection ||
|
if( m_completedASectionThisRun )
|
||||||
m_runStatus == RanToCompletionWithSections;
|
return false;
|
||||||
|
if( m_currentSection->runState() == TrackedSection::Executing ) {
|
||||||
|
m_currentSection->addChild( name );
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
bool isBranchSection() const {
|
TrackedSection* child = m_currentSection->getChild( name );
|
||||||
return m_currentSection &&
|
if( child->runState() != TrackedSection::Completed ) {
|
||||||
m_currentSection->isBranch();
|
m_currentSection = child;
|
||||||
}
|
m_currentSection->enter();
|
||||||
|
|
||||||
bool hasSections() const {
|
|
||||||
return m_runStatus == RanAtLeastOneSection ||
|
|
||||||
m_runStatus == RanToCompletionWithSections ||
|
|
||||||
m_runStatus == EncounteredASection;
|
|
||||||
}
|
|
||||||
|
|
||||||
void reset() {
|
|
||||||
m_runStatus = NothingRun;
|
|
||||||
m_changed = false;
|
|
||||||
m_lastSectionToRun = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ranToCompletion() {
|
|
||||||
if( m_runStatus != RanAtLeastOneSection && m_runStatus != EncounteredASection )
|
|
||||||
m_runStatus = RanToCompletionWithNoSections;
|
|
||||||
m_runStatus = RanToCompletionWithSections;
|
|
||||||
if( m_lastSectionToRun ) {
|
|
||||||
m_lastSectionToRun->ranToCompletion();
|
|
||||||
m_changed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool addSection( std::string const& name ) {
|
|
||||||
if( m_runStatus == NothingRun )
|
|
||||||
m_runStatus = EncounteredASection;
|
|
||||||
|
|
||||||
RunningSection* thisSection = m_currentSection->findOrAddSubSection( name, m_changed );
|
|
||||||
|
|
||||||
if( !wasSectionSeen() && thisSection->shouldRun() ) {
|
|
||||||
m_currentSection = thisSection;
|
|
||||||
m_lastSectionToRun = NULL;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void endSection( std::string const&, bool stealth ) {
|
|
||||||
if( m_currentSection->ran() ) {
|
|
||||||
if( !stealth )
|
|
||||||
m_runStatus = RanAtLeastOneSection;
|
|
||||||
m_changed = true;
|
|
||||||
}
|
|
||||||
else if( m_runStatus == EncounteredASection ) {
|
|
||||||
if( !stealth )
|
|
||||||
m_runStatus = RanAtLeastOneSection;
|
|
||||||
m_lastSectionToRun = m_currentSection;
|
|
||||||
}
|
}
|
||||||
|
void leaveSection() {
|
||||||
|
m_currentSection->leave();
|
||||||
m_currentSection = m_currentSection->getParent();
|
m_currentSection = m_currentSection->getParent();
|
||||||
|
assert( m_currentSection != NULL );
|
||||||
|
m_completedASectionThisRun = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
TestCase const& getTestCase() const {
|
bool currentSectionHasChildren() const {
|
||||||
return m_info;
|
return m_currentSection->hasChildren();
|
||||||
|
}
|
||||||
|
bool isCompleted() const {
|
||||||
|
return m_testCase.runState() == TrackedSection::Completed;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasUntestedSections() const {
|
class Guard {
|
||||||
return m_runStatus == RanAtLeastOneSection ||
|
public:
|
||||||
( m_rootSection.hasUntestedSections() && m_changed );
|
Guard( TestCaseTracker& tracker )
|
||||||
|
: m_tracker( tracker )
|
||||||
|
{
|
||||||
|
m_tracker.enterTestCase();
|
||||||
}
|
}
|
||||||
|
~Guard() {
|
||||||
|
m_tracker.leaveTestCase();
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
TestCaseTracker& m_tracker;
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RunningTest( RunningTest const& );
|
void enterTestCase() {
|
||||||
void operator=( RunningTest const& );
|
m_currentSection = &m_testCase;
|
||||||
|
m_completedASectionThisRun = false;
|
||||||
TestCase const& m_info;
|
m_testCase.enter();
|
||||||
RunStatus m_runStatus;
|
|
||||||
RunningSection m_rootSection;
|
|
||||||
RunningSection* m_currentSection;
|
|
||||||
RunningSection* m_lastSectionToRun;
|
|
||||||
bool m_changed;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
void leaveTestCase() {
|
||||||
|
m_testCase.leave();
|
||||||
|
}
|
||||||
|
|
||||||
|
TrackedSection m_testCase;
|
||||||
|
TrackedSection* m_currentSection;
|
||||||
|
bool m_completedASectionThisRun;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace SectionTracking
|
||||||
|
|
||||||
|
using SectionTracking::TestCaseTracker;
|
||||||
|
|
||||||
|
} // namespace Catch
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -4798,7 +4733,7 @@ namespace Catch {
|
|||||||
explicit RunContext( Ptr<IConfig const> const& config, Ptr<IStreamingReporter> const& reporter )
|
explicit RunContext( Ptr<IConfig const> const& config, Ptr<IStreamingReporter> const& reporter )
|
||||||
: m_runInfo( config->name() ),
|
: m_runInfo( config->name() ),
|
||||||
m_context( getCurrentMutableContext() ),
|
m_context( getCurrentMutableContext() ),
|
||||||
m_runningTest( NULL ),
|
m_activeTestCase( NULL ),
|
||||||
m_config( config ),
|
m_config( config ),
|
||||||
m_reporter( reporter ),
|
m_reporter( reporter ),
|
||||||
m_prevRunner( &m_context.getRunner() ),
|
m_prevRunner( &m_context.getRunner() ),
|
||||||
@ -4853,13 +4788,14 @@ namespace Catch {
|
|||||||
|
|
||||||
m_reporter->testCaseStarting( testInfo );
|
m_reporter->testCaseStarting( testInfo );
|
||||||
|
|
||||||
m_runningTest = new RunningTest( testCase );
|
m_activeTestCase = &testCase;
|
||||||
|
m_testCaseTracker = TestCaseTracker( testInfo.name );
|
||||||
|
|
||||||
do {
|
do {
|
||||||
do {
|
do {
|
||||||
runCurrentTest( redirectedCout, redirectedCerr );
|
runCurrentTest( redirectedCout, redirectedCerr );
|
||||||
}
|
}
|
||||||
while( m_runningTest->hasUntestedSections() && !aborting() );
|
while( !m_testCaseTracker->isCompleted() && !aborting() );
|
||||||
}
|
}
|
||||||
while( getCurrentContext().advanceGeneratorsForCurrentTest() && !aborting() );
|
while( getCurrentContext().advanceGeneratorsForCurrentTest() && !aborting() );
|
||||||
|
|
||||||
@ -4880,8 +4816,8 @@ namespace Catch {
|
|||||||
missingAssertions,
|
missingAssertions,
|
||||||
aborting() ) );
|
aborting() ) );
|
||||||
|
|
||||||
delete m_runningTest;
|
m_activeTestCase = NULL;
|
||||||
m_runningTest = NULL;
|
m_testCaseTracker.reset();
|
||||||
|
|
||||||
return deltaTotals;
|
return deltaTotals;
|
||||||
}
|
}
|
||||||
@ -4920,7 +4856,7 @@ namespace Catch {
|
|||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << sectionInfo.name << "@" << sectionInfo.lineInfo;
|
oss << sectionInfo.name << "@" << sectionInfo.lineInfo;
|
||||||
|
|
||||||
if( !m_runningTest->addSection( oss.str() ) )
|
if( !m_testCaseTracker->enterSection( oss.str() ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_lastAssertionInfo.lineInfo = sectionInfo.lineInfo;
|
m_lastAssertionInfo.lineInfo = sectionInfo.lineInfo;
|
||||||
@ -4942,13 +4878,13 @@ namespace Catch {
|
|||||||
bool missingAssertions = false;
|
bool missingAssertions = false;
|
||||||
if( assertions.total() == 0 &&
|
if( assertions.total() == 0 &&
|
||||||
m_config->warnAboutMissingAssertions() &&
|
m_config->warnAboutMissingAssertions() &&
|
||||||
!m_runningTest->isBranchSection() ) {
|
!m_testCaseTracker->currentSectionHasChildren() ) {
|
||||||
m_totals.assertions.failed++;
|
m_totals.assertions.failed++;
|
||||||
assertions.failed++;
|
assertions.failed++;
|
||||||
missingAssertions = true;
|
missingAssertions = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
m_runningTest->endSection( info.name, false );
|
m_testCaseTracker->leaveSection();
|
||||||
|
|
||||||
m_reporter->sectionEnded( SectionStats( info, assertions, missingAssertions ) );
|
m_reporter->sectionEnded( SectionStats( info, assertions, missingAssertions ) );
|
||||||
m_messages.clear();
|
m_messages.clear();
|
||||||
@ -4967,8 +4903,8 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual std::string getCurrentTestName() const {
|
virtual std::string getCurrentTestName() const {
|
||||||
return m_runningTest
|
return m_activeTestCase
|
||||||
? m_runningTest->getTestCase().getTestCaseInfo().name
|
? m_activeTestCase->getTestCaseInfo().name
|
||||||
: "";
|
: "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5001,19 +4937,21 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void runCurrentTest( std::string& redirectedCout, std::string& redirectedCerr ) {
|
void runCurrentTest( std::string& redirectedCout, std::string& redirectedCerr ) {
|
||||||
|
TestCaseInfo const& testCaseInfo = m_activeTestCase->getTestCaseInfo();
|
||||||
|
SectionInfo testCaseSection( testCaseInfo.name, testCaseInfo.description, testCaseInfo.lineInfo );
|
||||||
|
m_reporter->sectionStarting( testCaseSection );
|
||||||
try {
|
try {
|
||||||
m_lastAssertionInfo = AssertionInfo( "TEST_CASE", m_runningTest->getTestCase().getTestCaseInfo().lineInfo, "", ResultDisposition::Normal );
|
m_lastAssertionInfo = AssertionInfo( "TEST_CASE", testCaseInfo.lineInfo, "", ResultDisposition::Normal );
|
||||||
m_runningTest->reset();
|
TestCaseTracker::Guard guard( *m_testCaseTracker );
|
||||||
|
|
||||||
if( m_reporter->getPreferences().shouldRedirectStdOut ) {
|
if( m_reporter->getPreferences().shouldRedirectStdOut ) {
|
||||||
StreamRedirect coutRedir( std::cout, redirectedCout );
|
StreamRedirect coutRedir( std::cout, redirectedCout );
|
||||||
StreamRedirect cerrRedir( std::cerr, redirectedCerr );
|
StreamRedirect cerrRedir( std::cerr, redirectedCerr );
|
||||||
m_runningTest->getTestCase().invoke();
|
m_activeTestCase->invoke();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_runningTest->getTestCase().invoke();
|
m_activeTestCase->invoke();
|
||||||
}
|
}
|
||||||
m_runningTest->ranToCompletion();
|
|
||||||
}
|
}
|
||||||
catch( TestFailureException& ) {
|
catch( TestFailureException& ) {
|
||||||
// This just means the test was aborted due to failure
|
// This just means the test was aborted due to failure
|
||||||
@ -5023,6 +4961,8 @@ namespace Catch {
|
|||||||
exResult << translateActiveException();
|
exResult << translateActiveException();
|
||||||
actOnCurrentResult( exResult.buildResult( m_lastAssertionInfo ) );
|
actOnCurrentResult( exResult.buildResult( m_lastAssertionInfo ) );
|
||||||
}
|
}
|
||||||
|
// If sections ended prematurely due to an exception we stored their
|
||||||
|
// infos here so we can tear them down outside the unwind process.
|
||||||
for( std::vector<UnfinishedSections>::const_iterator it = m_unfinishedSections.begin(),
|
for( std::vector<UnfinishedSections>::const_iterator it = m_unfinishedSections.begin(),
|
||||||
itEnd = m_unfinishedSections.end();
|
itEnd = m_unfinishedSections.end();
|
||||||
it != itEnd;
|
it != itEnd;
|
||||||
@ -5030,6 +4970,8 @@ namespace Catch {
|
|||||||
sectionEnded( it->info, it->prevAssertions );
|
sectionEnded( it->info, it->prevAssertions );
|
||||||
m_unfinishedSections.clear();
|
m_unfinishedSections.clear();
|
||||||
m_messages.clear();
|
m_messages.clear();
|
||||||
|
SectionStats testCaseSectionStats( testCaseSection, Counts(), 0 ); // !TBD
|
||||||
|
m_reporter->sectionEnded( testCaseSectionStats );
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -5044,7 +4986,8 @@ namespace Catch {
|
|||||||
|
|
||||||
TestRunInfo m_runInfo;
|
TestRunInfo m_runInfo;
|
||||||
IMutableContext& m_context;
|
IMutableContext& m_context;
|
||||||
RunningTest* m_runningTest;
|
TestCase const* m_activeTestCase;
|
||||||
|
Option<TestCaseTracker> m_testCaseTracker;
|
||||||
AssertionResult m_lastResult;
|
AssertionResult m_lastResult;
|
||||||
|
|
||||||
Ptr<IConfig const> m_config;
|
Ptr<IConfig const> m_config;
|
||||||
@ -6236,7 +6179,7 @@ namespace Catch {
|
|||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
// These numbers are maintained by a script
|
// These numbers are maintained by a script
|
||||||
Version libraryVersion( 1, 0, 5, "master" );
|
Version libraryVersion( 1, 0, 6, "master" );
|
||||||
}
|
}
|
||||||
|
|
||||||
// #included from: catch_text.hpp
|
// #included from: catch_text.hpp
|
||||||
@ -7070,7 +7013,7 @@ namespace Catch {
|
|||||||
namespace Catch {
|
namespace Catch {
|
||||||
class XmlReporter : public SharedImpl<IReporter> {
|
class XmlReporter : public SharedImpl<IReporter> {
|
||||||
public:
|
public:
|
||||||
XmlReporter( ReporterConfig const& config ) : m_config( config ) {}
|
XmlReporter( ReporterConfig const& config ) : m_config( config ), m_sectionDepth( 0 ) {}
|
||||||
|
|
||||||
static std::string getDescription() {
|
static std::string getDescription() {
|
||||||
return "Reports test results as an XML document";
|
return "Reports test results as an XML document";
|
||||||
@ -7110,19 +7053,23 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual void StartSection( const std::string& sectionName, const std::string& description ) {
|
virtual void StartSection( const std::string& sectionName, const std::string& description ) {
|
||||||
|
if( m_sectionDepth++ > 0 ) {
|
||||||
m_xml.startElement( "Section" )
|
m_xml.startElement( "Section" )
|
||||||
.writeAttribute( "name", sectionName )
|
.writeAttribute( "name", sectionName )
|
||||||
.writeAttribute( "description", description );
|
.writeAttribute( "description", description );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
virtual void NoAssertionsInSection( const std::string& ) {}
|
virtual void NoAssertionsInSection( const std::string& ) {}
|
||||||
virtual void NoAssertionsInTestCase( const std::string& ) {}
|
virtual void NoAssertionsInTestCase( const std::string& ) {}
|
||||||
|
|
||||||
virtual void EndSection( const std::string& /*sectionName*/, const Counts& assertions ) {
|
virtual void EndSection( const std::string& /*sectionName*/, const Counts& assertions ) {
|
||||||
|
if( --m_sectionDepth > 0 ) {
|
||||||
m_xml.scopedElement( "OverallResults" )
|
m_xml.scopedElement( "OverallResults" )
|
||||||
.writeAttribute( "successes", assertions.passed )
|
.writeAttribute( "successes", assertions.passed )
|
||||||
.writeAttribute( "failures", assertions.failed );
|
.writeAttribute( "failures", assertions.failed );
|
||||||
m_xml.endElement();
|
m_xml.endElement();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
virtual void StartTestCase( const Catch::TestCaseInfo& testInfo ) {
|
virtual void StartTestCase( const Catch::TestCaseInfo& testInfo ) {
|
||||||
m_xml.startElement( "TestCase" ).writeAttribute( "name", testInfo.name );
|
m_xml.startElement( "TestCase" ).writeAttribute( "name", testInfo.name );
|
||||||
@ -7192,6 +7139,7 @@ namespace Catch {
|
|||||||
ReporterConfig m_config;
|
ReporterConfig m_config;
|
||||||
bool m_currentTestSuccess;
|
bool m_currentTestSuccess;
|
||||||
XmlWriter m_xml;
|
XmlWriter m_xml;
|
||||||
|
int m_sectionDepth;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
@ -7696,12 +7644,10 @@ namespace Catch {
|
|||||||
sections.push_back( section );
|
sections.push_back( section );
|
||||||
|
|
||||||
// Sections
|
// Sections
|
||||||
if( !sections.empty() ) {
|
std::vector<ThreadedSectionInfo*>::const_reverse_iterator
|
||||||
typedef std::vector<ThreadedSectionInfo*>::const_reverse_iterator It;
|
it = sections.rbegin(), itEnd = sections.rend();
|
||||||
for( It it = sections.rbegin(), itEnd = sections.rend(); it != itEnd; ++it )
|
for( ++it; it != itEnd; ++it ) // Skip first section (test case)
|
||||||
printHeaderString( (*it)->name, 2 );
|
printHeaderString( (*it)->name, 2 );
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
SourceLineInfo lineInfo = currentSectionInfo
|
SourceLineInfo lineInfo = currentSectionInfo
|
||||||
? currentSectionInfo->lineInfo
|
? currentSectionInfo->lineInfo
|
||||||
|
Loading…
Reference in New Issue
Block a user