X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/051d655703d708e19a703d5d16f9f88a753a12af..1ec4e9c2b72a01a7ba7da569e0f8d04a81aaba10:/tests/strings/vsnprintf.cpp diff --git a/tests/strings/vsnprintf.cpp b/tests/strings/vsnprintf.cpp index 9105a8190e..b37d0e50a8 100644 --- a/tests/strings/vsnprintf.cpp +++ b/tests/strings/vsnprintf.cpp @@ -34,22 +34,6 @@ // http://www.gnu.org/software/libc/manual/html_node/Formatted-Output.html -// Visual C++ run-time produces different results from glibc (not sure if this -// was tested using other run-times to be honest) so adjust the test results in -// some cases. Remember that while we test our own wxPrintf() code here, it -// uses the system sprintf() for actual formatting so the results are still -// different under different systems. -// -// Notice that MinGW uses VC CRT by default but may use its own printf() -// implementation if __USE_MINGW_ANSI_STDIO is defined. And finally also notice -// that testing for __USE_MINGW_ANSI_STDIO directly results in a warning with -// -Wundef if it involves an operation with undefined __MINGW_FEATURES__ so -// test for the latter too to avoid it. -#if defined(__VISUALC__) || \ - (defined(__MINGW32__) && !defined(__MINGW_FEATURES__) || !__USE_MINGW_ANSI_STDIO) - #define USING_VC_CRT -#endif - // ---------------------------------------------------------------------------- // global utilities for testing // ---------------------------------------------------------------------------- @@ -205,7 +189,7 @@ private: // register in the unnamed registry so that these tests are run by default CPPUNIT_TEST_SUITE_REGISTRATION( VsnprintfTestCase ); -// also include in it's own registry so that these tests can be run alone +// also include in its own registry so that these tests can be run alone CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( VsnprintfTestCase, "VsnprintfTestCase" ); void VsnprintfTestCase::setUp() @@ -252,15 +236,15 @@ void VsnprintfTestCase::O() void VsnprintfTestCase::P() { - // WARNING: printing of pointers is not fully standard. - // GNU prints them as %#x except for NULL pointers which are - // printed as '(nil)'. - // MSVC always print them as %8X on 32 bit systems and as %16X - // on 64 bit systems - // mingw32 uses MSVC CRT in old versions but is own implementation - // now which is somewhere in the middle as it uses %8x, so to - // catch both cases we use case-insensitive comparison here. -#ifdef USING_VC_CRT + // The exact format used for "%p" is not specified by the standard and so + // varies among different platforms, so we need to expect different results + // here (remember that while we test our own wxPrintf() code here, it uses + // the system sprintf() for actual formatting so the results are still + // different under different systems). + +#ifdef wxUSING_VC_CRT_IO + // MSVC always prints pointers as %8X on 32 bit systems and as %16X on 64 + // bit systems. #if SIZEOF_VOID_P == 4 CMP3i("00ABCDEF", "%p", (void*)0xABCDEF); CMP3("00000000", "%p", (void*)NULL); @@ -269,9 +253,14 @@ void VsnprintfTestCase::P() CMP3("0000000000000000", "%p", (void*)NULL); #endif #elif defined(__MINGW32__) + // mingw32 uses MSVC CRT in old versions but is own implementation now + // which is somewhere in the middle as it uses %8x, so to catch both cases + // we use case-insensitive comparison here. CMP3("0xabcdef", "%p", (void*)0xABCDEF); CMP3("0", "%p", (void*)NULL); #elif defined(__GNUG__) + // glibc prints pointers as %#x except for NULL pointers which are printed + // as '(nil)'. CMP3("0xabcdef", "%p", (void*)0xABCDEF); CMP3("(nil)", "%p", (void*)NULL); #endif @@ -436,7 +425,7 @@ void VsnprintfTestCase::LongLong() CMP3("123456789", "%llu", (wxULongLong_t)123456789); -#ifdef __WXMSW__ +#ifdef __WINDOWS__ CMP3("123456789", "%I64d", (wxLongLong_t)123456789); CMP3("123456789abcdef", "%I64x", wxLL(0x123456789abcdef)); #endif @@ -627,7 +616,7 @@ void VsnprintfTestCase::GlibcMisc1() { CMP3(" ", "%5.s", "xyz"); CMP3(" 33", "%5.f", 33.3); -#ifdef USING_VC_CRT +#ifdef wxUSING_VC_CRT_IO // see the previous notes about the minimum width of mantissa: CMP3(" 3e+008", "%8.e", 33.3e7); CMP3(" 3E+008", "%8.E", 33.3e7);