Pointer comparisons and compare to NULL

This commit is contained in:
Phil Nash
2011-03-18 14:39:58 +00:00
parent 1e15669f2a
commit ef611c65d9
3 changed files with 137 additions and 3 deletions

View File

@@ -214,6 +214,19 @@ TEST_CASE( "./failing/conditions/unsigned-negative", "Comparisons between negati
CHECK( negative == ui );
}
TEST_CASE( "./succeeding/conditions/ptr", "Pointers can be compared to null" )
{
TestData* p = NULL;
TestData* pNULL = NULL;
REQUIRE( p == NULL );
REQUIRE( p == pNULL );
TestData data;
p = &data;
REQUIRE( p != NULL );
}
// Not (!) tests
// The problem with the ! operator is that it has right-to-left associativity.
// This means we can't isolate it when we decompose. The simple REQUIRE( !false ) form, therefore,