mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-04 05:09:53 +01:00
Added ability to specify if macros should be prefixed with CATCH_
This commit is contained in:
parent
5d73c5a008
commit
46bcd4b2b7
@ -37,6 +37,52 @@
|
|||||||
|
|
||||||
//////
|
//////
|
||||||
|
|
||||||
|
// If this config identifier is defined then all CATCH macros are prefixed with CATCH_
|
||||||
|
#ifdef CATCH_CONFIG_PREFIX_ALL
|
||||||
|
|
||||||
|
#define CATCH_REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, false, true, "CATCH_REQUIRE" )
|
||||||
|
#define CATCH_REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, true, true, "CATCH_REQUIRE_FALSE" )
|
||||||
|
|
||||||
|
#define CATCH_REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, ..., true, "CATCH_REQUIRE_THROWS" )
|
||||||
|
#define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, true, "CATCH_REQUIRE_THROWS_AS" )
|
||||||
|
#define CATCH_REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, true, "CATCH_REQUIRE_NOTHROW" )
|
||||||
|
|
||||||
|
#define CATCH_CHECK( expr ) INTERNAL_CATCH_TEST( expr, false, false, "CATCH_CHECK" )
|
||||||
|
#define CATCH_CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( expr, true, false, "CATCH_CHECK_FALSE" )
|
||||||
|
#define CATCH_CHECKED_IF( expr ) INTERNAL_CATCH_IF( expr, false, false, "CATCH_CHECKED_IF" )
|
||||||
|
#define CATCH_CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( expr, false, false, "CATCH_CHECKED_ELSE" )
|
||||||
|
|
||||||
|
#define CATCH_CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, ..., false, "CATCH_CHECK_THROWS" )
|
||||||
|
#define CATCH_CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, false, "CATCH_CHECK_THROWS_AS" )
|
||||||
|
#define CATCH_CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, false, "CATCH_CHECK_NOTHROW" )
|
||||||
|
|
||||||
|
#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, false, "CATCH_CHECK_THAT" )
|
||||||
|
#define CATCH_REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, true, "CATCH_REQUIRE_THAT" )
|
||||||
|
|
||||||
|
#define CATCH_INFO( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Info, false, "CATCH_INFO" )
|
||||||
|
#define CATCH_WARN( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Warning, false, "CATCH_WARN" )
|
||||||
|
#define CATCH_FAIL( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::ExplicitFailure, true, "CATCH_FAIL" )
|
||||||
|
#define CATCH_SCOPED_INFO( msg ) INTERNAL_CATCH_SCOPED_INFO( msg )
|
||||||
|
#define CATCH_CAPTURE( msg ) INTERNAL_CATCH_MSG( #msg " := " << msg, Catch::ResultWas::Info, false, "CATCH_CAPTURE" )
|
||||||
|
|
||||||
|
#define CATCH_SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
|
||||||
|
|
||||||
|
#define CATCH_TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description )
|
||||||
|
#define CATCH_TEST_CASE_NORETURN( name, description ) INTERNAL_CATCH_TESTCASE_NORETURN( name, description )
|
||||||
|
#define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "Anonymous test case" )
|
||||||
|
#define CATCH_METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description )
|
||||||
|
|
||||||
|
#define CATCH_REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType )
|
||||||
|
|
||||||
|
#define CATCH_GENERATE( expr) INTERNAL_CATCH_GENERATE( expr )
|
||||||
|
|
||||||
|
///////////////
|
||||||
|
// Still to be implemented
|
||||||
|
//#define CHECK_NOFAIL( expr ) // !TBD - reports violation, but doesn't fail Test
|
||||||
|
|
||||||
|
// If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required
|
||||||
|
#else
|
||||||
|
|
||||||
#define REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, false, true, "REQUIRE" )
|
#define REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, false, true, "REQUIRE" )
|
||||||
#define REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, true, true, "REQUIRE_FALSE" )
|
#define REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, true, true, "REQUIRE_FALSE" )
|
||||||
|
|
||||||
@ -67,16 +113,15 @@
|
|||||||
#define TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description )
|
#define TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description )
|
||||||
#define TEST_CASE_NORETURN( name, description ) INTERNAL_CATCH_TESTCASE_NORETURN( name, description )
|
#define TEST_CASE_NORETURN( name, description ) INTERNAL_CATCH_TESTCASE_NORETURN( name, description )
|
||||||
#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "Anonymous test case" )
|
#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "Anonymous test case" )
|
||||||
#define METHOD_AS_TEST_CASE( method, name, description ) CATCH_METHOD_AS_TEST_CASE( method, name, description )
|
#define METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description )
|
||||||
|
|
||||||
#define REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType )
|
#define REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType )
|
||||||
#define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature )
|
|
||||||
|
|
||||||
#define GENERATE( expr) INTERNAL_CATCH_GENERATE( expr )
|
#define GENERATE( expr) INTERNAL_CATCH_GENERATE( expr )
|
||||||
|
|
||||||
///////////////
|
#endif
|
||||||
// Still to be implemented
|
|
||||||
#define CHECK_NOFAIL( expr ) // !TBD - reports violation, but doesn't fail Test
|
#define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature )
|
||||||
|
|
||||||
using Catch::Detail::Approx;
|
using Catch::Detail::Approx;
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ private:
|
|||||||
static void INTERNAL_CATCH_UNIQUE_NAME( TestCaseFunction_catch_internal_ )()
|
static void INTERNAL_CATCH_UNIQUE_NAME( TestCaseFunction_catch_internal_ )()
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define 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, Name, Desc, CATCH_INTERNAL_LINEINFO ); }
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -10,6 +10,9 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// This define means we have to prefix all the CATCH macros with CATCH_
|
||||||
|
// We're using it here to test it out
|
||||||
|
#define CATCH_CONFIG_PREFIX_ALL
|
||||||
#include "catch.hpp"
|
#include "catch.hpp"
|
||||||
|
|
||||||
inline int multiply( int a, int b )
|
inline int multiply( int a, int b )
|
||||||
@ -17,13 +20,13 @@ inline int multiply( int a, int b )
|
|||||||
return a*b;
|
return a*b;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE( "./succeeding/generators/1", "Generators over two ranges" )
|
CATCH_TEST_CASE( "./succeeding/generators/1", "Generators over two ranges" )
|
||||||
{
|
{
|
||||||
using namespace Catch::Generators;
|
using namespace Catch::Generators;
|
||||||
|
|
||||||
int i = GENERATE( between( 1, 5 ).then( values( 15, 20, 21 ).then( 36 ) ) );
|
int i = CATCH_GENERATE( between( 1, 5 ).then( values( 15, 20, 21 ).then( 36 ) ) );
|
||||||
int j = GENERATE( between( 100, 107 ) );
|
int j = CATCH_GENERATE( between( 100, 107 ) );
|
||||||
|
|
||||||
REQUIRE( multiply( i, 2 ) == i*2 );
|
CATCH_REQUIRE( multiply( i, 2 ) == i*2 );
|
||||||
REQUIRE( multiply( j, 2 ) == j*2 );
|
CATCH_REQUIRE( multiply( j, 2 ) == j*2 );
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Generated: 2012-07-17 08:02:44.293339
|
* Generated: 2012-07-20 18:42:56.789420
|
||||||
* ----------------------------------------------------------
|
* ----------------------------------------------------------
|
||||||
* 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.
|
||||||
@ -515,7 +515,7 @@ private:
|
|||||||
static void INTERNAL_CATCH_UNIQUE_NAME( TestCaseFunction_catch_internal_ )()
|
static void INTERNAL_CATCH_UNIQUE_NAME( TestCaseFunction_catch_internal_ )()
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define 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, Name, Desc, CATCH_INTERNAL_LINEINFO ); }
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -4747,6 +4747,52 @@ int main (int argc, char * const argv[]) {
|
|||||||
|
|
||||||
//////
|
//////
|
||||||
|
|
||||||
|
// If this config identifier is defined then all CATCH macros are prefixed with CATCH_
|
||||||
|
#ifdef CATCH_CONFIG_PREFIX_ALL
|
||||||
|
|
||||||
|
#define CATCH_REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, false, true, "CATCH_REQUIRE" )
|
||||||
|
#define CATCH_REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, true, true, "CATCH_REQUIRE_FALSE" )
|
||||||
|
|
||||||
|
#define CATCH_REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, ..., true, "CATCH_REQUIRE_THROWS" )
|
||||||
|
#define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, true, "CATCH_REQUIRE_THROWS_AS" )
|
||||||
|
#define CATCH_REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, true, "CATCH_REQUIRE_NOTHROW" )
|
||||||
|
|
||||||
|
#define CATCH_CHECK( expr ) INTERNAL_CATCH_TEST( expr, false, false, "CATCH_CHECK" )
|
||||||
|
#define CATCH_CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( expr, true, false, "CATCH_CHECK_FALSE" )
|
||||||
|
#define CATCH_CHECKED_IF( expr ) INTERNAL_CATCH_IF( expr, false, false, "CATCH_CHECKED_IF" )
|
||||||
|
#define CATCH_CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( expr, false, false, "CATCH_CHECKED_ELSE" )
|
||||||
|
|
||||||
|
#define CATCH_CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, ..., false, "CATCH_CHECK_THROWS" )
|
||||||
|
#define CATCH_CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, false, "CATCH_CHECK_THROWS_AS" )
|
||||||
|
#define CATCH_CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, false, "CATCH_CHECK_NOTHROW" )
|
||||||
|
|
||||||
|
#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, false, "CATCH_CHECK_THAT" )
|
||||||
|
#define CATCH_REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, true, "CATCH_REQUIRE_THAT" )
|
||||||
|
|
||||||
|
#define CATCH_INFO( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Info, false, "CATCH_INFO" )
|
||||||
|
#define CATCH_WARN( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Warning, false, "CATCH_WARN" )
|
||||||
|
#define CATCH_FAIL( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::ExplicitFailure, true, "CATCH_FAIL" )
|
||||||
|
#define CATCH_SCOPED_INFO( msg ) INTERNAL_CATCH_SCOPED_INFO( msg )
|
||||||
|
#define CATCH_CAPTURE( msg ) INTERNAL_CATCH_MSG( #msg " := " << msg, Catch::ResultWas::Info, false, "CATCH_CAPTURE" )
|
||||||
|
|
||||||
|
#define CATCH_SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
|
||||||
|
|
||||||
|
#define CATCH_TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description )
|
||||||
|
#define CATCH_TEST_CASE_NORETURN( name, description ) INTERNAL_CATCH_TESTCASE_NORETURN( name, description )
|
||||||
|
#define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "Anonymous test case" )
|
||||||
|
#define CATCH_METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description )
|
||||||
|
|
||||||
|
#define CATCH_REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType )
|
||||||
|
|
||||||
|
#define CATCH_GENERATE( expr) INTERNAL_CATCH_GENERATE( expr )
|
||||||
|
|
||||||
|
///////////////
|
||||||
|
// Still to be implemented
|
||||||
|
//#define CHECK_NOFAIL( expr ) // !TBD - reports violation, but doesn't fail Test
|
||||||
|
|
||||||
|
// If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required
|
||||||
|
#else
|
||||||
|
|
||||||
#define REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, false, true, "REQUIRE" )
|
#define REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, false, true, "REQUIRE" )
|
||||||
#define REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, true, true, "REQUIRE_FALSE" )
|
#define REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, true, true, "REQUIRE_FALSE" )
|
||||||
|
|
||||||
@ -4777,16 +4823,15 @@ int main (int argc, char * const argv[]) {
|
|||||||
#define TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description )
|
#define TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description )
|
||||||
#define TEST_CASE_NORETURN( name, description ) INTERNAL_CATCH_TESTCASE_NORETURN( name, description )
|
#define TEST_CASE_NORETURN( name, description ) INTERNAL_CATCH_TESTCASE_NORETURN( name, description )
|
||||||
#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "Anonymous test case" )
|
#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "Anonymous test case" )
|
||||||
#define METHOD_AS_TEST_CASE( method, name, description ) CATCH_METHOD_AS_TEST_CASE( method, name, description )
|
#define METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description )
|
||||||
|
|
||||||
#define REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType )
|
#define REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType )
|
||||||
#define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature )
|
|
||||||
|
|
||||||
#define GENERATE( expr) INTERNAL_CATCH_GENERATE( expr )
|
#define GENERATE( expr) INTERNAL_CATCH_GENERATE( expr )
|
||||||
|
|
||||||
///////////////
|
#endif
|
||||||
// Still to be implemented
|
|
||||||
#define CHECK_NOFAIL( expr ) // !TBD - reports violation, but doesn't fail Test
|
#define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature )
|
||||||
|
|
||||||
using Catch::Detail::Approx;
|
using Catch::Detail::Approx;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user