3131
3232#define CHECK_TEST_FAILS_PROPER_WITH_TEXT (text ) fixture.checkTestFailsWithProperTestLocation(text, __FILE__, __LINE__)
3333
34+ // Mainly this is for Visual C++, but we'll define it for any system that has the same behavior
35+ // of a 32-bit long on a 64-bit system
36+ #if defined(CPPUTEST_64BIT) && defined(CPPUTEST_64BIT_32BIT_LONGS)
37+ // Forcing the value to be unsigned long long means that there's no sign-extension to perform
38+ #define to_void_pointer (x ) ((void *)x##ULL)
39+ #define to_func_pointer (x ) ((void (*)())x##ULL)
40+ #else
41+ // Probably not needed, but let's guarantee that the value is an unsigned long
42+ #define to_void_pointer (x ) ((void *)x##UL)
43+ #define to_func_pointer (x ) ((void (*)())x##UL)
44+ #endif
45+
3446TEST_GROUP (UnitTestMacros)
3547{
3648 TestTestingFixture fixture;
@@ -721,8 +733,8 @@ TEST(UnitTestMacros, FailureWithPOINTERS_EQUAL)
721733
722734TEST (UnitTestMacros, POINTERS_EQUALBehavesAsProperMacro)
723735{
724- if (false ) POINTERS_EQUAL (0 , 0x0ea1beef )
725- else POINTERS_EQUAL (0x01debeef , 0x01debeef )
736+ if (false ) POINTERS_EQUAL (0 , to_void_pointer ( 0xbeefbeef ) )
737+ else POINTERS_EQUAL (to_void_pointer ( 0xdeadbeef ), to_void_pointer ( 0xdeadbeef ) )
726738}
727739
728740IGNORE_TEST (UnitTestMacros, POINTERS_EQUALWorksInAnIgnoredTest)
@@ -746,8 +758,8 @@ TEST(UnitTestMacros, FailureWithPOINTERS_EQUAL_TEXT)
746758
747759TEST (UnitTestMacros, POINTERS_EQUAL_TEXTBehavesAsProperMacro)
748760{
749- if (false ) POINTERS_EQUAL_TEXT (0 , ( void *) 0x0ea1beef , " Failed because it failed" )
750- else POINTERS_EQUAL_TEXT (( void *) 0x01debeef , ( void *) 0x01debeef , " Failed because it failed" )
761+ if (false ) POINTERS_EQUAL_TEXT (0 , to_void_pointer ( 0xbeefbeef ) , " Failed because it failed" )
762+ else POINTERS_EQUAL_TEXT (to_void_pointer ( 0xdeadbeef ), to_void_pointer ( 0xdeadbeef ) , " Failed because it failed" )
751763}
752764
753765IGNORE_TEST (UnitTestMacros, POINTERS_EQUAL_TEXTWorksInAnIgnoredTest)
@@ -771,8 +783,8 @@ TEST(UnitTestMacros, FailureWithFUNCTIONPOINTERS_EQUAL)
771783
772784TEST (UnitTestMacros, FUNCTIONPOINTERS_EQUALBehavesAsProperMacro)
773785{
774- if (false ) FUNCTIONPOINTERS_EQUAL (0 , ( void (*)()) 0x0ea1beef )
775- else FUNCTIONPOINTERS_EQUAL (( void (*)()) 0x01debeef , ( void (*)()) 0x01debeef )
786+ if (false ) FUNCTIONPOINTERS_EQUAL (0 , to_func_pointer ( 0xbeefbeef ) )
787+ else FUNCTIONPOINTERS_EQUAL (to_func_pointer ( 0xdeadbeef ), to_func_pointer ( 0xdeadbeef ) )
776788}
777789
778790IGNORE_TEST (UnitTestMacros, FUNCTIONPOINTERS_EQUALWorksInAnIgnoredTest)
@@ -796,8 +808,8 @@ TEST(UnitTestMacros, FailureWithFUNCTIONPOINTERS_EQUAL_TEXT)
796808
797809TEST (UnitTestMacros, FUNCTIONPOINTERS_EQUAL_TEXTBehavesAsProperMacro)
798810{
799- if (false ) FUNCTIONPOINTERS_EQUAL_TEXT (0 , ( void (*)()) 0x0ea1beef , " Failed because it failed" )
800- else FUNCTIONPOINTERS_EQUAL_TEXT (( void (*)()) 0x01debeef , ( void (*)()) 0x01debeef , " Failed because it failed" )
811+ if (false ) FUNCTIONPOINTERS_EQUAL_TEXT (0 , to_func_pointer ( 0xbeefbeef ) , " Failed because it failed" )
812+ else FUNCTIONPOINTERS_EQUAL_TEXT (to_func_pointer ( 0xdeadbeef ), to_func_pointer ( 0xdeadbeef ) , " Failed because it failed" )
801813}
802814
803815IGNORE_TEST (UnitTestMacros, FUNCTIONPOINTERS_EQUAL_TEXTWorksInAnIgnoredTest)
0 commit comments