Replaced all file/ line pairings with SourceLineInfo

This commit is contained in:
Phil Nash 2012-05-08 19:16:18 +01:00
parent 81a122e66a
commit 5d1c8f2c6d
9 changed files with 73 additions and 118 deletions

View File

@ -44,12 +44,11 @@ public:
( (
const char* expr, const char* expr,
bool isNot, bool isNot,
const char* filename, const SourceLineInfo& lineInfo,
std::size_t line,
const char* macroName, const char* macroName,
const char* message = "" const char* message = ""
) )
: ResultInfo( expr, ResultWas::Unknown, isNot, filename, line, macroName, message ) : ResultInfo( expr, ResultWas::Unknown, isNot, lineInfo, macroName, message )
{ {
} }
@ -78,14 +77,12 @@ public:
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
void setFileAndLine void setLineInfo
( (
const std::string& filename, const SourceLineInfo& lineInfo
std::size_t line
) )
{ {
m_filename = filename; m_lineInfo = lineInfo;
m_line = line;
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@ -371,13 +368,12 @@ public:
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
ResultBuilder ResultBuilder
( (
const char* filename, const SourceLineInfo& lineInfo,
std::size_t line,
const char* macroName, const char* macroName,
const char* expr = "", const char* expr = "",
bool isNot = false bool isNot = false
) )
: m_result( expr, isNot, filename, line, macroName ), : m_result( expr, isNot, lineInfo, macroName ),
m_messageStream() m_messageStream()
{} {}
@ -573,12 +569,12 @@ inline bool isTrue
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_TEST( expr, isNot, stopOnFailure, macroName ) \ #define INTERNAL_CATCH_TEST( expr, isNot, stopOnFailure, macroName ) \
do{ try{ \ do{ try{ \
INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( __FILE__, __LINE__, macroName, #expr, isNot )->*expr ), stopOnFailure ); \ INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr, isNot )->*expr ), stopOnFailure ); \
if( Catch::isTrue( false ) ){ bool internal_catch_dummyResult = ( expr ); Catch::isTrue( internal_catch_dummyResult ); } \ if( Catch::isTrue( false ) ){ bool internal_catch_dummyResult = ( expr ); Catch::isTrue( internal_catch_dummyResult ); } \
}catch( Catch::TestFailureException& ){ \ }catch( Catch::TestFailureException& ){ \
throw; \ throw; \
} catch( ... ){ \ } catch( ... ){ \
INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( __FILE__, __LINE__, macroName, #expr ) << Catch::Hub::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), false ); \ INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::Hub::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), false ); \
throw; \ throw; \
}}while( Catch::isTrue( false ) ) }}while( Catch::isTrue( false ) )
@ -597,11 +593,11 @@ inline bool isTrue
try \ try \
{ \ { \
expr; \ expr; \
INTERNAL_CATCH_ACCEPT_EXPR( Catch::ResultBuilder( __FILE__, __LINE__, macroName, #expr ).setResultType( Catch::ResultWas::Ok ), stopOnFailure ); \ INTERNAL_CATCH_ACCEPT_EXPR( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ).setResultType( Catch::ResultWas::Ok ), stopOnFailure ); \
} \ } \
catch( ... ) \ catch( ... ) \
{ \ { \
INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( __FILE__, __LINE__, macroName, #expr ) << Catch::Hub::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), stopOnFailure ); \ INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::Hub::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), stopOnFailure ); \
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -609,7 +605,7 @@ inline bool isTrue
try \ try \
{ \ { \
expr; \ expr; \
INTERNAL_CATCH_ACCEPT_EXPR( Catch::ResultBuilder( __FILE__, __LINE__, macroName, #expr ).setResultType( Catch::ResultWas::DidntThrowException ), stopOnFailure ); \ INTERNAL_CATCH_ACCEPT_EXPR( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ).setResultType( Catch::ResultWas::DidntThrowException ), stopOnFailure ); \
} \ } \
catch( Catch::TestFailureException& ) \ catch( Catch::TestFailureException& ) \
{ \ { \
@ -617,7 +613,7 @@ inline bool isTrue
} \ } \
catch( exceptionType ) \ catch( exceptionType ) \
{ \ { \
INTERNAL_CATCH_ACCEPT_EXPR( Catch::ResultBuilder( __FILE__, __LINE__, macroName, #expr ).setResultType( Catch::ResultWas::Ok ), stopOnFailure ); \ INTERNAL_CATCH_ACCEPT_EXPR( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ).setResultType( Catch::ResultWas::Ok ), stopOnFailure ); \
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -625,12 +621,12 @@ inline bool isTrue
INTERNAL_CATCH_THROWS( expr, exceptionType, stopOnFailure, macroName ) \ INTERNAL_CATCH_THROWS( expr, exceptionType, stopOnFailure, macroName ) \
catch( ... ) \ catch( ... ) \
{ \ { \
INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( __FILE__, __LINE__, macroName, #expr ) << Catch::Hub::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), stopOnFailure ); \ INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::Hub::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), stopOnFailure ); \
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_MSG( reason, resultType, stopOnFailure, macroName ) \ #define INTERNAL_CATCH_MSG( reason, resultType, stopOnFailure, macroName ) \
Catch::Hub::getResultCapture().acceptExpression( ( Catch::ResultBuilder( __FILE__, __LINE__, macroName ) << reason ).setResultType( resultType ) ); Catch::Hub::getResultCapture().acceptExpression( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName ) << reason ).setResultType( resultType ) );
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_SCOPED_INFO( log ) \ #define INTERNAL_CATCH_SCOPED_INFO( log ) \
@ -640,11 +636,11 @@ inline bool isTrue
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CHECK_THAT( arg, matcher, stopOnFailure, macroName ) \ #define INTERNAL_CHECK_THAT( arg, matcher, stopOnFailure, macroName ) \
do{ try{ \ do{ try{ \
INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( __FILE__, __LINE__, macroName, #arg " " #matcher, false ).acceptMatcher( matcher, arg, #matcher ) ), stopOnFailure ); \ INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #arg " " #matcher, false ).acceptMatcher( matcher, arg, #matcher ) ), stopOnFailure ); \
}catch( Catch::TestFailureException& ){ \ }catch( Catch::TestFailureException& ){ \
throw; \ throw; \
} catch( ... ){ \ } catch( ... ){ \
INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( __FILE__, __LINE__, macroName, #arg " " #matcher ) << Catch::Hub::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), false ); \ INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #arg " " #matcher ) << Catch::Hub::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), false ); \
throw; \ throw; \
}}while( Catch::isTrue( false ) ) }}while( Catch::isTrue( false ) )

View File

@ -1,15 +1,10 @@
/* /*
* catch_common.h
* Catch
*
* Created by Phil on 29/10/2010. * Created by Phil on 29/10/2010.
* Copyright 2010 Two Blue Cubes Ltd. All rights reserved. * Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
* *
* Distributed under the Boost Software License, Version 1.0. (See accompanying * Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
*/ */
#ifndef TWOBLUECUBES_CATCH_COMMON_H_INCLUDED #ifndef TWOBLUECUBES_CATCH_COMMON_H_INCLUDED
#define TWOBLUECUBES_CATCH_COMMON_H_INCLUDED #define TWOBLUECUBES_CATCH_COMMON_H_INCLUDED
@ -32,24 +27,16 @@
namespace Catch namespace Catch
{ {
class NonCopyable class NonCopyable {
{
NonCopyable( const NonCopyable& ); NonCopyable( const NonCopyable& );
void operator = ( const NonCopyable& ); void operator = ( const NonCopyable& );
protected: protected:
NonCopyable(){} NonCopyable() {}
virtual ~NonCopyable() {} virtual ~NonCopyable() {}
}; };
typedef char NoType;
typedef int YesType;
// create a T for use in sizeof expressions
template<typename T> T Synth();
template<typename ContainerT> template<typename ContainerT>
inline void deleteAll( ContainerT& container ) inline void deleteAll( ContainerT& container ) {
{
typename ContainerT::const_iterator it = container.begin(); typename ContainerT::const_iterator it = container.begin();
typename ContainerT::const_iterator itEnd = container.end(); typename ContainerT::const_iterator itEnd = container.end();
for(; it != itEnd; ++it ) for(; it != itEnd; ++it )
@ -58,8 +45,7 @@ namespace Catch
} }
} }
template<typename AssociativeContainerT> template<typename AssociativeContainerT>
inline void deleteAllValues( AssociativeContainerT& container ) inline void deleteAllValues( AssociativeContainerT& container ) {
{
typename AssociativeContainerT::const_iterator it = container.begin(); typename AssociativeContainerT::const_iterator it = container.begin();
typename AssociativeContainerT::const_iterator itEnd = container.end(); typename AssociativeContainerT::const_iterator itEnd = container.end();
for(; it != itEnd; ++it ) for(; it != itEnd; ++it )
@ -69,34 +55,36 @@ namespace Catch
} }
template<typename ContainerT, typename Function> template<typename ContainerT, typename Function>
inline void forEach( ContainerT& container, Function function ) inline void forEach( ContainerT& container, Function function ) {
{
std::for_each( container.begin(), container.end(), function ); std::for_each( container.begin(), container.end(), function );
} }
template<typename ContainerT, typename Function> template<typename ContainerT, typename Function>
inline void forEach( const ContainerT& container, Function function ) inline void forEach( const ContainerT& container, Function function ) {
{
std::for_each( container.begin(), container.end(), function ); std::for_each( container.begin(), container.end(), function );
} }
struct SourceLineInfo struct SourceLineInfo
{ {
SourceLineInfo SourceLineInfo() : line( 0 ){}
( SourceLineInfo( const std::string& file, std::size_t line )
const std::string& file,
std::size_t line
)
: file( file ), : file( file ),
line( line ) line( line )
{} {}
SourceLineInfo( const SourceLineInfo& other )
: file( other.file ),
line( other.line )
{}
void swap( SourceLineInfo& other ){
file.swap( other.file );
std::swap( line, other.line );
}
std::string file; std::string file;
std::size_t line; std::size_t line;
}; };
inline std::ostream& operator << ( std::ostream& os, const SourceLineInfo& info ) inline std::ostream& operator << ( std::ostream& os, const SourceLineInfo& info ) {
{
#ifndef __GNUG__ #ifndef __GNUG__
os << info.file << "(" << info.line << "): "; os << info.file << "(" << info.line << "): ";
#else #else
@ -106,8 +94,7 @@ namespace Catch
} }
ATTRIBUTE_NORETURN ATTRIBUTE_NORETURN
inline void throwLogicError( const std::string& message, const std::string& file, long line ) inline void throwLogicError( const std::string& message, const std::string& file, long line ) {
{
std::ostringstream oss; std::ostringstream oss;
oss << "Internal Catch error: '" << message << "' at: " << SourceLineInfo( file, line ); oss << "Internal Catch error: '" << message << "' at: " << SourceLineInfo( file, line );
throw std::logic_error( oss.str() ); throw std::logic_error( oss.str() );
@ -115,6 +102,7 @@ namespace Catch
} }
#define CATCH_INTERNAL_ERROR( msg ) throwLogicError( msg, __FILE__, __LINE__ ); #define CATCH_INTERNAL_ERROR( msg ) throwLogicError( msg, __FILE__, __LINE__ );
#define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FILE__, __LINE__ )
#endif // TWOBLUECUBES_CATCH_COMMON_H_INCLUDED #endif // TWOBLUECUBES_CATCH_COMMON_H_INCLUDED

View File

@ -35,8 +35,7 @@ namespace Catch
virtual bool sectionStarted virtual bool sectionStarted
( const std::string& name, ( const std::string& name,
const std::string& description, const std::string& description,
const std::string& filename, const SourceLineInfo& lineInfo,
std::size_t line,
Counts& assertions Counts& assertions
) = 0; ) = 0;
virtual void sectionEnded virtual void sectionEnded

View File

@ -25,8 +25,6 @@ namespace Catch
ResultInfo ResultInfo
() ()
: m_macroName(), : m_macroName(),
m_filename(),
m_line( 0 ),
m_expr(), m_expr(),
m_lhs(), m_lhs(),
m_rhs(), m_rhs(),
@ -42,14 +40,12 @@ namespace Catch
const char* expr, const char* expr,
ResultWas::OfType result, ResultWas::OfType result,
bool isNot, bool isNot,
const char* filename, const SourceLineInfo& lineInfo,
std::size_t line,
const char* macroName, const char* macroName,
const char* message const char* message
) )
: m_macroName( macroName ), : m_macroName( macroName ),
m_filename( filename ), m_lineInfo( lineInfo ),
m_line( line ),
m_expr( expr ), m_expr( expr ),
m_lhs(), m_lhs(),
m_rhs(), m_rhs(),
@ -137,7 +133,7 @@ namespace Catch
() ()
const const
{ {
return m_filename; return m_lineInfo.file;
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@ -145,7 +141,7 @@ namespace Catch
() ()
const const
{ {
return m_line; return m_lineInfo.line;
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@ -191,8 +187,7 @@ namespace Catch
protected: protected:
std::string m_macroName; std::string m_macroName;
std::string m_filename; SourceLineInfo m_lineInfo;
std::size_t m_line;
std::string m_expr, m_lhs, m_rhs, m_op; std::string m_expr, m_lhs, m_rhs, m_op;
std::string m_message; std::string m_message;
ResultWas::OfType m_result; ResultWas::OfType m_result;

View File

@ -147,8 +147,7 @@ namespace Catch
do do
{ {
m_reporter->StartGroup( "test case run" ); m_reporter->StartGroup( "test case run" );
m_currentResult.setFileAndLine( m_runningTest->getTestCaseInfo().getFilename(), m_currentResult.setLineInfo( m_runningTest->getTestCaseInfo().getLineInfo() );
m_runningTest->getTestCaseInfo().getLine() );
runCurrentTest( redirectedCout, redirectedCerr ); runCurrentTest( redirectedCout, redirectedCerr );
m_reporter->EndGroup( "test case run", m_totals - prevTotals ); m_reporter->EndGroup( "test case run", m_totals - prevTotals );
} }
@ -247,18 +246,17 @@ namespace Catch
( (
const std::string& name, const std::string& name,
const std::string& description, const std::string& description,
const std::string& filename, const SourceLineInfo& lineInfo,
std::size_t line,
Counts& assertions Counts& assertions
) )
{ {
std::ostringstream oss; std::ostringstream oss;
oss << name << "@" << SourceLineInfo( filename, line ); oss << name << "@" << lineInfo;
if( !m_runningTest->addSection( oss.str() ) ) if( !m_runningTest->addSection( oss.str() ) )
return false; return false;
m_currentResult.setFileAndLine( filename, line ); m_currentResult.setLineInfo( lineInfo );
m_reporter->StartSection( name, description ); m_reporter->StartSection( name, description );
assertions = m_totals.assertions; assertions = m_totals.assertions;

View File

@ -28,11 +28,10 @@ namespace Catch
( (
const std::string& name, const std::string& name,
const std::string& description, const std::string& description,
const std::string& filename, const SourceLineInfo& lineInfo
std::size_t line
) )
: m_name( name ), : m_name( name ),
m_sectionIncluded( Hub::getResultCapture().sectionStarted( name, description, filename, line, m_assertions ) ) m_sectionIncluded( Hub::getResultCapture().sectionStarted( name, description, lineInfo, m_assertions ) )
{ {
} }
@ -62,6 +61,6 @@ namespace Catch
} // end namespace Catch } // end namespace Catch
#define INTERNAL_CATCH_SECTION( name, desc ) \ #define INTERNAL_CATCH_SECTION( name, desc ) \
if( Catch::Section INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::Section( name, desc, __FILE__, __LINE__ ) ) if( Catch::Section INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::Section( name, desc, CATCH_INTERNAL_LINEINFO ) )
#endif // TWOBLUECUBES_CATCH_SECTION_HPP_INCLUDED #endif // TWOBLUECUBES_CATCH_SECTION_HPP_INCLUDED

View File

@ -28,14 +28,12 @@ namespace Catch
ITestCase* testCase, ITestCase* testCase,
const char* name, const char* name,
const char* description, const char* description,
const char* filename, const SourceLineInfo& lineInfo
std::size_t line
) )
: m_test( testCase ), : m_test( testCase ),
m_name( name ), m_name( name ),
m_description( description ), m_description( description ),
m_filename( filename ), m_lineInfo( lineInfo )
m_line( line )
{ {
} }
@ -44,9 +42,7 @@ namespace Catch
() ()
: m_test( NULL ), : m_test( NULL ),
m_name(), m_name(),
m_description(), m_description()
m_filename(),
m_line( 0 )
{ {
} }
@ -58,8 +54,7 @@ namespace Catch
: m_test( other.m_test->clone() ), : m_test( other.m_test->clone() ),
m_name( other.m_name ), m_name( other.m_name ),
m_description( other.m_description ), m_description( other.m_description ),
m_filename( other.m_filename ), m_lineInfo( other.m_lineInfo )
m_line( other.m_line )
{ {
} }
@ -72,8 +67,7 @@ namespace Catch
: m_test( other.m_test->clone() ), : m_test( other.m_test->clone() ),
m_name( name ), m_name( name ),
m_description( other.m_description ), m_description( other.m_description ),
m_filename( other.m_filename ), m_lineInfo( other.m_lineInfo )
m_line( other.m_line )
{ {
} }
@ -120,19 +114,11 @@ namespace Catch
} }
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
const std::string& getFilename const SourceLineInfo& getLineInfo
() ()
const const
{ {
return m_filename; return m_lineInfo;
}
///////////////////////////////////////////////////////////////////////
std::size_t getLine
()
const
{
return m_line;
} }
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
@ -152,6 +138,7 @@ namespace Catch
std::swap( m_test, other.m_test ); std::swap( m_test, other.m_test );
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 );
} }
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
@ -178,9 +165,7 @@ namespace Catch
ITestCase* m_test; ITestCase* m_test;
std::string m_name; std::string m_name;
std::string m_description; std::string m_description;
std::string m_filename; SourceLineInfo m_lineInfo;
std::size_t m_line;
}; };
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////

View File

@ -51,8 +51,8 @@ namespace Catch
{ {
const TestCaseInfo& prev = *m_functions.find( testInfo ); const TestCaseInfo& 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.getFilename(), prev.getLine() ) << "\n" << "\tFirst seen at " << SourceLineInfo( prev.getLineInfo() ) << "\n"
<< "\tRedefined at " << SourceLineInfo( testInfo.getFilename(), testInfo.getLine() ) << std::endl; << "\tRedefined at " << SourceLineInfo( testInfo.getLineInfo() ) << std::endl;
exit(1); exit(1);
} }
} }
@ -158,11 +158,10 @@ namespace Catch
TestFunction function, TestFunction function,
const char* name, const char* name,
const char* description, const char* description,
const char* filename, const SourceLineInfo& lineInfo
std::size_t line
) )
{ {
registerTestCase( new FreeFunctionTestCase( function ), name, description, filename, line ); registerTestCase( new FreeFunctionTestCase( function ), name, description, lineInfo );
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@ -177,11 +176,10 @@ namespace Catch
ITestCase* testCase, ITestCase* testCase,
const char* name, const char* name,
const char* description, const char* description,
const char* filename, const SourceLineInfo& lineInfo
std::size_t line
) )
{ {
Hub::getTestCaseRegistry().registerTest( TestCaseInfo( testCase, name, description, filename, line ) ); Hub::getTestCaseRegistry().registerTest( TestCaseInfo( testCase, name, description, lineInfo ) );
} }
} // end namespace Catch } // end namespace Catch

View File

@ -80,8 +80,7 @@ struct AutoReg
( TestFunction function, ( TestFunction function,
const char* name, const char* name,
const char* description, const char* description,
const char* filename, const SourceLineInfo& lineInfo
std::size_t line
); );
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@ -91,11 +90,10 @@ struct AutoReg
void (C::*method)(), void (C::*method)(),
const char* name, const char* name,
const char* description, const char* description,
const char* filename, const SourceLineInfo& lineInfo
std::size_t line
) )
{ {
registerTestCase( new MethodTestCase<C>( method ), name, description, filename, line ); registerTestCase( new MethodTestCase<C>( method ), name, description, lineInfo );
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@ -104,8 +102,7 @@ struct AutoReg
ITestCase* testCase, ITestCase* testCase,
const char* name, const char* name,
const char* description, const char* description,
const char* filename, const SourceLineInfo& lineInfo
std::size_t line
); );
~AutoReg ~AutoReg
@ -124,18 +121,18 @@ private:
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_TESTCASE( Name, Desc ) \ #define INTERNAL_CATCH_TESTCASE( Name, Desc ) \
static void INTERNAL_CATCH_UNIQUE_NAME( catch_internal_TestFunction )(); \ static void INTERNAL_CATCH_UNIQUE_NAME( catch_internal_TestFunction )(); \
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &INTERNAL_CATCH_UNIQUE_NAME( catch_internal_TestFunction ), Name, Desc, __FILE__, __LINE__ ); }\ namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &INTERNAL_CATCH_UNIQUE_NAME( catch_internal_TestFunction ), Name, Desc, CATCH_INTERNAL_LINEINFO ); }\
static void INTERNAL_CATCH_UNIQUE_NAME( catch_internal_TestFunction )() static void INTERNAL_CATCH_UNIQUE_NAME( catch_internal_TestFunction )()
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_TESTCASE_NORETURN( Name, Desc ) \ #define INTERNAL_CATCH_TESTCASE_NORETURN( Name, Desc ) \
static void INTERNAL_CATCH_UNIQUE_NAME( catch_internal_TestFunction )() ATTRIBUTE_NORETURN; \ static void INTERNAL_CATCH_UNIQUE_NAME( catch_internal_TestFunction )() ATTRIBUTE_NORETURN; \
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &INTERNAL_CATCH_UNIQUE_NAME( catch_internal_TestFunction ), Name, Desc, __FILE__, __LINE__ ); }\ namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &INTERNAL_CATCH_UNIQUE_NAME( catch_internal_TestFunction ), Name, Desc, CATCH_INTERNAL_LINEINFO ); }\
static void INTERNAL_CATCH_UNIQUE_NAME( catch_internal_TestFunction )() static void INTERNAL_CATCH_UNIQUE_NAME( catch_internal_TestFunction )()
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, Name, Desc ) \ #define CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, Name, Desc ) \
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, Name, Desc, __FILE__, __LINE__ ); } namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, Name, Desc, CATCH_INTERNAL_LINEINFO ); }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define TEST_CASE_METHOD( ClassName, TestName, Desc )\ #define TEST_CASE_METHOD( ClassName, TestName, Desc )\
@ -143,7 +140,7 @@ private:
struct INTERNAL_CATCH_UNIQUE_NAME( Catch_FixtureWrapper ) : ClassName{ \ struct INTERNAL_CATCH_UNIQUE_NAME( Catch_FixtureWrapper ) : ClassName{ \
void test(); \ void test(); \
}; \ }; \
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &INTERNAL_CATCH_UNIQUE_NAME( Catch_FixtureWrapper )::test, TestName, Desc, __FILE__, __LINE__ ); \ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &INTERNAL_CATCH_UNIQUE_NAME( Catch_FixtureWrapper )::test, TestName, Desc, CATCH_INTERNAL_LINEINFO ); \
} \ } \
void INTERNAL_CATCH_UNIQUE_NAME( Catch_FixtureWrapper )::test() void INTERNAL_CATCH_UNIQUE_NAME( Catch_FixtureWrapper )::test()