mirror of https://github.com/catchorg/Catch2.git
Replaced all file/ line pairings with SourceLineInfo
This commit is contained in:
parent
81a122e66a
commit
5d1c8f2c6d
|
@ -44,12 +44,11 @@ public:
|
|||
(
|
||||
const char* expr,
|
||||
bool isNot,
|
||||
const char* filename,
|
||||
std::size_t line,
|
||||
const SourceLineInfo& lineInfo,
|
||||
const char* macroName,
|
||||
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,
|
||||
std::size_t line
|
||||
const SourceLineInfo& lineInfo
|
||||
)
|
||||
{
|
||||
m_filename = filename;
|
||||
m_line = line;
|
||||
m_lineInfo = lineInfo;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
@ -371,13 +368,12 @@ public:
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
ResultBuilder
|
||||
(
|
||||
const char* filename,
|
||||
std::size_t line,
|
||||
const SourceLineInfo& lineInfo,
|
||||
const char* macroName,
|
||||
const char* expr = "",
|
||||
bool isNot = false
|
||||
)
|
||||
: m_result( expr, isNot, filename, line, macroName ),
|
||||
: m_result( expr, isNot, lineInfo, macroName ),
|
||||
m_messageStream()
|
||||
{}
|
||||
|
||||
|
@ -573,12 +569,12 @@ inline bool isTrue
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_TEST( expr, isNot, stopOnFailure, macroName ) \
|
||||
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 ); } \
|
||||
}catch( Catch::TestFailureException& ){ \
|
||||
throw; \
|
||||
} 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; \
|
||||
}}while( Catch::isTrue( false ) )
|
||||
|
||||
|
@ -597,11 +593,11 @@ inline bool isTrue
|
|||
try \
|
||||
{ \
|
||||
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( ... ) \
|
||||
{ \
|
||||
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 \
|
||||
{ \
|
||||
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& ) \
|
||||
{ \
|
||||
|
@ -617,7 +613,7 @@ inline bool isTrue
|
|||
} \
|
||||
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 ) \
|
||||
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 ) \
|
||||
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 ) \
|
||||
|
@ -640,11 +636,11 @@ inline bool isTrue
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CHECK_THAT( arg, matcher, stopOnFailure, macroName ) \
|
||||
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& ){ \
|
||||
throw; \
|
||||
} 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; \
|
||||
}}while( Catch::isTrue( false ) )
|
||||
|
||||
|
|
|
@ -1,15 +1,10 @@
|
|||
/*
|
||||
* catch_common.h
|
||||
* Catch
|
||||
*
|
||||
* Created by Phil on 29/10/2010.
|
||||
* Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
|
||||
*
|
||||
* 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)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TWOBLUECUBES_CATCH_COMMON_H_INCLUDED
|
||||
#define TWOBLUECUBES_CATCH_COMMON_H_INCLUDED
|
||||
|
||||
|
@ -32,8 +27,7 @@
|
|||
|
||||
namespace Catch
|
||||
{
|
||||
class NonCopyable
|
||||
{
|
||||
class NonCopyable {
|
||||
NonCopyable( const NonCopyable& );
|
||||
void operator = ( const NonCopyable& );
|
||||
protected:
|
||||
|
@ -41,15 +35,8 @@ namespace Catch
|
|||
virtual ~NonCopyable() {}
|
||||
};
|
||||
|
||||
typedef char NoType;
|
||||
typedef int YesType;
|
||||
|
||||
// create a T for use in sizeof expressions
|
||||
template<typename T> T Synth();
|
||||
|
||||
template<typename ContainerT>
|
||||
inline void deleteAll( ContainerT& container )
|
||||
{
|
||||
inline void deleteAll( ContainerT& container ) {
|
||||
typename ContainerT::const_iterator it = container.begin();
|
||||
typename ContainerT::const_iterator itEnd = container.end();
|
||||
for(; it != itEnd; ++it )
|
||||
|
@ -58,8 +45,7 @@ namespace Catch
|
|||
}
|
||||
}
|
||||
template<typename AssociativeContainerT>
|
||||
inline void deleteAllValues( AssociativeContainerT& container )
|
||||
{
|
||||
inline void deleteAllValues( AssociativeContainerT& container ) {
|
||||
typename AssociativeContainerT::const_iterator it = container.begin();
|
||||
typename AssociativeContainerT::const_iterator itEnd = container.end();
|
||||
for(; it != itEnd; ++it )
|
||||
|
@ -69,34 +55,36 @@ namespace Catch
|
|||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
struct SourceLineInfo
|
||||
{
|
||||
SourceLineInfo
|
||||
(
|
||||
const std::string& file,
|
||||
std::size_t line
|
||||
)
|
||||
SourceLineInfo() : line( 0 ){}
|
||||
SourceLineInfo( const std::string& file, std::size_t line )
|
||||
: file( file ),
|
||||
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::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__
|
||||
os << info.file << "(" << info.line << "): ";
|
||||
#else
|
||||
|
@ -106,8 +94,7 @@ namespace Catch
|
|||
}
|
||||
|
||||
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;
|
||||
oss << "Internal Catch error: '" << message << "' at: " << SourceLineInfo( file, line );
|
||||
throw std::logic_error( oss.str() );
|
||||
|
@ -115,6 +102,7 @@ namespace Catch
|
|||
}
|
||||
|
||||
#define CATCH_INTERNAL_ERROR( msg ) throwLogicError( msg, __FILE__, __LINE__ );
|
||||
#define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FILE__, __LINE__ )
|
||||
|
||||
#endif // TWOBLUECUBES_CATCH_COMMON_H_INCLUDED
|
||||
|
||||
|
|
|
@ -35,8 +35,7 @@ namespace Catch
|
|||
virtual bool sectionStarted
|
||||
( const std::string& name,
|
||||
const std::string& description,
|
||||
const std::string& filename,
|
||||
std::size_t line,
|
||||
const SourceLineInfo& lineInfo,
|
||||
Counts& assertions
|
||||
) = 0;
|
||||
virtual void sectionEnded
|
||||
|
|
|
@ -25,8 +25,6 @@ namespace Catch
|
|||
ResultInfo
|
||||
()
|
||||
: m_macroName(),
|
||||
m_filename(),
|
||||
m_line( 0 ),
|
||||
m_expr(),
|
||||
m_lhs(),
|
||||
m_rhs(),
|
||||
|
@ -42,14 +40,12 @@ namespace Catch
|
|||
const char* expr,
|
||||
ResultWas::OfType result,
|
||||
bool isNot,
|
||||
const char* filename,
|
||||
std::size_t line,
|
||||
const SourceLineInfo& lineInfo,
|
||||
const char* macroName,
|
||||
const char* message
|
||||
)
|
||||
: m_macroName( macroName ),
|
||||
m_filename( filename ),
|
||||
m_line( line ),
|
||||
m_lineInfo( lineInfo ),
|
||||
m_expr( expr ),
|
||||
m_lhs(),
|
||||
m_rhs(),
|
||||
|
@ -137,7 +133,7 @@ namespace Catch
|
|||
()
|
||||
const
|
||||
{
|
||||
return m_filename;
|
||||
return m_lineInfo.file;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
@ -145,7 +141,7 @@ namespace Catch
|
|||
()
|
||||
const
|
||||
{
|
||||
return m_line;
|
||||
return m_lineInfo.line;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
@ -191,8 +187,7 @@ namespace Catch
|
|||
|
||||
protected:
|
||||
std::string m_macroName;
|
||||
std::string m_filename;
|
||||
std::size_t m_line;
|
||||
SourceLineInfo m_lineInfo;
|
||||
std::string m_expr, m_lhs, m_rhs, m_op;
|
||||
std::string m_message;
|
||||
ResultWas::OfType m_result;
|
||||
|
|
|
@ -147,8 +147,7 @@ namespace Catch
|
|||
do
|
||||
{
|
||||
m_reporter->StartGroup( "test case run" );
|
||||
m_currentResult.setFileAndLine( m_runningTest->getTestCaseInfo().getFilename(),
|
||||
m_runningTest->getTestCaseInfo().getLine() );
|
||||
m_currentResult.setLineInfo( m_runningTest->getTestCaseInfo().getLineInfo() );
|
||||
runCurrentTest( redirectedCout, redirectedCerr );
|
||||
m_reporter->EndGroup( "test case run", m_totals - prevTotals );
|
||||
}
|
||||
|
@ -247,18 +246,17 @@ namespace Catch
|
|||
(
|
||||
const std::string& name,
|
||||
const std::string& description,
|
||||
const std::string& filename,
|
||||
std::size_t line,
|
||||
const SourceLineInfo& lineInfo,
|
||||
Counts& assertions
|
||||
)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << name << "@" << SourceLineInfo( filename, line );
|
||||
oss << name << "@" << lineInfo;
|
||||
|
||||
if( !m_runningTest->addSection( oss.str() ) )
|
||||
return false;
|
||||
|
||||
m_currentResult.setFileAndLine( filename, line );
|
||||
m_currentResult.setLineInfo( lineInfo );
|
||||
m_reporter->StartSection( name, description );
|
||||
assertions = m_totals.assertions;
|
||||
|
||||
|
|
|
@ -28,11 +28,10 @@ namespace Catch
|
|||
(
|
||||
const std::string& name,
|
||||
const std::string& description,
|
||||
const std::string& filename,
|
||||
std::size_t line
|
||||
const SourceLineInfo& lineInfo
|
||||
)
|
||||
: 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
|
||||
|
||||
#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
|
||||
|
|
|
@ -28,14 +28,12 @@ namespace Catch
|
|||
ITestCase* testCase,
|
||||
const char* name,
|
||||
const char* description,
|
||||
const char* filename,
|
||||
std::size_t line
|
||||
const SourceLineInfo& lineInfo
|
||||
)
|
||||
: m_test( testCase ),
|
||||
m_name( name ),
|
||||
m_description( description ),
|
||||
m_filename( filename ),
|
||||
m_line( line )
|
||||
m_lineInfo( lineInfo )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -44,9 +42,7 @@ namespace Catch
|
|||
()
|
||||
: m_test( NULL ),
|
||||
m_name(),
|
||||
m_description(),
|
||||
m_filename(),
|
||||
m_line( 0 )
|
||||
m_description()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -58,8 +54,7 @@ namespace Catch
|
|||
: m_test( other.m_test->clone() ),
|
||||
m_name( other.m_name ),
|
||||
m_description( other.m_description ),
|
||||
m_filename( other.m_filename ),
|
||||
m_line( other.m_line )
|
||||
m_lineInfo( other.m_lineInfo )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -72,8 +67,7 @@ namespace Catch
|
|||
: m_test( other.m_test->clone() ),
|
||||
m_name( name ),
|
||||
m_description( other.m_description ),
|
||||
m_filename( other.m_filename ),
|
||||
m_line( other.m_line )
|
||||
m_lineInfo( other.m_lineInfo )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -120,19 +114,11 @@ namespace Catch
|
|||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
const std::string& getFilename
|
||||
const SourceLineInfo& getLineInfo
|
||||
()
|
||||
const
|
||||
{
|
||||
return m_filename;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
std::size_t getLine
|
||||
()
|
||||
const
|
||||
{
|
||||
return m_line;
|
||||
return m_lineInfo;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
@ -152,6 +138,7 @@ namespace Catch
|
|||
std::swap( m_test, other.m_test );
|
||||
m_name.swap( other.m_name );
|
||||
m_description.swap( other.m_description );
|
||||
m_lineInfo.swap( other.m_lineInfo );
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
@ -178,9 +165,7 @@ namespace Catch
|
|||
ITestCase* m_test;
|
||||
std::string m_name;
|
||||
std::string m_description;
|
||||
std::string m_filename;
|
||||
std::size_t m_line;
|
||||
|
||||
SourceLineInfo m_lineInfo;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -51,8 +51,8 @@ namespace Catch
|
|||
{
|
||||
const TestCaseInfo& prev = *m_functions.find( testInfo );
|
||||
std::cerr << "error: TEST_CASE( \"" << testInfo.getName() << "\" ) already defined.\n"
|
||||
<< "\tFirst seen at " << SourceLineInfo( prev.getFilename(), prev.getLine() ) << "\n"
|
||||
<< "\tRedefined at " << SourceLineInfo( testInfo.getFilename(), testInfo.getLine() ) << std::endl;
|
||||
<< "\tFirst seen at " << SourceLineInfo( prev.getLineInfo() ) << "\n"
|
||||
<< "\tRedefined at " << SourceLineInfo( testInfo.getLineInfo() ) << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -158,11 +158,10 @@ namespace Catch
|
|||
TestFunction function,
|
||||
const char* name,
|
||||
const char* description,
|
||||
const char* filename,
|
||||
std::size_t line
|
||||
const SourceLineInfo& lineInfo
|
||||
)
|
||||
{
|
||||
registerTestCase( new FreeFunctionTestCase( function ), name, description, filename, line );
|
||||
registerTestCase( new FreeFunctionTestCase( function ), name, description, lineInfo );
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
@ -177,11 +176,10 @@ namespace Catch
|
|||
ITestCase* testCase,
|
||||
const char* name,
|
||||
const char* description,
|
||||
const char* filename,
|
||||
std::size_t line
|
||||
const SourceLineInfo& lineInfo
|
||||
)
|
||||
{
|
||||
Hub::getTestCaseRegistry().registerTest( TestCaseInfo( testCase, name, description, filename, line ) );
|
||||
Hub::getTestCaseRegistry().registerTest( TestCaseInfo( testCase, name, description, lineInfo ) );
|
||||
}
|
||||
|
||||
} // end namespace Catch
|
||||
|
|
|
@ -80,8 +80,7 @@ struct AutoReg
|
|||
( TestFunction function,
|
||||
const char* name,
|
||||
const char* description,
|
||||
const char* filename,
|
||||
std::size_t line
|
||||
const SourceLineInfo& lineInfo
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
@ -91,11 +90,10 @@ struct AutoReg
|
|||
void (C::*method)(),
|
||||
const char* name,
|
||||
const char* description,
|
||||
const char* filename,
|
||||
std::size_t line
|
||||
const SourceLineInfo& lineInfo
|
||||
)
|
||||
{
|
||||
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,
|
||||
const char* name,
|
||||
const char* description,
|
||||
const char* filename,
|
||||
std::size_t line
|
||||
const SourceLineInfo& lineInfo
|
||||
);
|
||||
|
||||
~AutoReg
|
||||
|
@ -124,18 +121,18 @@ private:
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_TESTCASE( Name, Desc ) \
|
||||
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 )()
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_TESTCASE_NORETURN( Name, Desc ) \
|
||||
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 )()
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#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 )\
|
||||
|
@ -143,7 +140,7 @@ private:
|
|||
struct INTERNAL_CATCH_UNIQUE_NAME( Catch_FixtureWrapper ) : ClassName{ \
|
||||
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()
|
||||
|
||||
|
|
Loading…
Reference in New Issue