Renamed TestCaseInfo -> TestCase

This commit is contained in:
Phil Nash 2012-11-22 19:17:20 +00:00
parent 37f3820747
commit 06a671a349
21 changed files with 146 additions and 95 deletions

View File

@ -56,8 +56,8 @@ namespace Catch {
Totals runTestsForGroup( Runner& context, const TestCaseFilters& filterGroup ) { Totals runTestsForGroup( Runner& context, const TestCaseFilters& filterGroup ) {
Totals totals; Totals totals;
std::vector<TestCaseInfo>::const_iterator it = getRegistryHub().getTestCaseRegistry().getAllTests().begin(); std::vector<TestCase>::const_iterator it = getRegistryHub().getTestCaseRegistry().getAllTests().begin();
std::vector<TestCaseInfo>::const_iterator itEnd = getRegistryHub().getTestCaseRegistry().getAllTests().end(); std::vector<TestCase>::const_iterator itEnd = getRegistryHub().getTestCaseRegistry().getAllTests().end();
int testsRunForGroup = 0; int testsRunForGroup = 0;
for(; it != itEnd; ++it ) { for(; it != itEnd; ++it ) {
if( filterGroup.shouldInclude( *it ) ) { if( filterGroup.shouldInclude( *it ) ) {
@ -114,7 +114,7 @@ namespace Catch {
const ConfigData& m_config; const ConfigData& m_config;
std::ofstream m_ofs; std::ofstream m_ofs;
Ptr<IReporter> m_reporter; Ptr<IReporter> m_reporter;
std::set<TestCaseInfo> m_testsAlreadyRun; std::set<TestCase> m_testsAlreadyRun;
}; };
inline int Main( Config& configWrapper ) { inline int Main( Config& configWrapper ) {

View File

@ -16,7 +16,7 @@
namespace Catch { namespace Catch {
class TestCaseInfo; class TestCase;
class Stream; class Stream;
struct IResultCapture; struct IResultCapture;
struct IRunner; struct IRunner;

View File

@ -15,7 +15,7 @@
namespace Catch { namespace Catch {
class TestCaseInfo; class TestCase;
class ScopedInfo; class ScopedInfo;
class ExpressionResultBuilder; class ExpressionResultBuilder;
class AssertionResult; class AssertionResult;

View File

@ -15,7 +15,7 @@
namespace Catch { namespace Catch {
class TestCaseInfo; class TestCase;
struct ITestCaseRegistry; struct ITestCaseRegistry;
struct IExceptionTranslatorRegistry; struct IExceptionTranslatorRegistry;
struct IExceptionTranslator; struct IExceptionTranslator;
@ -31,7 +31,7 @@ namespace Catch {
struct IMutableRegistryHub { struct IMutableRegistryHub {
virtual ~IMutableRegistryHub(); virtual ~IMutableRegistryHub();
virtual void registerReporter( const std::string& name, IReporterFactory* factory ) = 0; virtual void registerReporter( const std::string& name, IReporterFactory* factory ) = 0;
virtual void registerTest( const TestCaseInfo& testInfo ) = 0; virtual void registerTest( const TestCase& testInfo ) = 0;
virtual void registerTranslator( const IExceptionTranslator* translator ) = 0; virtual void registerTranslator( const IExceptionTranslator* translator ) = 0;
}; };

View File

@ -12,6 +12,8 @@
#include "catch_totals.hpp" #include "catch_totals.hpp"
#include "catch_ptr.hpp" #include "catch_ptr.hpp"
#include "catch_config.hpp" #include "catch_config.hpp"
#include "catch_test_case_info.h"
#include "catch_assertionresult.h"
#include <string> #include <string>
#include <ostream> #include <ostream>
@ -47,10 +49,54 @@ namespace Catch
private: private:
void operator=(const ReporterConfig&); void operator=(const ReporterConfig&);
}; };
struct AssertionStats {
AssertionInfo assertionInfo;
AssertionResult assertionResult;
Totals totals;
};
struct TestCaseStats {
TestCase testInfo;
Totals totals;
std::string stdOut;
std::string stdErr;
bool aborting;
};
class TestCaseInfo; struct TestGroupStats {
class AssertionResult; std::string groupName;
Totals totals;
bool aborting;
};
struct TestRunStats {
std::string runName;
Totals totals;
bool aborting;
};
// !Work In progress
struct IStreamingReporter : IShared {
virtual void testRunStarting( const std::string& runName ) = 0;
virtual void testGroupStarting( const std::string& groupName ) = 0;
// !TBD: include section info (perhaps TestCase has an isSection flag and/ or a parent pointer
virtual void testCaseStarting( const TestCase& testInfo ) = 0;
virtual void assertionStarting( const AssertionInfo& assertionInfo ) = 0;
virtual void assertionEnding( const AssertionStats& assertionStats ) = 0;
virtual void testCaseEnding( const TestCaseStats& testCaseStats ) = 0;
virtual void testGroupEnding( const TestGroupStats& testGroupStats ) = 0;
virtual void testRunEnding( const TestRunStats& testRunStats ) = 0;
};
// !TBD: Derived helper that implements the streaming interface but holds the stats
// - declares a new interface where methods are called at the end of each event
// - this would be used by the JUnit reporter, for example.
// - it may be used by the basic reporter, too, but that would clear down the stack
// as it goes
struct IReporter : IShared { struct IReporter : IShared {
virtual ~IReporter(); virtual ~IReporter();
@ -62,9 +108,9 @@ namespace Catch
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; virtual void StartTestCase( const TestCase& testInfo ) = 0;
// TestCaseResult // TestCaseResult
virtual void EndTestCase( const TestCaseInfo& testInfo, const Totals& totals, const std::string& stdOut, const std::string& stdErr ) = 0; virtual void EndTestCase( const TestCase& testInfo, const Totals& totals, const std::string& stdOut, const std::string& stdErr ) = 0;
// SectionInfo // 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;

View File

@ -13,7 +13,7 @@
#include <string> #include <string>
namespace Catch { namespace Catch {
class TestCaseInfo; class TestCase;
struct IRunner { struct IRunner {
virtual ~IRunner(); virtual ~IRunner();

View File

@ -22,12 +22,12 @@ namespace Catch {
virtual ~ITestCase(); virtual ~ITestCase();
}; };
class TestCaseInfo; class TestCase;
struct ITestCaseRegistry { struct ITestCaseRegistry {
virtual ~ITestCaseRegistry(); virtual ~ITestCaseRegistry();
virtual const std::vector<TestCaseInfo>& getAllTests() const = 0; virtual const std::vector<TestCase>& getAllTests() const = 0;
virtual std::vector<TestCaseInfo> getMatchingTestCases( const std::string& rawTestSpec ) const = 0; virtual std::vector<TestCase> getMatchingTestCases( const std::string& rawTestSpec ) const = 0;
}; };
} }

View File

@ -12,7 +12,7 @@
#include <limits> #include <limits>
namespace Catch { namespace Catch {
inline bool matchesFilters( const std::vector<TestCaseFilters>& filters, const TestCaseInfo& testCase ) { inline bool matchesFilters( const std::vector<TestCaseFilters>& filters, const TestCase& testCase ) {
std::vector<TestCaseFilters>::const_iterator it = filters.begin(); std::vector<TestCaseFilters>::const_iterator it = filters.begin();
std::vector<TestCaseFilters>::const_iterator itEnd = filters.end(); std::vector<TestCaseFilters>::const_iterator itEnd = filters.end();
for(; it != itEnd; ++it ) for(; it != itEnd; ++it )
@ -38,8 +38,8 @@ namespace Catch {
std::cout << "All available test cases:\n"; std::cout << "All available test cases:\n";
else else
std::cout << "Matching test cases:\n"; std::cout << "Matching test cases:\n";
std::vector<TestCaseInfo>::const_iterator it = getRegistryHub().getTestCaseRegistry().getAllTests().begin(); std::vector<TestCase>::const_iterator it = getRegistryHub().getTestCaseRegistry().getAllTests().begin();
std::vector<TestCaseInfo>::const_iterator itEnd = getRegistryHub().getTestCaseRegistry().getAllTests().end(); std::vector<TestCase>::const_iterator itEnd = getRegistryHub().getTestCaseRegistry().getAllTests().end();
std::size_t matchedTests = 0; std::size_t matchedTests = 0;
for(; it != itEnd; ++it ) { for(; it != itEnd; ++it ) {
if( matchesFilters( config.filters, *it ) ) { if( matchesFilters( config.filters, *it ) ) {

View File

@ -93,7 +93,7 @@ namespace Catch {
std::string name = Detail::getAnnotation( cls, "Name", testCaseName ); std::string name = Detail::getAnnotation( cls, "Name", testCaseName );
std::string desc = Detail::getAnnotation( cls, "Description", testCaseName ); std::string desc = Detail::getAnnotation( cls, "Description", testCaseName );
getMutableRegistryHub().registerTest( TestCaseInfo( new OcMethod( cls, selector ), name.c_str(), desc.c_str(), SourceLineInfo() ) ); getMutableRegistryHub().registerTest( TestCase( new OcMethod( cls, selector ), name.c_str(), desc.c_str(), SourceLineInfo() ) );
noTestMethods++; noTestMethods++;
} }
} }

View File

@ -40,7 +40,7 @@ namespace Catch {
virtual void registerReporter( const std::string& name, IReporterFactory* factory ) { virtual void registerReporter( const std::string& name, IReporterFactory* factory ) {
m_reporterRegistry.registerReporter( name, factory ); m_reporterRegistry.registerReporter( name, factory );
} }
virtual void registerTest( const TestCaseInfo& testInfo ) { virtual void registerTest( const TestCase& testInfo ) {
m_testCaseRegistry.registerTest( testInfo ); m_testCaseRegistry.registerTest( testInfo );
} }
virtual void registerTranslator( const IExceptionTranslator* translator ) { virtual void registerTranslator( const IExceptionTranslator* translator ) {

View File

@ -81,14 +81,14 @@ namespace Catch {
Totals runMatching( const std::string& testSpec ) { Totals runMatching( const std::string& testSpec ) {
std::vector<TestCaseInfo> matchingTests = getRegistryHub().getTestCaseRegistry().getMatchingTestCases( testSpec ); std::vector<TestCase> matchingTests = getRegistryHub().getTestCaseRegistry().getMatchingTestCases( testSpec );
Totals totals; Totals totals;
m_reporter->StartGroup( testSpec ); m_reporter->StartGroup( testSpec );
std::vector<TestCaseInfo>::const_iterator it = matchingTests.begin(); std::vector<TestCase>::const_iterator it = matchingTests.begin();
std::vector<TestCaseInfo>::const_iterator itEnd = matchingTests.end(); std::vector<TestCase>::const_iterator itEnd = matchingTests.end();
for(; it != itEnd; ++it ) for(; it != itEnd; ++it )
totals += runTest( *it ); totals += runTest( *it );
// !TBD use std::accumulate? // !TBD use std::accumulate?
@ -97,7 +97,7 @@ namespace Catch {
return totals; return totals;
} }
Totals runTest( const TestCaseInfo& testInfo ) { Totals runTest( const TestCase& testInfo ) {
Totals prevTotals = m_totals; Totals prevTotals = m_totals;
std::string redirectedCout; std::string redirectedCout;
@ -120,7 +120,7 @@ namespace Catch {
( m_config.data().warnings & ConfigData::WarnAbout::NoAssertions ) ) { ( m_config.data().warnings & ConfigData::WarnAbout::NoAssertions ) ) {
m_totals.assertions.failed++; m_totals.assertions.failed++;
deltaTotals = m_totals.delta( prevTotals ); deltaTotals = m_totals.delta( prevTotals );
m_reporter->NoAssertionsInTestCase( m_runningTest->getTestCaseInfo().getName() ); m_reporter->NoAssertionsInTestCase( m_runningTest->getTestCase().getName() );
} }
m_totals.testCases += deltaTotals.testCases; m_totals.testCases += deltaTotals.testCases;
@ -228,7 +228,7 @@ namespace Catch {
virtual std::string getCurrentTestName() const { virtual std::string getCurrentTestName() const {
return m_runningTest return m_runningTest
? m_runningTest->getTestCaseInfo().getName() ? m_runningTest->getTestCase().getName()
: ""; : "";
} }
@ -262,15 +262,15 @@ namespace Catch {
void runCurrentTest( std::string& redirectedCout, std::string& redirectedCerr ) { void runCurrentTest( std::string& redirectedCout, std::string& redirectedCerr ) {
try { try {
m_lastAssertionInfo = AssertionInfo( "TEST_CASE", m_runningTest->getTestCaseInfo().getLineInfo(), "", ResultDisposition::Normal ); m_lastAssertionInfo = AssertionInfo( "TEST_CASE", m_runningTest->getTestCase().getLineInfo(), "", ResultDisposition::Normal );
m_runningTest->reset(); m_runningTest->reset();
if( m_reporter->shouldRedirectStdout() ) { if( m_reporter->shouldRedirectStdout() ) {
StreamRedirect coutRedir( std::cout, redirectedCout ); StreamRedirect coutRedir( std::cout, redirectedCout );
StreamRedirect cerrRedir( std::cerr, redirectedCerr ); StreamRedirect cerrRedir( std::cerr, redirectedCerr );
m_runningTest->getTestCaseInfo().invoke(); m_runningTest->getTestCase().invoke();
} }
else { else {
m_runningTest->getTestCaseInfo().invoke(); m_runningTest->getTestCase().invoke();
} }
m_runningTest->ranToCompletion(); m_runningTest->ranToCompletion();
} }

View File

@ -24,7 +24,7 @@ namespace Catch {
}; };
public: public:
explicit RunningTest( const TestCaseInfo* info = NULL ) explicit RunningTest( const TestCase* info = NULL )
: m_info( info ), : m_info( info ),
m_runStatus( RanAtLeastOneSection ), m_runStatus( RanAtLeastOneSection ),
m_currentSection( &m_rootSection ), m_currentSection( &m_rootSection ),
@ -97,7 +97,7 @@ namespace Catch {
m_currentSection = m_currentSection->getParent(); m_currentSection = m_currentSection->getParent();
} }
const TestCaseInfo& getTestCaseInfo() const { const TestCase& getTestCase() const {
return *m_info; return *m_info;
} }
@ -107,7 +107,7 @@ namespace Catch {
} }
private: private:
const TestCaseInfo* m_info; const TestCase* m_info;
RunStatus m_runStatus; RunStatus m_runStatus;
SectionInfo m_rootSection; SectionInfo m_rootSection;
SectionInfo* m_currentSection; SectionInfo* m_currentSection;

View File

@ -16,20 +16,20 @@
namespace Catch { namespace Catch {
struct ITestCase; struct ITestCase;
class TestCaseInfo { class TestCase {
public: public:
TestCaseInfo(); TestCase();
TestCaseInfo( ITestCase* testCase, TestCase( ITestCase* testCase,
const std::string& className, const std::string& className,
const std::string& name, const std::string& name,
const std::string& description, const std::string& description,
const SourceLineInfo& lineInfo ); const SourceLineInfo& lineInfo );
TestCaseInfo( const TestCaseInfo& other, const std::string& name ); TestCase( const TestCase& other, const std::string& name );
TestCaseInfo( const TestCaseInfo& other ); TestCase( const TestCase& other );
void invoke() const; void invoke() const;
@ -42,10 +42,10 @@ namespace Catch {
bool matchesTags( const std::string& tagPattern ) const; bool matchesTags( const std::string& tagPattern ) const;
const std::set<std::string>& getTags() const; const std::set<std::string>& getTags() const;
void swap( TestCaseInfo& other ); void swap( TestCase& other );
bool operator == ( const TestCaseInfo& other ) const; bool operator == ( const TestCase& other ) const;
bool operator < ( const TestCaseInfo& other ) const; bool operator < ( const TestCase& other ) const;
TestCaseInfo& operator = ( const TestCaseInfo& other ); TestCase& operator = ( const TestCase& other );
private: private:
Ptr<ITestCase> m_test; Ptr<ITestCase> m_test;

View File

@ -15,7 +15,7 @@
namespace Catch { namespace Catch {
TestCaseInfo::TestCaseInfo( ITestCase* testCase, TestCase::TestCase( ITestCase* testCase,
const std::string& className, const std::string& className,
const std::string& name, const std::string& name,
const std::string& description, const std::string& description,
@ -32,7 +32,7 @@ namespace Catch {
m_isHidden = true; m_isHidden = true;
} }
TestCaseInfo::TestCaseInfo() TestCase::TestCase()
: m_test( NULL ), : m_test( NULL ),
m_className(), m_className(),
m_name(), m_name(),
@ -40,7 +40,7 @@ namespace Catch {
m_isHidden( false ) m_isHidden( false )
{} {}
TestCaseInfo::TestCaseInfo( const TestCaseInfo& other, const std::string& name ) TestCase::TestCase( const TestCase& other, const std::string& name )
: m_test( other.m_test ), : m_test( other.m_test ),
m_className( other.m_className ), m_className( other.m_className ),
m_name( name ), m_name( name ),
@ -50,7 +50,7 @@ namespace Catch {
m_isHidden( other.m_isHidden ) m_isHidden( other.m_isHidden )
{} {}
TestCaseInfo::TestCaseInfo( const TestCaseInfo& other ) TestCase::TestCase( const TestCase& other )
: m_test( other.m_test ), : m_test( other.m_test ),
m_className( other.m_className ), m_className( other.m_className ),
m_name( other.m_name ), m_name( other.m_name ),
@ -60,40 +60,40 @@ namespace Catch {
m_isHidden( other.m_isHidden ) m_isHidden( other.m_isHidden )
{} {}
void TestCaseInfo::invoke() const { void TestCase::invoke() const {
m_test->invoke(); m_test->invoke();
} }
const std::string& TestCaseInfo::getClassName() const { const std::string& TestCase::getClassName() const {
return m_className; return m_className;
} }
const std::string& TestCaseInfo::getName() const { const std::string& TestCase::getName() const {
return m_name; return m_name;
} }
const std::string& TestCaseInfo::getDescription() const { const std::string& TestCase::getDescription() const {
return m_description; return m_description;
} }
const SourceLineInfo& TestCaseInfo::getLineInfo() const { const SourceLineInfo& TestCase::getLineInfo() const {
return m_lineInfo; return m_lineInfo;
} }
bool TestCaseInfo::isHidden() const { bool TestCase::isHidden() const {
return m_isHidden; return m_isHidden;
} }
bool TestCaseInfo::hasTag( const std::string& tag ) const { bool TestCase::hasTag( const std::string& tag ) const {
return m_tags.find( tag ) != m_tags.end(); return m_tags.find( tag ) != m_tags.end();
} }
bool TestCaseInfo::matchesTags( const std::string& tagPattern ) const { bool TestCase::matchesTags( const std::string& tagPattern ) const {
TagExpression exp; TagExpression exp;
TagExpressionParser( exp ).parse( tagPattern ); TagExpressionParser( exp ).parse( tagPattern );
return exp.matches( m_tags ); return exp.matches( m_tags );
} }
const std::set<std::string>& TestCaseInfo::getTags() const { const std::set<std::string>& TestCase::getTags() const {
return m_tags; return m_tags;
} }
void TestCaseInfo::swap( TestCaseInfo& other ) { void TestCase::swap( TestCase& other ) {
m_test.swap( other.m_test ); m_test.swap( other.m_test );
m_className.swap( other.m_className ); m_className.swap( other.m_className );
m_name.swap( other.m_name ); m_name.swap( other.m_name );
@ -101,17 +101,17 @@ namespace Catch {
std::swap( m_lineInfo, other.m_lineInfo ); std::swap( m_lineInfo, other.m_lineInfo );
} }
bool TestCaseInfo::operator == ( const TestCaseInfo& other ) const { bool TestCase::operator == ( const TestCase& other ) const {
return m_test.get() == other.m_test.get() && return m_test.get() == other.m_test.get() &&
m_name == other.m_name && m_name == other.m_name &&
m_className == other.m_className; m_className == other.m_className;
} }
bool TestCaseInfo::operator < ( const TestCaseInfo& other ) const { bool TestCase::operator < ( const TestCase& other ) const {
return m_name < other.m_name; return m_name < other.m_name;
} }
TestCaseInfo& TestCaseInfo::operator = ( const TestCaseInfo& other ) { TestCase& TestCase::operator = ( const TestCase& other ) {
TestCaseInfo temp( other ); TestCase temp( other );
swap( temp ); swap( temp );
return *this; return *this;
} }

View File

@ -25,11 +25,11 @@ namespace Catch {
TestRegistry() : m_unnamedCount( 0 ) {} TestRegistry() : m_unnamedCount( 0 ) {}
virtual ~TestRegistry(); virtual ~TestRegistry();
virtual void registerTest( const TestCaseInfo& testInfo ) { virtual void registerTest( const TestCase& testInfo ) {
if( testInfo.getName() == "" ) { if( testInfo.getName() == "" ) {
std::ostringstream oss; std::ostringstream oss;
oss << testInfo.getName() << "unnamed/" << ++m_unnamedCount; oss << testInfo.getName() << "unnamed/" << ++m_unnamedCount;
return registerTest( TestCaseInfo( testInfo, oss.str() ) ); return registerTest( TestCase( testInfo, oss.str() ) );
} }
if( m_functions.find( testInfo ) == m_functions.end() ) { if( m_functions.find( testInfo ) == m_functions.end() ) {
@ -39,7 +39,7 @@ namespace Catch {
m_nonHiddenFunctions.push_back( testInfo ); m_nonHiddenFunctions.push_back( testInfo );
} }
else { else {
const TestCaseInfo& prev = *m_functions.find( testInfo ); const TestCase& prev = *m_functions.find( testInfo );
std::cerr << "error: TEST_CASE( \"" << testInfo.getName() << "\" ) already defined.\n" std::cerr << "error: TEST_CASE( \"" << testInfo.getName() << "\" ) already defined.\n"
<< "\tFirst seen at " << SourceLineInfo( prev.getLineInfo() ) << "\n" << "\tFirst seen at " << SourceLineInfo( prev.getLineInfo() ) << "\n"
<< "\tRedefined at " << SourceLineInfo( testInfo.getLineInfo() ) << std::endl; << "\tRedefined at " << SourceLineInfo( testInfo.getLineInfo() ) << std::endl;
@ -47,36 +47,36 @@ namespace Catch {
} }
} }
virtual const std::vector<TestCaseInfo>& getAllTests() const { virtual const std::vector<TestCase>& getAllTests() const {
return m_functionsInOrder; return m_functionsInOrder;
} }
virtual const std::vector<TestCaseInfo>& getAllNonHiddenTests() const { virtual const std::vector<TestCase>& getAllNonHiddenTests() const {
return m_nonHiddenFunctions; return m_nonHiddenFunctions;
} }
// !TBD deprecated // !TBD deprecated
virtual std::vector<TestCaseInfo> getMatchingTestCases( const std::string& rawTestSpec ) const { virtual std::vector<TestCase> getMatchingTestCases( const std::string& rawTestSpec ) const {
std::vector<TestCaseInfo> matchingTests; std::vector<TestCase> matchingTests;
getMatchingTestCases( rawTestSpec, matchingTests ); getMatchingTestCases( rawTestSpec, matchingTests );
return matchingTests; return matchingTests;
} }
// !TBD deprecated // !TBD deprecated
virtual void getMatchingTestCases( const std::string& rawTestSpec, std::vector<TestCaseInfo>& matchingTestsOut ) const { virtual void getMatchingTestCases( const std::string& rawTestSpec, std::vector<TestCase>& matchingTestsOut ) const {
TestCaseFilter filter( rawTestSpec ); TestCaseFilter filter( rawTestSpec );
std::vector<TestCaseInfo>::const_iterator it = m_functionsInOrder.begin(); std::vector<TestCase>::const_iterator it = m_functionsInOrder.begin();
std::vector<TestCaseInfo>::const_iterator itEnd = m_functionsInOrder.end(); std::vector<TestCase>::const_iterator itEnd = m_functionsInOrder.end();
for(; it != itEnd; ++it ) { for(; it != itEnd; ++it ) {
if( filter.shouldInclude( *it ) ) { if( filter.shouldInclude( *it ) ) {
matchingTestsOut.push_back( *it ); matchingTestsOut.push_back( *it );
} }
} }
} }
virtual void getMatchingTestCases( const TestCaseFilters& filters, std::vector<TestCaseInfo>& matchingTestsOut ) const { virtual void getMatchingTestCases( const TestCaseFilters& filters, std::vector<TestCase>& matchingTestsOut ) const {
std::vector<TestCaseInfo>::const_iterator it = m_functionsInOrder.begin(); std::vector<TestCase>::const_iterator it = m_functionsInOrder.begin();
std::vector<TestCaseInfo>::const_iterator itEnd = m_functionsInOrder.end(); std::vector<TestCase>::const_iterator itEnd = m_functionsInOrder.end();
// !TBD: replace with algorithm // !TBD: replace with algorithm
for(; it != itEnd; ++it ) for(; it != itEnd; ++it )
if( filters.shouldInclude( *it ) ) if( filters.shouldInclude( *it ) )
@ -85,9 +85,9 @@ namespace Catch {
private: private:
std::set<TestCaseInfo> m_functions; std::set<TestCase> m_functions;
std::vector<TestCaseInfo> m_functionsInOrder; std::vector<TestCase> m_functionsInOrder;
std::vector<TestCaseInfo> m_nonHiddenFunctions; std::vector<TestCase> m_nonHiddenFunctions;
size_t m_unnamedCount; size_t m_unnamedCount;
}; };
@ -138,7 +138,7 @@ namespace Catch {
const char* description, const char* description,
const SourceLineInfo& lineInfo ) { const SourceLineInfo& lineInfo ) {
getMutableRegistryHub().registerTest( TestCaseInfo( testCase, extractClassName( classOrQualifiedMethodName ), name, description, lineInfo ) ); getMutableRegistryHub().registerTest( TestCase( testCase, extractClassName( classOrQualifiedMethodName ), name, description, lineInfo ) );
} }
} // end namespace Catch } // end namespace Catch

View File

@ -64,7 +64,7 @@ namespace Catch {
return m_filterType; return m_filterType;
} }
bool shouldInclude( const TestCaseInfo& testCase ) const { bool shouldInclude( const TestCase& testCase ) const {
return isMatch( testCase ) == (m_filterType == IfFilterMatches::IncludeTests); return isMatch( testCase ) == (m_filterType == IfFilterMatches::IncludeTests);
} }
private: private:
@ -74,7 +74,7 @@ namespace Catch {
#pragma clang diagnostic ignored "-Wunreachable-code" #pragma clang diagnostic ignored "-Wunreachable-code"
#endif #endif
bool isMatch( const TestCaseInfo& testCase ) const { bool isMatch( const TestCase& testCase ) const {
const std::string& name = testCase.getName(); const std::string& name = testCase.getName();
switch( m_wildcardPosition ) { switch( m_wildcardPosition ) {
@ -121,7 +121,7 @@ namespace Catch {
m_tagExpressions.push_back( exp ); m_tagExpressions.push_back( exp );
} }
bool shouldInclude( const TestCaseInfo& testCase ) const { bool shouldInclude( const TestCase& testCase ) const {
if( !m_tagExpressions.empty() ) { if( !m_tagExpressions.empty() ) {
std::vector<TagExpression>::const_iterator it = m_tagExpressions.begin(); std::vector<TagExpression>::const_iterator it = m_tagExpressions.begin();
std::vector<TagExpression>::const_iterator itEnd = m_tagExpressions.end(); std::vector<TagExpression>::const_iterator itEnd = m_tagExpressions.end();

View File

@ -120,7 +120,7 @@ namespace Catch {
} }
} }
virtual void StartTestCase( const TestCaseInfo& testInfo ) { virtual void StartTestCase( const TestCase& testInfo ) {
m_testSpan = testInfo.getName(); m_testSpan = testInfo.getName();
} }
@ -264,7 +264,7 @@ namespace Catch {
m_config.stream << std::endl; m_config.stream << std::endl;
} }
virtual void EndTestCase( const TestCaseInfo& testInfo, virtual void EndTestCase( const TestCase& testInfo,
const Totals& totals, const Totals& totals,
const std::string& stdOut, const std::string& stdOut,
const std::string& stdErr ) { const std::string& stdErr ) {

View File

@ -38,6 +38,7 @@ namespace Catch {
std::string m_stdOut; std::string m_stdOut;
std::string m_stdErr; std::string m_stdErr;
std::vector<TestStats> m_testStats; std::vector<TestStats> m_testStats;
std::vector<TestCaseStats> m_sections;
}; };
struct Stats { struct Stats {
@ -101,8 +102,9 @@ namespace Catch {
virtual void EndSection( const std::string&, const Counts& ) {} virtual void EndSection( const std::string&, const Counts& ) {}
virtual void StartTestCase( const Catch::TestCaseInfo& testInfo ) { virtual void StartTestCase( const Catch::TestCase& testInfo ) {
m_currentStats->m_testCaseStats.push_back( TestCaseStats( testInfo.getClassName(), testInfo.getName() ) ); m_currentStats->m_testCaseStats.push_back( TestCaseStats( testInfo.getClassName(), testInfo.getName() ) );
m_currentTestCaseStats.push_back( &m_currentStats->m_testCaseStats.back() );
} }
virtual void Result( const Catch::AssertionResult& assertionResult ) { virtual void Result( const Catch::AssertionResult& assertionResult ) {
@ -149,7 +151,9 @@ namespace Catch {
} }
} }
virtual void EndTestCase( const Catch::TestCaseInfo&, const Totals&, const std::string& stdOut, const std::string& stdErr ) { virtual void EndTestCase( const Catch::TestCase&, const Totals&, const std::string& stdOut, const std::string& stdErr ) {
m_currentTestCaseStats.pop_back();
assert( m_currentTestCaseStats.empty() );
TestCaseStats& testCaseStats = m_currentStats->m_testCaseStats.back(); TestCaseStats& testCaseStats = m_currentStats->m_testCaseStats.back();
testCaseStats.m_stdOut = stdOut; testCaseStats.m_stdOut = stdOut;
testCaseStats.m_stdErr = stdErr; testCaseStats.m_stdErr = stdErr;
@ -236,6 +240,7 @@ namespace Catch {
Stats m_testSuiteStats; Stats m_testSuiteStats;
Stats* m_currentStats; Stats* m_currentStats;
std::vector<Stats> m_statsForSuites; std::vector<Stats> m_statsForSuites;
std::vector<const TestCaseStats*> m_currentTestCaseStats;
std::ostringstream m_stdOut; std::ostringstream m_stdOut;
std::ostringstream m_stdErr; std::ostringstream m_stdErr;
}; };

View File

@ -70,7 +70,7 @@ namespace Catch {
m_xml.endElement(); m_xml.endElement();
} }
virtual void StartTestCase( const Catch::TestCaseInfo& testInfo ) { virtual void StartTestCase( const Catch::TestCase& testInfo ) {
m_xml.startElement( "TestCase" ).writeAttribute( "name", testInfo.getName() ); m_xml.startElement( "TestCase" ).writeAttribute( "name", testInfo.getName() );
m_currentTestSuccess = true; m_currentTestSuccess = true;
} }
@ -129,7 +129,7 @@ namespace Catch {
// !TBD // !TBD
} }
virtual void EndTestCase( const Catch::TestCaseInfo&, const Totals&, const std::string&, const std::string& ) { virtual void EndTestCase( const Catch::TestCase&, const Totals&, const std::string&, const std::string& ) {
m_xml.scopedElement( "OverallResult" ).writeAttribute( "success", m_currentTestSuccess ); m_xml.scopedElement( "OverallResult" ).writeAttribute( "success", m_currentTestSuccess );
m_xml.endElement(); m_xml.endElement();
} }

View File

@ -86,7 +86,7 @@ std::string parseIntoConfigAndReturnError( const char * (&argv)[size], Catch::Co
return ""; return "";
} }
inline Catch::TestCaseInfo makeTestCase( const char* name ){ return Catch::TestCaseInfo( NULL, "", name, "", CATCH_INTERNAL_LINEINFO ); } inline Catch::TestCase makeTestCase( const char* name ){ return Catch::TestCase( NULL, "", name, "", CATCH_INTERNAL_LINEINFO ); }
TEST_CASE( "selftest/parser/2", "ConfigData" ) { TEST_CASE( "selftest/parser/2", "ConfigData" ) {
@ -364,7 +364,7 @@ TEST_CASE( "selftest/tags", "" ) {
std::string p5 = "[one][two]~[hide],[three]"; std::string p5 = "[one][two]~[hide],[three]";
SECTION( "one tag", "" ) { SECTION( "one tag", "" ) {
Catch::TestCaseInfo oneTag( NULL, "", "test", "[one]", CATCH_INTERNAL_LINEINFO ); Catch::TestCase oneTag( NULL, "", "test", "[one]", CATCH_INTERNAL_LINEINFO );
CHECK( oneTag.getDescription() == "" ); CHECK( oneTag.getDescription() == "" );
CHECK( oneTag.hasTag( "one" ) ); CHECK( oneTag.hasTag( "one" ) );
@ -378,7 +378,7 @@ TEST_CASE( "selftest/tags", "" ) {
} }
SECTION( "two tags", "" ) { SECTION( "two tags", "" ) {
Catch::TestCaseInfo twoTags( NULL, "", "test", "[one][two]", CATCH_INTERNAL_LINEINFO ); Catch::TestCase twoTags( NULL, "", "test", "[one][two]", CATCH_INTERNAL_LINEINFO );
CHECK( twoTags.getDescription() == "" ); CHECK( twoTags.getDescription() == "" );
CHECK( twoTags.hasTag( "one" ) ); CHECK( twoTags.hasTag( "one" ) );
@ -395,7 +395,7 @@ TEST_CASE( "selftest/tags", "" ) {
SECTION( "one tag with characters either side", "" ) { SECTION( "one tag with characters either side", "" ) {
Catch::TestCaseInfo oneTagWithExtras( NULL, "", "test", "12[one]34", CATCH_INTERNAL_LINEINFO ); Catch::TestCase oneTagWithExtras( NULL, "", "test", "12[one]34", CATCH_INTERNAL_LINEINFO );
CHECK( oneTagWithExtras.getDescription() == "1234" ); CHECK( oneTagWithExtras.getDescription() == "1234" );
CHECK( oneTagWithExtras.hasTag( "one" ) ); CHECK( oneTagWithExtras.hasTag( "one" ) );
CHECK( oneTagWithExtras.hasTag( "two" ) == false ); CHECK( oneTagWithExtras.hasTag( "two" ) == false );
@ -404,7 +404,7 @@ TEST_CASE( "selftest/tags", "" ) {
SECTION( "start of a tag, but not closed", "" ) { SECTION( "start of a tag, but not closed", "" ) {
Catch::TestCaseInfo oneTagOpen( NULL, "", "test", "[one", CATCH_INTERNAL_LINEINFO ); Catch::TestCase oneTagOpen( NULL, "", "test", "[one", CATCH_INTERNAL_LINEINFO );
CHECK( oneTagOpen.getDescription() == "[one" ); CHECK( oneTagOpen.getDescription() == "[one" );
CHECK( oneTagOpen.hasTag( "one" ) == false ); CHECK( oneTagOpen.hasTag( "one" ) == false );
@ -412,7 +412,7 @@ TEST_CASE( "selftest/tags", "" ) {
} }
SECTION( "hidden", "" ) { SECTION( "hidden", "" ) {
Catch::TestCaseInfo oneTag( NULL, "", "test", "[hide]", CATCH_INTERNAL_LINEINFO ); Catch::TestCase oneTag( NULL, "", "test", "[hide]", CATCH_INTERNAL_LINEINFO );
CHECK( oneTag.getDescription() == "" ); CHECK( oneTag.getDescription() == "" );
CHECK( oneTag.hasTag( "hide" ) ); CHECK( oneTag.hasTag( "hide" ) );

View File

@ -82,13 +82,13 @@ namespace Catch {
closeLabel( recordSections, sectionName ); closeLabel( recordSections, sectionName );
} }
virtual void StartTestCase( const TestCaseInfo& testInfo ) { virtual void StartTestCase( const TestCase& testInfo ) {
openLabel( recordTestCases, testInfo.getName() ); openLabel( recordTestCases, testInfo.getName() );
} }
virtual void Aborted(){} virtual void Aborted(){}
virtual void EndTestCase( const TestCaseInfo& testInfo, virtual void EndTestCase( const TestCase& testInfo,
const Totals&, const Totals&,
const std::string&, const std::string&,
const std::string& ) { const std::string& ) {
@ -153,7 +153,7 @@ namespace Catch {
MetaTestRunner( expectedResult ) ); MetaTestRunner( expectedResult ) );
} }
void operator()( const TestCaseInfo& testCase ) { void operator()( const TestCase& testCase ) {
EmbeddedRunner runner; EmbeddedRunner runner;
Totals totals = runner.runMatching( testCase.getName() ); Totals totals = runner.runMatching( testCase.getName() );
switch( m_expectedResult ) { switch( m_expectedResult ) {