Fixed more gcc warnings

This commit is contained in:
Phil Nash 2011-01-31 20:15:40 +00:00
parent db378d8939
commit d1ee964f5d
5 changed files with 18 additions and 2 deletions

View File

@ -17,9 +17,13 @@
namespace namespace
{ {
ATTRIBUTE_NORETURN
int thisThrows();
int thisThrows() int thisThrows()
{ {
throw std::domain_error( "expected exception" ); throw std::domain_error( "expected exception" );
/*NOTREACHED*/
} }
int thisDoesntThrow() int thisDoesntThrow()
@ -42,9 +46,10 @@ TEST_CASE( "./failing/exceptions/explicit", "When checked exceptions are thrown
CHECK_NOTHROW( thisThrows() ); CHECK_NOTHROW( thisThrows() );
} }
TEST_CASE( "./failing/exceptions/implicit", "When unchecked exceptions are thrown they are always failures" ) INTERNAL_CATCH_TESTCASE_NORETURN( "./failing/exceptions/implicit", "When unchecked exceptions are thrown they are always failures" )
{ {
throw std::domain_error( "unexpected exception" ); throw std::domain_error( "unexpected exception" );
/*NOTREACHED*/
} }
TEST_CASE( "./succeeding/exceptions/implicit", "When unchecked exceptions are thrown, but caught, they do not affect the test" ) TEST_CASE( "./succeeding/exceptions/implicit", "When unchecked exceptions are thrown, but caught, they do not affect the test" )

View File

@ -53,6 +53,7 @@
#define SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description ) #define SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
#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 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 ) CATCH_METHOD_AS_TEST_CASE( method, name, description )

View File

@ -55,5 +55,10 @@ namespace Catch
} }
} }
#ifdef __GNUC__
#define ATTRIBUTE_NORETURN __attribute__ ((noreturn))
#else
#define ATTRIBUTE_NORETURN
#endif
#endif // TWOBLUECUBES_CATCH_COMMON_H_INCLUDED #endif // TWOBLUECUBES_CATCH_COMMON_H_INCLUDED

View File

@ -58,6 +58,6 @@ namespace Catch
} // end namespace Catch } // end namespace Catch
#define INTERNAL_CATCH_SECTION( name, desc ) if( Catch::Section catch_internal_Section = Catch::Section( name, desc ) ) #define INTERNAL_CATCH_SECTION( name, desc ) if( Catch::Section INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::Section( name, desc ) )
#endif // TWOBLUECUBES_CATCH_SECTION_HPP_INCLUDED #endif // TWOBLUECUBES_CATCH_SECTION_HPP_INCLUDED

View File

@ -83,6 +83,11 @@ struct FixtureWrapper{};
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &INTERNAL_CATCH_UNIQUE_NAME( catch_internal_TestFunction ), Name, Desc ); }\ namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &INTERNAL_CATCH_UNIQUE_NAME( catch_internal_TestFunction ), Name, Desc ); }\
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 ) \
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 ); }\
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 ); } namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, Name, Desc ); }