Fix for comparing (const) char* to NULL

This commit is contained in:
Phil Nash
2012-05-07 19:45:55 +01:00
parent a201f715a8
commit e1cb8f25f2
3 changed files with 20 additions and 4 deletions

View File

@@ -221,6 +221,9 @@ TEST_CASE( "succeeding/conditions/negative ints",
}
#endif
inline const char* returnsConstNull(){ return NULL; }
inline char* returnsNull(){ return NULL; }
TEST_CASE( "./succeeding/conditions/ptr",
"Pointers can be compared to null" )
{
@@ -241,6 +244,9 @@ TEST_CASE( "./succeeding/conditions/ptr",
const TestData* const cpc = p;
REQUIRE( cpc != NULL );
REQUIRE( returnsNull() == NULL );
REQUIRE( returnsConstNull() == NULL );
// REQUIRE( NULL != p ); // gives warning, but should compile and run ok
}

View File

@@ -43,7 +43,7 @@ TEST_CASE( "selftest/main", "Runs all Catch self tests and checks their results"
"Number of 'succeeding' tests is fixed" )
{
runner.runMatching( "./succeeding/*" );
CHECK( runner.getTotals().assertions.passed == 273 );
CHECK( runner.getTotals().assertions.passed == 275 );
CHECK( runner.getTotals().assertions.failed == 0 );
}