Skip to content

Commit c984fc3

Browse files
committed
v1.4.0
- use __COUNTER__ for unique IDS instead of __LINE__ (where possible) + bug fixes
1 parent 447f53e commit c984fc3

File tree

3 files changed

+57
-26
lines changed

3 files changed

+57
-26
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![catch logo](catch-logo-small.png)
22

3-
*v1.3.6*
3+
*v1.4.0*
44

55
Build status (on Travis CI) [![Build Status](https://travis-ci.org/philsquared/Catch.png)](https://travis-ci.org/philsquared/Catch)
66

include/internal/catch_version.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace Catch {
3737
return os;
3838
}
3939

40-
Version libraryVersion( 1, 3, 6, "", 0 );
40+
Version libraryVersion( 1, 4, 0, "", 0 );
4141

4242
}
4343

single_include/catch.hpp

Lines changed: 55 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Catch v1.3.6
3-
* Generated: 2016-03-11 18:30:42.852700
2+
* Catch v1.4.0
3+
* Generated: 2016-03-15 07:23:12.623111
44
* ----------------------------------------------------------
55
* This file has been merged from multiple headers. Please don't edit it directly
66
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
@@ -62,7 +62,11 @@
6262

6363
#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line
6464
#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line )
65-
#define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ )
65+
#ifdef CATCH_CONFIG_COUNTER
66+
# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ )
67+
#else
68+
# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ )
69+
#endif
6670

6771
#define INTERNAL_CATCH_STRINGIFY2( expr ) #expr
6872
#define INTERNAL_CATCH_STRINGIFY( expr ) INTERNAL_CATCH_STRINGIFY2( expr )
@@ -89,7 +93,7 @@
8993
// CATCH_CONFIG_CPP11_OR_GREATER : Is C++11 supported?
9094

9195
// CATCH_CONFIG_VARIADIC_MACROS : are variadic macros supported?
92-
96+
// CATCH_CONFIG_COUNTER : is the __COUNTER__ macro supported?
9397
// ****************
9498
// Note to maintainers: if new toggles are added please document them
9599
// in configuration.md, too
@@ -185,6 +189,15 @@
185189

186190
#endif
187191

192+
// Use __COUNTER__ if the compiler supports it
193+
#if ( defined _MSC_VER && _MSC_VER >= 1300 ) || \
194+
( defined __GNUC__ && __GNUC__ >= 4 && __GNUC_MINOR__ >= 3 ) || \
195+
( defined __clang__ && __clang_major__ >= 3 )
196+
197+
#define CATCH_INTERNAL_CONFIG_COUNTER
198+
199+
#endif
200+
188201
////////////////////////////////////////////////////////////////////////////////
189202
// C++ language feature support
190203

@@ -256,6 +269,9 @@
256269
#if defined(CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_NO_UNIQUE_PTR) && !defined(CATCH_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_NO_CPP11)
257270
# define CATCH_CONFIG_CPP11_UNIQUE_PTR
258271
#endif
272+
#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER)
273+
# define CATCH_CONFIG_COUNTER
274+
#endif
259275

260276
#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS)
261277
# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS
@@ -686,49 +702,57 @@ void registerTestCaseFunction
686702

687703
#ifdef CATCH_CONFIG_VARIADIC_MACROS
688704
///////////////////////////////////////////////////////////////////////////////
705+
#define INTERNAL_CATCH_TESTCASE2( TestName, ... ) \
706+
static void TestName(); \
707+
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); }\
708+
static void TestName()
689709
#define INTERNAL_CATCH_TESTCASE( ... ) \
690-
static void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )(); \
691-
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); }\
692-
static void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )()
710+
INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), __VA_ARGS__ )
693711

694712
///////////////////////////////////////////////////////////////////////////////
695713
#define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \
696714
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); }
697715

698716
///////////////////////////////////////////////////////////////////////////////
699-
#define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... )\
717+
#define INTERNAL_CATCH_TEST_CASE_METHOD2( TestName, ClassName, ... )\
700718
namespace{ \
701-
struct INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ) : ClassName{ \
719+
struct TestName : ClassName{ \
702720
void test(); \
703721
}; \
704-
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )::test, #ClassName, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); \
722+
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &TestName::test, #ClassName, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); \
705723
} \
706-
void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )::test()
724+
void TestName::test()
725+
#define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... ) \
726+
INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, __VA_ARGS__ )
707727

708728
///////////////////////////////////////////////////////////////////////////////
709729
#define INTERNAL_CATCH_REGISTER_TESTCASE( Function, ... ) \
710730
Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) );
711731

712732
#else
713733
///////////////////////////////////////////////////////////////////////////////
734+
#define INTERNAL_CATCH_TESTCASE2( TestName, Name, Desc ) \
735+
static void TestName(); \
736+
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); }\
737+
static void TestName()
714738
#define INTERNAL_CATCH_TESTCASE( Name, Desc ) \
715-
static void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )(); \
716-
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); }\
717-
static void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )()
739+
INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), Name, Desc )
718740

719741
///////////////////////////////////////////////////////////////////////////////
720742
#define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, Name, Desc ) \
721743
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( Name, Desc ), CATCH_INTERNAL_LINEINFO ); }
722744

723745
///////////////////////////////////////////////////////////////////////////////
724-
#define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, TestName, Desc )\
746+
#define INTERNAL_CATCH_TEST_CASE_METHOD2( TestCaseName, ClassName, TestName, Desc )\
725747
namespace{ \
726-
struct INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ) : ClassName{ \
748+
struct TestCaseName : ClassName{ \
727749
void test(); \
728750
}; \
729-
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )::test, #ClassName, Catch::NameAndDesc( TestName, Desc ), CATCH_INTERNAL_LINEINFO ); \
751+
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &TestCaseName::test, #ClassName, Catch::NameAndDesc( TestName, Desc ), CATCH_INTERNAL_LINEINFO ); \
730752
} \
731-
void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )::test()
753+
void TestCaseName::test()
754+
#define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, TestName, Desc )\
755+
INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, TestName, Desc )
732756

733757
///////////////////////////////////////////////////////////////////////////////
734758
#define INTERNAL_CATCH_REGISTER_TESTCASE( Function, Name, Desc ) \
@@ -2578,10 +2602,12 @@ namespace Catch {
25782602
}
25792603

25802604
///////////////////////////////////////////////////////////////////////////////
2581-
#define INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) \
2582-
static std::string INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator )( signature ); \
2583-
namespace{ Catch::ExceptionTranslatorRegistrar INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionRegistrar )( &INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator ) ); }\
2584-
static std::string INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator )( signature )
2605+
#define INTERNAL_CATCH_TRANSLATE_EXCEPTION2( translatorName, signature ) \
2606+
static std::string translatorName( signature ); \
2607+
namespace{ Catch::ExceptionTranslatorRegistrar INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionRegistrar )( &translatorName ); }\
2608+
static std::string translatorName( signature )
2609+
2610+
#define INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION2( INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator ), signature )
25852611

25862612
// #included from: internal/catch_approx.hpp
25872613
#define TWOBLUECUBES_CATCH_APPROX_HPP_INCLUDED
@@ -5884,6 +5910,11 @@ namespace Catch {
58845910
while( getCurrentContext().advanceGeneratorsForCurrentTest() && !aborting() );
58855911

58865912
Totals deltaTotals = m_totals.delta( prevTotals );
5913+
if( testInfo.expectedToFail() && deltaTotals.testCases.passed > 0 ) {
5914+
deltaTotals.assertions.failed++;
5915+
deltaTotals.testCases.passed--;
5916+
deltaTotals.testCases.failed++;
5917+
}
58875918
m_totals.testCases += deltaTotals.testCases;
58885919
m_reporter->testCaseEnded( TestCaseStats( testInfo,
58895920
deltaTotals,
@@ -7481,7 +7512,7 @@ namespace Catch {
74817512
return os;
74827513
}
74837514

7484-
Version libraryVersion( 1, 3, 6, "", 0 );
7515+
Version libraryVersion( 1, 4, 0, "", 0 );
74857516

74867517
}
74877518

@@ -9777,7 +9808,7 @@ namespace Catch {
97779808
if( totals.testCases.total() == 0 ) {
97789809
stream << Colour( Colour::Warning ) << "No tests ran\n";
97799810
}
9780-
else if( totals.assertions.total() > 0 && totals.assertions.allPassed() ) {
9811+
else if( totals.assertions.total() > 0 && totals.testCases.allPassed() ) {
97819812
stream << Colour( Colour::ResultSuccess ) << "All tests passed";
97829813
stream << " ("
97839814
<< pluralise( totals.assertions.passed, "assertion" ) << " in "

0 commit comments

Comments
 (0)