mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Renamed TestCaseInfo -> TestCase
This commit is contained in:
parent
37f3820747
commit
06a671a349
@ -56,8 +56,8 @@ namespace Catch {
|
||||
|
||||
Totals runTestsForGroup( Runner& context, const TestCaseFilters& filterGroup ) {
|
||||
Totals totals;
|
||||
std::vector<TestCaseInfo>::const_iterator it = getRegistryHub().getTestCaseRegistry().getAllTests().begin();
|
||||
std::vector<TestCaseInfo>::const_iterator itEnd = getRegistryHub().getTestCaseRegistry().getAllTests().end();
|
||||
std::vector<TestCase>::const_iterator it = getRegistryHub().getTestCaseRegistry().getAllTests().begin();
|
||||
std::vector<TestCase>::const_iterator itEnd = getRegistryHub().getTestCaseRegistry().getAllTests().end();
|
||||
int testsRunForGroup = 0;
|
||||
for(; it != itEnd; ++it ) {
|
||||
if( filterGroup.shouldInclude( *it ) ) {
|
||||
@ -114,7 +114,7 @@ namespace Catch {
|
||||
const ConfigData& m_config;
|
||||
std::ofstream m_ofs;
|
||||
Ptr<IReporter> m_reporter;
|
||||
std::set<TestCaseInfo> m_testsAlreadyRun;
|
||||
std::set<TestCase> m_testsAlreadyRun;
|
||||
};
|
||||
|
||||
inline int Main( Config& configWrapper ) {
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
namespace Catch {
|
||||
|
||||
class TestCaseInfo;
|
||||
class TestCase;
|
||||
class Stream;
|
||||
struct IResultCapture;
|
||||
struct IRunner;
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
namespace Catch {
|
||||
|
||||
class TestCaseInfo;
|
||||
class TestCase;
|
||||
class ScopedInfo;
|
||||
class ExpressionResultBuilder;
|
||||
class AssertionResult;
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
namespace Catch {
|
||||
|
||||
class TestCaseInfo;
|
||||
class TestCase;
|
||||
struct ITestCaseRegistry;
|
||||
struct IExceptionTranslatorRegistry;
|
||||
struct IExceptionTranslator;
|
||||
@ -31,7 +31,7 @@ namespace Catch {
|
||||
struct IMutableRegistryHub {
|
||||
virtual ~IMutableRegistryHub();
|
||||
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;
|
||||
};
|
||||
|
||||
|
@ -12,6 +12,8 @@
|
||||
#include "catch_totals.hpp"
|
||||
#include "catch_ptr.hpp"
|
||||
#include "catch_config.hpp"
|
||||
#include "catch_test_case_info.h"
|
||||
#include "catch_assertionresult.h"
|
||||
|
||||
#include <string>
|
||||
#include <ostream>
|
||||
@ -47,10 +49,54 @@ namespace Catch
|
||||
private:
|
||||
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;
|
||||
class AssertionResult;
|
||||
struct TestGroupStats {
|
||||
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 {
|
||||
virtual ~IReporter();
|
||||
|
||||
@ -62,9 +108,9 @@ namespace Catch
|
||||
virtual void StartGroup( const std::string& groupName ) = 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
|
||||
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
|
||||
virtual void StartSection( const std::string& sectionName, const std::string& description ) = 0;
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include <string>
|
||||
|
||||
namespace Catch {
|
||||
class TestCaseInfo;
|
||||
class TestCase;
|
||||
|
||||
struct IRunner {
|
||||
virtual ~IRunner();
|
||||
|
@ -22,12 +22,12 @@ namespace Catch {
|
||||
virtual ~ITestCase();
|
||||
};
|
||||
|
||||
class TestCaseInfo;
|
||||
class TestCase;
|
||||
|
||||
struct ITestCaseRegistry {
|
||||
virtual ~ITestCaseRegistry();
|
||||
virtual const std::vector<TestCaseInfo>& getAllTests() const = 0;
|
||||
virtual std::vector<TestCaseInfo> getMatchingTestCases( const std::string& rawTestSpec ) const = 0;
|
||||
virtual const std::vector<TestCase>& getAllTests() const = 0;
|
||||
virtual std::vector<TestCase> getMatchingTestCases( const std::string& rawTestSpec ) const = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include <limits>
|
||||
|
||||
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 itEnd = filters.end();
|
||||
for(; it != itEnd; ++it )
|
||||
@ -38,8 +38,8 @@ namespace Catch {
|
||||
std::cout << "All available test cases:\n";
|
||||
else
|
||||
std::cout << "Matching test cases:\n";
|
||||
std::vector<TestCaseInfo>::const_iterator it = getRegistryHub().getTestCaseRegistry().getAllTests().begin();
|
||||
std::vector<TestCaseInfo>::const_iterator itEnd = getRegistryHub().getTestCaseRegistry().getAllTests().end();
|
||||
std::vector<TestCase>::const_iterator it = getRegistryHub().getTestCaseRegistry().getAllTests().begin();
|
||||
std::vector<TestCase>::const_iterator itEnd = getRegistryHub().getTestCaseRegistry().getAllTests().end();
|
||||
std::size_t matchedTests = 0;
|
||||
for(; it != itEnd; ++it ) {
|
||||
if( matchesFilters( config.filters, *it ) ) {
|
||||
|
@ -93,7 +93,7 @@ namespace Catch {
|
||||
std::string name = Detail::getAnnotation( cls, "Name", 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++;
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ namespace Catch {
|
||||
virtual void registerReporter( const std::string& name, IReporterFactory* factory ) {
|
||||
m_reporterRegistry.registerReporter( name, factory );
|
||||
}
|
||||
virtual void registerTest( const TestCaseInfo& testInfo ) {
|
||||
virtual void registerTest( const TestCase& testInfo ) {
|
||||
m_testCaseRegistry.registerTest( testInfo );
|
||||
}
|
||||
virtual void registerTranslator( const IExceptionTranslator* translator ) {
|
||||
|
@ -81,14 +81,14 @@ namespace Catch {
|
||||
|
||||
Totals runMatching( const std::string& testSpec ) {
|
||||
|
||||
std::vector<TestCaseInfo> matchingTests = getRegistryHub().getTestCaseRegistry().getMatchingTestCases( testSpec );
|
||||
std::vector<TestCase> matchingTests = getRegistryHub().getTestCaseRegistry().getMatchingTestCases( testSpec );
|
||||
|
||||
Totals totals;
|
||||
|
||||
m_reporter->StartGroup( testSpec );
|
||||
|
||||
std::vector<TestCaseInfo>::const_iterator it = matchingTests.begin();
|
||||
std::vector<TestCaseInfo>::const_iterator itEnd = matchingTests.end();
|
||||
std::vector<TestCase>::const_iterator it = matchingTests.begin();
|
||||
std::vector<TestCase>::const_iterator itEnd = matchingTests.end();
|
||||
for(; it != itEnd; ++it )
|
||||
totals += runTest( *it );
|
||||
// !TBD use std::accumulate?
|
||||
@ -97,7 +97,7 @@ namespace Catch {
|
||||
return totals;
|
||||
}
|
||||
|
||||
Totals runTest( const TestCaseInfo& testInfo ) {
|
||||
Totals runTest( const TestCase& testInfo ) {
|
||||
Totals prevTotals = m_totals;
|
||||
|
||||
std::string redirectedCout;
|
||||
@ -120,7 +120,7 @@ namespace Catch {
|
||||
( m_config.data().warnings & ConfigData::WarnAbout::NoAssertions ) ) {
|
||||
m_totals.assertions.failed++;
|
||||
deltaTotals = m_totals.delta( prevTotals );
|
||||
m_reporter->NoAssertionsInTestCase( m_runningTest->getTestCaseInfo().getName() );
|
||||
m_reporter->NoAssertionsInTestCase( m_runningTest->getTestCase().getName() );
|
||||
}
|
||||
m_totals.testCases += deltaTotals.testCases;
|
||||
|
||||
@ -228,7 +228,7 @@ namespace Catch {
|
||||
|
||||
virtual std::string getCurrentTestName() const {
|
||||
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 ) {
|
||||
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();
|
||||
if( m_reporter->shouldRedirectStdout() ) {
|
||||
StreamRedirect coutRedir( std::cout, redirectedCout );
|
||||
StreamRedirect cerrRedir( std::cerr, redirectedCerr );
|
||||
m_runningTest->getTestCaseInfo().invoke();
|
||||
m_runningTest->getTestCase().invoke();
|
||||
}
|
||||
else {
|
||||
m_runningTest->getTestCaseInfo().invoke();
|
||||
m_runningTest->getTestCase().invoke();
|
||||
}
|
||||
m_runningTest->ranToCompletion();
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ namespace Catch {
|
||||
};
|
||||
|
||||
public:
|
||||
explicit RunningTest( const TestCaseInfo* info = NULL )
|
||||
explicit RunningTest( const TestCase* info = NULL )
|
||||
: m_info( info ),
|
||||
m_runStatus( RanAtLeastOneSection ),
|
||||
m_currentSection( &m_rootSection ),
|
||||
@ -97,7 +97,7 @@ namespace Catch {
|
||||
m_currentSection = m_currentSection->getParent();
|
||||
}
|
||||
|
||||
const TestCaseInfo& getTestCaseInfo() const {
|
||||
const TestCase& getTestCase() const {
|
||||
return *m_info;
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ namespace Catch {
|
||||
}
|
||||
|
||||
private:
|
||||
const TestCaseInfo* m_info;
|
||||
const TestCase* m_info;
|
||||
RunStatus m_runStatus;
|
||||
SectionInfo m_rootSection;
|
||||
SectionInfo* m_currentSection;
|
||||
|
@ -16,20 +16,20 @@
|
||||
namespace Catch {
|
||||
|
||||
struct ITestCase;
|
||||
|
||||
class TestCaseInfo {
|
||||
|
||||
class TestCase {
|
||||
public:
|
||||
TestCaseInfo();
|
||||
TestCase();
|
||||
|
||||
TestCaseInfo( ITestCase* testCase,
|
||||
TestCase( ITestCase* testCase,
|
||||
const std::string& className,
|
||||
const std::string& name,
|
||||
const std::string& description,
|
||||
const SourceLineInfo& lineInfo );
|
||||
|
||||
|
||||
TestCaseInfo( const TestCaseInfo& other, const std::string& name );
|
||||
TestCaseInfo( const TestCaseInfo& other );
|
||||
TestCase( const TestCase& other, const std::string& name );
|
||||
TestCase( const TestCase& other );
|
||||
|
||||
void invoke() const;
|
||||
|
||||
@ -42,10 +42,10 @@ namespace Catch {
|
||||
bool matchesTags( const std::string& tagPattern ) const;
|
||||
const std::set<std::string>& getTags() const;
|
||||
|
||||
void swap( TestCaseInfo& other );
|
||||
bool operator == ( const TestCaseInfo& other ) const;
|
||||
bool operator < ( const TestCaseInfo& other ) const;
|
||||
TestCaseInfo& operator = ( const TestCaseInfo& other );
|
||||
void swap( TestCase& other );
|
||||
bool operator == ( const TestCase& other ) const;
|
||||
bool operator < ( const TestCase& other ) const;
|
||||
TestCase& operator = ( const TestCase& other );
|
||||
|
||||
private:
|
||||
Ptr<ITestCase> m_test;
|
||||
|
@ -15,7 +15,7 @@
|
||||
namespace Catch {
|
||||
|
||||
|
||||
TestCaseInfo::TestCaseInfo( ITestCase* testCase,
|
||||
TestCase::TestCase( ITestCase* testCase,
|
||||
const std::string& className,
|
||||
const std::string& name,
|
||||
const std::string& description,
|
||||
@ -32,7 +32,7 @@ namespace Catch {
|
||||
m_isHidden = true;
|
||||
}
|
||||
|
||||
TestCaseInfo::TestCaseInfo()
|
||||
TestCase::TestCase()
|
||||
: m_test( NULL ),
|
||||
m_className(),
|
||||
m_name(),
|
||||
@ -40,7 +40,7 @@ namespace Catch {
|
||||
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_className( other.m_className ),
|
||||
m_name( name ),
|
||||
@ -50,7 +50,7 @@ namespace Catch {
|
||||
m_isHidden( other.m_isHidden )
|
||||
{}
|
||||
|
||||
TestCaseInfo::TestCaseInfo( const TestCaseInfo& other )
|
||||
TestCase::TestCase( const TestCase& other )
|
||||
: m_test( other.m_test ),
|
||||
m_className( other.m_className ),
|
||||
m_name( other.m_name ),
|
||||
@ -60,40 +60,40 @@ namespace Catch {
|
||||
m_isHidden( other.m_isHidden )
|
||||
{}
|
||||
|
||||
void TestCaseInfo::invoke() const {
|
||||
void TestCase::invoke() const {
|
||||
m_test->invoke();
|
||||
}
|
||||
|
||||
const std::string& TestCaseInfo::getClassName() const {
|
||||
const std::string& TestCase::getClassName() const {
|
||||
return m_className;
|
||||
}
|
||||
const std::string& TestCaseInfo::getName() const {
|
||||
const std::string& TestCase::getName() const {
|
||||
return m_name;
|
||||
}
|
||||
const std::string& TestCaseInfo::getDescription() const {
|
||||
const std::string& TestCase::getDescription() const {
|
||||
return m_description;
|
||||
}
|
||||
const SourceLineInfo& TestCaseInfo::getLineInfo() const {
|
||||
const SourceLineInfo& TestCase::getLineInfo() const {
|
||||
return m_lineInfo;
|
||||
}
|
||||
|
||||
bool TestCaseInfo::isHidden() const {
|
||||
bool TestCase::isHidden() const {
|
||||
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();
|
||||
}
|
||||
bool TestCaseInfo::matchesTags( const std::string& tagPattern ) const {
|
||||
bool TestCase::matchesTags( const std::string& tagPattern ) const {
|
||||
TagExpression exp;
|
||||
TagExpressionParser( exp ).parse( tagPattern );
|
||||
return exp.matches( m_tags );
|
||||
}
|
||||
const std::set<std::string>& TestCaseInfo::getTags() const {
|
||||
const std::set<std::string>& TestCase::getTags() const {
|
||||
return m_tags;
|
||||
}
|
||||
|
||||
void TestCaseInfo::swap( TestCaseInfo& other ) {
|
||||
void TestCase::swap( TestCase& other ) {
|
||||
m_test.swap( other.m_test );
|
||||
m_className.swap( other.m_className );
|
||||
m_name.swap( other.m_name );
|
||||
@ -101,17 +101,17 @@ namespace Catch {
|
||||
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() &&
|
||||
m_name == other.m_name &&
|
||||
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;
|
||||
}
|
||||
TestCaseInfo& TestCaseInfo::operator = ( const TestCaseInfo& other ) {
|
||||
TestCaseInfo temp( other );
|
||||
TestCase& TestCase::operator = ( const TestCase& other ) {
|
||||
TestCase temp( other );
|
||||
swap( temp );
|
||||
return *this;
|
||||
}
|
||||
|
@ -25,11 +25,11 @@ namespace Catch {
|
||||
TestRegistry() : m_unnamedCount( 0 ) {}
|
||||
virtual ~TestRegistry();
|
||||
|
||||
virtual void registerTest( const TestCaseInfo& testInfo ) {
|
||||
virtual void registerTest( const TestCase& testInfo ) {
|
||||
if( testInfo.getName() == "" ) {
|
||||
std::ostringstream oss;
|
||||
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() ) {
|
||||
@ -39,7 +39,7 @@ namespace Catch {
|
||||
m_nonHiddenFunctions.push_back( testInfo );
|
||||
}
|
||||
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"
|
||||
<< "\tFirst seen at " << SourceLineInfo( prev.getLineInfo() ) << "\n"
|
||||
<< "\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;
|
||||
}
|
||||
|
||||
virtual const std::vector<TestCaseInfo>& getAllNonHiddenTests() const {
|
||||
virtual const std::vector<TestCase>& getAllNonHiddenTests() const {
|
||||
return m_nonHiddenFunctions;
|
||||
}
|
||||
|
||||
// !TBD deprecated
|
||||
virtual std::vector<TestCaseInfo> getMatchingTestCases( const std::string& rawTestSpec ) const {
|
||||
std::vector<TestCaseInfo> matchingTests;
|
||||
virtual std::vector<TestCase> getMatchingTestCases( const std::string& rawTestSpec ) const {
|
||||
std::vector<TestCase> matchingTests;
|
||||
getMatchingTestCases( rawTestSpec, matchingTests );
|
||||
return matchingTests;
|
||||
}
|
||||
|
||||
// !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 );
|
||||
|
||||
std::vector<TestCaseInfo>::const_iterator it = m_functionsInOrder.begin();
|
||||
std::vector<TestCaseInfo>::const_iterator itEnd = m_functionsInOrder.end();
|
||||
std::vector<TestCase>::const_iterator it = m_functionsInOrder.begin();
|
||||
std::vector<TestCase>::const_iterator itEnd = m_functionsInOrder.end();
|
||||
for(; it != itEnd; ++it ) {
|
||||
if( filter.shouldInclude( *it ) ) {
|
||||
matchingTestsOut.push_back( *it );
|
||||
}
|
||||
}
|
||||
}
|
||||
virtual void getMatchingTestCases( const TestCaseFilters& filters, std::vector<TestCaseInfo>& matchingTestsOut ) const {
|
||||
std::vector<TestCaseInfo>::const_iterator it = m_functionsInOrder.begin();
|
||||
std::vector<TestCaseInfo>::const_iterator itEnd = m_functionsInOrder.end();
|
||||
virtual void getMatchingTestCases( const TestCaseFilters& filters, std::vector<TestCase>& matchingTestsOut ) const {
|
||||
std::vector<TestCase>::const_iterator it = m_functionsInOrder.begin();
|
||||
std::vector<TestCase>::const_iterator itEnd = m_functionsInOrder.end();
|
||||
// !TBD: replace with algorithm
|
||||
for(; it != itEnd; ++it )
|
||||
if( filters.shouldInclude( *it ) )
|
||||
@ -85,9 +85,9 @@ namespace Catch {
|
||||
|
||||
private:
|
||||
|
||||
std::set<TestCaseInfo> m_functions;
|
||||
std::vector<TestCaseInfo> m_functionsInOrder;
|
||||
std::vector<TestCaseInfo> m_nonHiddenFunctions;
|
||||
std::set<TestCase> m_functions;
|
||||
std::vector<TestCase> m_functionsInOrder;
|
||||
std::vector<TestCase> m_nonHiddenFunctions;
|
||||
size_t m_unnamedCount;
|
||||
};
|
||||
|
||||
@ -138,7 +138,7 @@ namespace Catch {
|
||||
const char* description,
|
||||
const SourceLineInfo& lineInfo ) {
|
||||
|
||||
getMutableRegistryHub().registerTest( TestCaseInfo( testCase, extractClassName( classOrQualifiedMethodName ), name, description, lineInfo ) );
|
||||
getMutableRegistryHub().registerTest( TestCase( testCase, extractClassName( classOrQualifiedMethodName ), name, description, lineInfo ) );
|
||||
}
|
||||
|
||||
} // end namespace Catch
|
||||
|
@ -64,7 +64,7 @@ namespace Catch {
|
||||
return m_filterType;
|
||||
}
|
||||
|
||||
bool shouldInclude( const TestCaseInfo& testCase ) const {
|
||||
bool shouldInclude( const TestCase& testCase ) const {
|
||||
return isMatch( testCase ) == (m_filterType == IfFilterMatches::IncludeTests);
|
||||
}
|
||||
private:
|
||||
@ -74,7 +74,7 @@ namespace Catch {
|
||||
#pragma clang diagnostic ignored "-Wunreachable-code"
|
||||
#endif
|
||||
|
||||
bool isMatch( const TestCaseInfo& testCase ) const {
|
||||
bool isMatch( const TestCase& testCase ) const {
|
||||
const std::string& name = testCase.getName();
|
||||
|
||||
switch( m_wildcardPosition ) {
|
||||
@ -121,7 +121,7 @@ namespace Catch {
|
||||
m_tagExpressions.push_back( exp );
|
||||
}
|
||||
|
||||
bool shouldInclude( const TestCaseInfo& testCase ) const {
|
||||
bool shouldInclude( const TestCase& testCase ) const {
|
||||
if( !m_tagExpressions.empty() ) {
|
||||
std::vector<TagExpression>::const_iterator it = m_tagExpressions.begin();
|
||||
std::vector<TagExpression>::const_iterator itEnd = m_tagExpressions.end();
|
||||
|
@ -120,7 +120,7 @@ namespace Catch {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void StartTestCase( const TestCaseInfo& testInfo ) {
|
||||
virtual void StartTestCase( const TestCase& testInfo ) {
|
||||
m_testSpan = testInfo.getName();
|
||||
}
|
||||
|
||||
@ -264,7 +264,7 @@ namespace Catch {
|
||||
m_config.stream << std::endl;
|
||||
}
|
||||
|
||||
virtual void EndTestCase( const TestCaseInfo& testInfo,
|
||||
virtual void EndTestCase( const TestCase& testInfo,
|
||||
const Totals& totals,
|
||||
const std::string& stdOut,
|
||||
const std::string& stdErr ) {
|
||||
|
@ -38,6 +38,7 @@ namespace Catch {
|
||||
std::string m_stdOut;
|
||||
std::string m_stdErr;
|
||||
std::vector<TestStats> m_testStats;
|
||||
std::vector<TestCaseStats> m_sections;
|
||||
};
|
||||
|
||||
struct Stats {
|
||||
@ -101,8 +102,9 @@ namespace Catch {
|
||||
|
||||
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_currentTestCaseStats.push_back( &m_currentStats->m_testCaseStats.back() );
|
||||
}
|
||||
|
||||
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.m_stdOut = stdOut;
|
||||
testCaseStats.m_stdErr = stdErr;
|
||||
@ -236,6 +240,7 @@ namespace Catch {
|
||||
Stats m_testSuiteStats;
|
||||
Stats* m_currentStats;
|
||||
std::vector<Stats> m_statsForSuites;
|
||||
std::vector<const TestCaseStats*> m_currentTestCaseStats;
|
||||
std::ostringstream m_stdOut;
|
||||
std::ostringstream m_stdErr;
|
||||
};
|
||||
|
@ -70,7 +70,7 @@ namespace Catch {
|
||||
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_currentTestSuccess = true;
|
||||
}
|
||||
@ -129,7 +129,7 @@ namespace Catch {
|
||||
// !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.endElement();
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ std::string parseIntoConfigAndReturnError( const char * (&argv)[size], Catch::Co
|
||||
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" ) {
|
||||
|
||||
@ -364,7 +364,7 @@ TEST_CASE( "selftest/tags", "" ) {
|
||||
std::string p5 = "[one][two]~[hide],[three]";
|
||||
|
||||
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.hasTag( "one" ) );
|
||||
@ -378,7 +378,7 @@ TEST_CASE( "selftest/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.hasTag( "one" ) );
|
||||
@ -395,7 +395,7 @@ TEST_CASE( "selftest/tags", "" ) {
|
||||
|
||||
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.hasTag( "one" ) );
|
||||
CHECK( oneTagWithExtras.hasTag( "two" ) == false );
|
||||
@ -404,7 +404,7 @@ TEST_CASE( "selftest/tags", "" ) {
|
||||
|
||||
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.hasTag( "one" ) == false );
|
||||
@ -412,7 +412,7 @@ TEST_CASE( "selftest/tags", "" ) {
|
||||
}
|
||||
|
||||
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.hasTag( "hide" ) );
|
||||
|
@ -82,13 +82,13 @@ namespace Catch {
|
||||
closeLabel( recordSections, sectionName );
|
||||
}
|
||||
|
||||
virtual void StartTestCase( const TestCaseInfo& testInfo ) {
|
||||
virtual void StartTestCase( const TestCase& testInfo ) {
|
||||
openLabel( recordTestCases, testInfo.getName() );
|
||||
}
|
||||
|
||||
virtual void Aborted(){}
|
||||
|
||||
virtual void EndTestCase( const TestCaseInfo& testInfo,
|
||||
virtual void EndTestCase( const TestCase& testInfo,
|
||||
const Totals&,
|
||||
const std::string&,
|
||||
const std::string& ) {
|
||||
@ -153,7 +153,7 @@ namespace Catch {
|
||||
MetaTestRunner( expectedResult ) );
|
||||
}
|
||||
|
||||
void operator()( const TestCaseInfo& testCase ) {
|
||||
void operator()( const TestCase& testCase ) {
|
||||
EmbeddedRunner runner;
|
||||
Totals totals = runner.runMatching( testCase.getName() );
|
||||
switch( m_expectedResult ) {
|
||||
|
Loading…
Reference in New Issue
Block a user