Regen single include

This commit is contained in:
Phil Nash 2012-11-04 21:39:38 +00:00
parent b323fc7e6c
commit 88b70828f2

View File

@ -1,5 +1,5 @@
/* /*
* Generated: 2012-10-31 18:04:01.157950 * Generated: 2012-11-04 21:39:24.756874
* ---------------------------------------------------------- * ----------------------------------------------------------
* 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.
@ -126,24 +126,14 @@ namespace Catch {
: file( _file ), : file( _file ),
line( _line ) line( _line )
{} {}
SourceLineInfo( const std::string& _function, const std::string& _file, std::size_t _line )
: function( _function ),
file( _file ),
line( _line )
{}
SourceLineInfo( const SourceLineInfo& other ) SourceLineInfo( const SourceLineInfo& other )
: file( other.file ), : file( other.file ),
line( other.line ) line( other.line )
{} {}
void swap( SourceLineInfo& other ){
file.swap( other.file );
std::swap( line, other.line );
}
bool empty() const { bool empty() const {
return file.empty(); return file.empty();
} }
std::string function;
std::string file; std::string file;
std::size_t line; std::size_t line;
}; };
@ -399,13 +389,15 @@ struct AutoReg {
template<typename C> template<typename C>
AutoReg( void (C::*method)(), AutoReg( void (C::*method)(),
const char* className,
const char* name, const char* name,
const char* description, const char* description,
const SourceLineInfo& lineInfo ) { const SourceLineInfo& lineInfo ) {
registerTestCase( new MethodTestCase<C>( method ), name, description, lineInfo ); registerTestCase( new MethodTestCase<C>( method ), className, name, description, lineInfo );
} }
void registerTestCase( ITestCase* testCase, void registerTestCase( ITestCase* testCase,
const char* className,
const char* name, const char* name,
const char* description, const char* description,
const SourceLineInfo& lineInfo ); const SourceLineInfo& lineInfo );
@ -433,7 +425,7 @@ private:
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, Name, Desc ) \ #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, Name, Desc ) \
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, Name, Desc, CATCH_INTERNAL_LINEINFO ); } namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Name, Desc, CATCH_INTERNAL_LINEINFO ); }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define TEST_CASE_METHOD( ClassName, TestName, Desc )\ #define TEST_CASE_METHOD( ClassName, TestName, Desc )\
@ -441,7 +433,7 @@ private:
struct INTERNAL_CATCH_UNIQUE_NAME( TestCaseMethod_catch_internal_ ) : ClassName{ \ struct INTERNAL_CATCH_UNIQUE_NAME( TestCaseMethod_catch_internal_ ) : ClassName{ \
void test(); \ void test(); \
}; \ }; \
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &INTERNAL_CATCH_UNIQUE_NAME( TestCaseMethod_catch_internal_ )::test, TestName, Desc, CATCH_INTERNAL_LINEINFO ); \ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &INTERNAL_CATCH_UNIQUE_NAME( TestCaseMethod_catch_internal_ )::test, #ClassName, TestName, Desc, CATCH_INTERNAL_LINEINFO ); \
} \ } \
void INTERNAL_CATCH_UNIQUE_NAME( TestCaseMethod_catch_internal_ )::test() void INTERNAL_CATCH_UNIQUE_NAME( TestCaseMethod_catch_internal_ )::test()
@ -688,7 +680,7 @@ namespace Catch {
struct AssertionInfo struct AssertionInfo
{ {
AssertionInfo() {} AssertionInfo() {}
AssertionInfo( const std::string& _macroName, const SourceLineInfo& _lineInfo, const std::string& _capturedExpression, bool _shouldNegate ) AssertionInfo( const std::string& _macroName, const SourceLineInfo& _lineInfo, const std::string& _capturedExpression = "", bool _shouldNegate = false )
: macroName( _macroName ), : macroName( _macroName ),
lineInfo( _lineInfo ), lineInfo( _lineInfo ),
capturedExpression( _capturedExpression ) capturedExpression( _capturedExpression )
@ -1128,7 +1120,6 @@ namespace Catch {
virtual void popScopedInfo( ScopedInfo* scopedInfo ) = 0; virtual void popScopedInfo( ScopedInfo* scopedInfo ) = 0;
virtual bool shouldDebugBreak() const = 0; virtual bool shouldDebugBreak() const = 0;
virtual void acceptAssertionInfo( const AssertionInfo& assertionInfo ) = 0;
virtual ResultAction::Value acceptExpression( const ExpressionResultBuilder& assertionResult, const AssertionInfo& assertionInfo ) = 0; virtual ResultAction::Value acceptExpression( const ExpressionResultBuilder& assertionResult, const AssertionInfo& assertionInfo ) = 0;
virtual std::string getCurrentTestName() const = 0; virtual std::string getCurrentTestName() const = 0;
@ -1269,14 +1260,17 @@ namespace Catch {
TestCaseInfo(); TestCaseInfo();
TestCaseInfo( ITestCase* testCase, TestCaseInfo( ITestCase* testCase,
const char* name, const std::string& className,
const char* description, const std::string& name,
const std::string& description,
const SourceLineInfo& lineInfo ); const SourceLineInfo& lineInfo );
TestCaseInfo( const TestCaseInfo& other, const std::string& name ); TestCaseInfo( const TestCaseInfo& other, const std::string& name );
TestCaseInfo( const TestCaseInfo& other ); TestCaseInfo( const TestCaseInfo& other );
void invoke() const; void invoke() const;
const std::string& getClassName() const;
const std::string& getName() const; const std::string& getName() const;
const std::string& getDescription() const; const std::string& getDescription() const;
const SourceLineInfo& getLineInfo() const; const SourceLineInfo& getLineInfo() const;
@ -1292,6 +1286,7 @@ namespace Catch {
private: private:
Ptr<ITestCase> m_test; Ptr<ITestCase> m_test;
std::string m_className;
std::string m_name; std::string m_name;
std::string m_description; std::string m_description;
std::set<std::string> m_tags; std::set<std::string> m_tags;
@ -1369,6 +1364,8 @@ namespace Catch {
m_remainder += c; m_remainder += c;
} }
TagExtracter& operator=(const TagExtracter&);
std::set<std::string>& m_tags; std::set<std::string>& m_tags;
std::string m_remainder; std::string m_remainder;
}; };
@ -1472,6 +1469,8 @@ namespace Catch {
m_exp.m_tagSets.push_back( m_currentTagSet ); m_exp.m_tagSets.push_back( m_currentTagSet );
} }
TagExpressionParser& operator=(const TagExpressionParser&);
bool m_isNegated; bool m_isNegated;
TagSet m_currentTagSet; TagSet m_currentTagSet;
TagExpression& m_exp; TagExpression& m_exp;
@ -2091,7 +2090,6 @@ inline bool isTrue( bool value ){ return value; }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_ACCEPT_INFO( expr, macroName, shouldNegate ) \ #define INTERNAL_CATCH_ACCEPT_INFO( expr, macroName, shouldNegate ) \
Catch::AssertionInfo INTERNAL_CATCH_ASSERTIONINFO_NAME( macroName, CATCH_INTERNAL_LINEINFO, expr, shouldNegate ); Catch::AssertionInfo INTERNAL_CATCH_ASSERTIONINFO_NAME( macroName, CATCH_INTERNAL_LINEINFO, expr, shouldNegate );
// !TBD Catch::getResultCapture().acceptAssertionInfo( INTERNAL_CATCH_ASSERTIONINFO_NAME )
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_TEST( expr, shouldNegate, stopOnFailure, macroName ) \ #define INTERNAL_CATCH_TEST( expr, shouldNegate, stopOnFailure, macroName ) \
@ -3970,7 +3968,6 @@ namespace Catch {
do { do {
do { do {
m_assertionInfo.lineInfo = m_runningTest->getTestCaseInfo().getLineInfo();
runCurrentTest( redirectedCout, redirectedCerr ); runCurrentTest( redirectedCout, redirectedCerr );
} }
while( m_runningTest->hasUntestedSections() && !aborting() ); while( m_runningTest->hasUntestedSections() && !aborting() );
@ -3992,14 +3989,9 @@ namespace Catch {
private: // IResultCapture private: // IResultCapture
virtual void acceptAssertionInfo( const AssertionInfo& assertionInfo ) {
m_assertionInfo = assertionInfo;
}
virtual ResultAction::Value acceptExpression( const ExpressionResultBuilder& assertionResult, const AssertionInfo& assertionInfo ) { virtual ResultAction::Value acceptExpression( const ExpressionResultBuilder& assertionResult, const AssertionInfo& assertionInfo ) {
m_assertionInfo = assertionInfo; m_lastAssertionInfo = assertionInfo;
m_currentResult = assertionResult; return actOnCurrentResult( assertionResult.buildResult( assertionInfo ) );
return actOnCurrentResult();
} }
virtual void testEnded( const AssertionResult& result ) { virtual void testEnded( const AssertionResult& result ) {
@ -4013,7 +4005,7 @@ namespace Catch {
std::vector<ScopedInfo*>::const_iterator it = m_scopedInfos.begin(); std::vector<ScopedInfo*>::const_iterator it = m_scopedInfos.begin();
std::vector<ScopedInfo*>::const_iterator itEnd = m_scopedInfos.end(); std::vector<ScopedInfo*>::const_iterator itEnd = m_scopedInfos.end();
for(; it != itEnd; ++it ) for(; it != itEnd; ++it )
m_reporter->Result( (*it)->buildResult( m_assertionInfo ) ); m_reporter->Result( (*it)->buildResult( m_lastAssertionInfo ) );
} }
{ {
std::vector<AssertionResult>::const_iterator it = m_assertionResults.begin(); std::vector<AssertionResult>::const_iterator it = m_assertionResults.begin();
@ -4043,7 +4035,8 @@ namespace Catch {
if( !m_runningTest->addSection( oss.str() ) ) if( !m_runningTest->addSection( oss.str() ) )
return false; return false;
m_assertionInfo.lineInfo = lineInfo; m_lastAssertionInfo.lineInfo = lineInfo;
m_reporter->StartSection( name, description ); m_reporter->StartSection( name, description );
assertions = m_totals.assertions; assertions = m_totals.assertions;
@ -4094,13 +4087,10 @@ namespace Catch {
private: private:
ResultAction::Value actOnCurrentResult() { ResultAction::Value actOnCurrentResult( const AssertionResult& result ) {
m_lastResult = m_currentResult.buildResult( m_assertionInfo ); m_lastResult = result;
testEnded( m_lastResult ); testEnded( m_lastResult );
m_currentResult = ExpressionResultBuilder();
m_assertionInfo = AssertionInfo();
ResultAction::Value action = ResultAction::None; ResultAction::Value action = ResultAction::None;
if( !m_lastResult.ok() ) { if( !m_lastResult.ok() ) {
@ -4115,6 +4105,7 @@ 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() );
m_runningTest->reset(); m_runningTest->reset();
Counts prevAssertions = m_totals.assertions; Counts prevAssertions = m_totals.assertions;
if( m_reporter->shouldRedirectStdout() ) { if( m_reporter->shouldRedirectStdout() ) {
@ -4138,10 +4129,9 @@ namespace Catch {
// This just means the test was aborted due to failure // This just means the test was aborted due to failure
} }
catch(...) { catch(...) {
m_currentResult ExpressionResultBuilder exResult( ResultWas::ThrewException );
.setResultType( ResultWas::ThrewException ) exResult << translateActiveException();
<< translateActiveException(); actOnCurrentResult( exResult.buildResult( m_lastAssertionInfo ) );
actOnCurrentResult();
} }
m_assertionResults.clear(); m_assertionResults.clear();
} }
@ -4149,7 +4139,6 @@ namespace Catch {
private: private:
IMutableContext& m_context; IMutableContext& m_context;
RunningTest* m_runningTest; RunningTest* m_runningTest;
ExpressionResultBuilder m_currentResult;
AssertionResult m_lastResult; AssertionResult m_lastResult;
const Config& m_config; const Config& m_config;
@ -4160,7 +4149,7 @@ namespace Catch {
IRunner* m_prevRunner; IRunner* m_prevRunner;
IResultCapture* m_prevResultCapture; IResultCapture* m_prevResultCapture;
const IConfig* m_prevConfig; const IConfig* m_prevConfig;
AssertionInfo m_assertionInfo; AssertionInfo m_lastAssertionInfo;
}; };
} // end namespace Catch } // end namespace Catch
@ -4515,22 +4504,37 @@ namespace Catch {
TestFunction m_fun; TestFunction m_fun;
}; };
inline std::string extractClassName( const std::string& classOrQualifiedMethodName ) {
std::string className = classOrQualifiedMethodName;
if( className[0] == '&' )
{
std::size_t lastColons = className.rfind( "::" );
std::size_t penultimateColons = className.rfind( "::", lastColons-1 );
if( penultimateColons == std::string::npos )
penultimateColons = 1;
className = className.substr( penultimateColons, lastColons-penultimateColons );
}
return className;
}
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
AutoReg::AutoReg( TestFunction function, AutoReg::AutoReg( TestFunction function,
const char* name, const char* name,
const char* description, const char* description,
const SourceLineInfo& lineInfo ) { const SourceLineInfo& lineInfo ) {
registerTestCase( new FreeFunctionTestCase( function ), name, description, lineInfo ); registerTestCase( new FreeFunctionTestCase( function ), "global", name, description, lineInfo );
} }
AutoReg::~AutoReg() {} AutoReg::~AutoReg() {}
void AutoReg::registerTestCase( ITestCase* testCase, void AutoReg::registerTestCase( ITestCase* testCase,
const char* classOrQualifiedMethodName,
const char* name, const char* name,
const char* description, const char* description,
const SourceLineInfo& lineInfo ) { const SourceLineInfo& lineInfo ) {
getMutableRegistryHub().registerTest( TestCaseInfo( testCase, name, description, lineInfo ) );
getMutableRegistryHub().registerTest( TestCaseInfo( testCase, extractClassName( classOrQualifiedMethodName ), name, description, lineInfo ) );
} }
} // end namespace Catch } // end namespace Catch
@ -4710,8 +4714,6 @@ namespace Catch {
: m_lineInfo( lineInfo ) { : m_lineInfo( lineInfo ) {
std::ostringstream oss; std::ostringstream oss;
oss << lineInfo << "function "; oss << lineInfo << "function ";
if( !lineInfo.function.empty() )
oss << lineInfo.function << " ";
oss << "not implemented"; oss << "not implemented";
m_what = oss.str(); m_what = oss.str();
} }
@ -4883,7 +4885,7 @@ namespace Catch {
if( isatty( fileno(stdout) ) ) { if( isatty( fileno(stdout) ) ) {
switch( colour ) { switch( colour ) {
case TextColour::FileName: case TextColour::FileName:
std::cout << colourEscape << "[0m"; // white std::cout << colourEscape << "[0m"; // white/ normal
break; break;
case TextColour::ResultError: case TextColour::ResultError:
std::cout << colourEscape << "[1;31m"; // bold red std::cout << colourEscape << "[1;31m"; // bold red
@ -4904,7 +4906,7 @@ namespace Catch {
std::cout << colourEscape << "[0;33m"; // yellow std::cout << colourEscape << "[0;33m"; // yellow
break; break;
case TextColour::None: case TextColour::None:
std::cout << colourEscape << "[0m"; // reset to white std::cout << colourEscape << "[0m"; // reset
} }
} }
} }
@ -5217,10 +5219,12 @@ namespace Catch {
namespace Catch { namespace Catch {
TestCaseInfo::TestCaseInfo( ITestCase* testCase, TestCaseInfo::TestCaseInfo( ITestCase* testCase,
const char* name, const std::string& className,
const char* description, const std::string& name,
const std::string& description,
const SourceLineInfo& lineInfo ) const SourceLineInfo& lineInfo )
: m_test( testCase ), : m_test( testCase ),
m_className( className ),
m_name( name ), m_name( name ),
m_description( description ), m_description( description ),
m_lineInfo( lineInfo ), m_lineInfo( lineInfo ),
@ -5233,6 +5237,7 @@ namespace Catch {
TestCaseInfo::TestCaseInfo() TestCaseInfo::TestCaseInfo()
: m_test( NULL ), : m_test( NULL ),
m_className(),
m_name(), m_name(),
m_description(), m_description(),
m_isHidden( false ) m_isHidden( false )
@ -5240,6 +5245,7 @@ namespace Catch {
TestCaseInfo::TestCaseInfo( const TestCaseInfo& other, const std::string& name ) TestCaseInfo::TestCaseInfo( const TestCaseInfo& other, const std::string& name )
: m_test( other.m_test ), : m_test( other.m_test ),
m_className( other.m_className ),
m_name( name ), m_name( name ),
m_description( other.m_description ), m_description( other.m_description ),
m_tags( other.m_tags ), m_tags( other.m_tags ),
@ -5249,6 +5255,7 @@ namespace Catch {
TestCaseInfo::TestCaseInfo( const TestCaseInfo& other ) TestCaseInfo::TestCaseInfo( const TestCaseInfo& other )
: m_test( other.m_test ), : m_test( other.m_test ),
m_className( other.m_className ),
m_name( other.m_name ), m_name( other.m_name ),
m_description( other.m_description ), m_description( other.m_description ),
m_tags( other.m_tags ), m_tags( other.m_tags ),
@ -5260,14 +5267,15 @@ namespace Catch {
m_test->invoke(); m_test->invoke();
} }
const std::string& TestCaseInfo::getClassName() const {
return m_className;
}
const std::string& TestCaseInfo::getName() const { const std::string& TestCaseInfo::getName() const {
return m_name; return m_name;
} }
const std::string& TestCaseInfo::getDescription() const { const std::string& TestCaseInfo::getDescription() const {
return m_description; return m_description;
} }
const SourceLineInfo& TestCaseInfo::getLineInfo() const { const SourceLineInfo& TestCaseInfo::getLineInfo() const {
return m_lineInfo; return m_lineInfo;
} }
@ -5290,13 +5298,16 @@ namespace Catch {
void TestCaseInfo::swap( TestCaseInfo& other ) { void TestCaseInfo::swap( TestCaseInfo& other ) {
m_test.swap( other.m_test ); m_test.swap( other.m_test );
m_className.swap( other.m_className );
m_name.swap( other.m_name ); m_name.swap( other.m_name );
m_description.swap( other.m_description ); m_description.swap( other.m_description );
m_lineInfo.swap( other.m_lineInfo ); std::swap( m_lineInfo, other.m_lineInfo );
} }
bool TestCaseInfo::operator == ( const TestCaseInfo& other ) const { bool TestCaseInfo::operator == ( const TestCaseInfo& other ) const {
return m_test.get() == other.m_test.get() && m_name == other.m_name; 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 TestCaseInfo::operator < ( const TestCaseInfo& other ) const {
@ -6018,7 +6029,10 @@ namespace Catch {
struct TestCaseStats { struct TestCaseStats {
TestCaseStats( const std::string& name = std::string() ) :m_name( name ){} TestCaseStats( const std::string& className, const std::string& name )
: m_className( className ),
m_name( name )
{}
double m_timeInSeconds; double m_timeInSeconds;
std::string m_status; std::string m_status;
@ -6086,7 +6100,7 @@ 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::TestCaseInfo& testInfo ) {
m_currentStats->m_testCaseStats.push_back( TestCaseStats( testInfo.getName() ) ); m_currentStats->m_testCaseStats.push_back( TestCaseStats( testInfo.getClassName(), testInfo.getName() ) );
} }
virtual void Result( const Catch::AssertionResult& assertionResult ) { virtual void Result( const Catch::AssertionResult& assertionResult ) {