Use wxUSING_VC_CRT_IO for MSVC CRT-specific test results.
Move USING_VC_CRT into testprec.h to allow its reuse in other files and rename it to wxUSING_VC_CRT_IO as it only checks whether we're using MSVC STDIO implementation and could be false even when we are otherwise using MSVC CRT. Use this symbol for the tests whose result depends on the concrete version of the CRT we use. This fixes StringTestCase::FromDouble() failure under MinGW. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65745 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -769,7 +769,7 @@ void StringTestCase::FromDouble()
|
|||||||
// NB: there are no standards about the minimum exponent width
|
// NB: there are no standards about the minimum exponent width
|
||||||
// and newer MSVC versions use 3 digits as minimum exponent
|
// and newer MSVC versions use 3 digits as minimum exponent
|
||||||
// width while GNU libc uses 2 digits as minimum width...
|
// width while GNU libc uses 2 digits as minimum width...
|
||||||
#ifdef __VISUALC__
|
#ifdef wxUSING_VC_CRT_IO
|
||||||
{ -3e-10, "-3e-010" },
|
{ -3e-10, "-3e-010" },
|
||||||
#else
|
#else
|
||||||
{ -3e-10, "-3e-10" },
|
{ -3e-10, "-3e-10" },
|
||||||
|
@@ -34,22 +34,6 @@
|
|||||||
// http://www.gnu.org/software/libc/manual/html_node/Formatted-Output.html
|
// 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
|
// global utilities for testing
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -252,15 +236,15 @@ void VsnprintfTestCase::O()
|
|||||||
|
|
||||||
void VsnprintfTestCase::P()
|
void VsnprintfTestCase::P()
|
||||||
{
|
{
|
||||||
// WARNING: printing of pointers is not fully standard.
|
// The exact format used for "%p" is not specified by the standard and so
|
||||||
// GNU prints them as %#x except for NULL pointers which are
|
// varies among different platforms, so we need to expect different results
|
||||||
// printed as '(nil)'.
|
// here (remember that while we test our own wxPrintf() code here, it uses
|
||||||
// MSVC always print them as %8X on 32 bit systems and as %16X
|
// the system sprintf() for actual formatting so the results are still
|
||||||
// on 64 bit systems
|
// different under different 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
|
#ifdef wxUSING_VC_CRT_IO
|
||||||
// catch both cases we use case-insensitive comparison here.
|
// MSVC always prints pointers as %8X on 32 bit systems and as %16X on 64
|
||||||
#ifdef USING_VC_CRT
|
// bit systems.
|
||||||
#if SIZEOF_VOID_P == 4
|
#if SIZEOF_VOID_P == 4
|
||||||
CMP3i("00ABCDEF", "%p", (void*)0xABCDEF);
|
CMP3i("00ABCDEF", "%p", (void*)0xABCDEF);
|
||||||
CMP3("00000000", "%p", (void*)NULL);
|
CMP3("00000000", "%p", (void*)NULL);
|
||||||
@@ -269,9 +253,14 @@ void VsnprintfTestCase::P()
|
|||||||
CMP3("0000000000000000", "%p", (void*)NULL);
|
CMP3("0000000000000000", "%p", (void*)NULL);
|
||||||
#endif
|
#endif
|
||||||
#elif defined(__MINGW32__)
|
#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("0xabcdef", "%p", (void*)0xABCDEF);
|
||||||
CMP3("0", "%p", (void*)NULL);
|
CMP3("0", "%p", (void*)NULL);
|
||||||
#elif defined(__GNUG__)
|
#elif defined(__GNUG__)
|
||||||
|
// glibc prints pointers as %#x except for NULL pointers which are printed
|
||||||
|
// as '(nil)'.
|
||||||
CMP3("0xabcdef", "%p", (void*)0xABCDEF);
|
CMP3("0xabcdef", "%p", (void*)0xABCDEF);
|
||||||
CMP3("(nil)", "%p", (void*)NULL);
|
CMP3("(nil)", "%p", (void*)NULL);
|
||||||
#endif
|
#endif
|
||||||
@@ -627,7 +616,7 @@ void VsnprintfTestCase::GlibcMisc1()
|
|||||||
{
|
{
|
||||||
CMP3(" ", "%5.s", "xyz");
|
CMP3(" ", "%5.s", "xyz");
|
||||||
CMP3(" 33", "%5.f", 33.3);
|
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:
|
// see the previous notes about the minimum width of mantissa:
|
||||||
CMP3(" 3e+008", "%8.e", 33.3e7);
|
CMP3(" 3e+008", "%8.e", 33.3e7);
|
||||||
CMP3(" 3E+008", "%8.E", 33.3e7);
|
CMP3(" 3E+008", "%8.E", 33.3e7);
|
||||||
|
@@ -26,6 +26,22 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Define wxUSING_VC_CRT_IO when using MSVC CRT STDIO library as its standard
|
||||||
|
// functions give different results from glibc ones in several cases (of
|
||||||
|
// course, any code relying on this is not portable and probably won't work,
|
||||||
|
// i.e. will result in tests failures, with other platforms/compilers which
|
||||||
|
// should have checks for them added as well).
|
||||||
|
//
|
||||||
|
// 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 wxUSING_VC_CRT_IO
|
||||||
|
#endif
|
||||||
|
|
||||||
// thrown when assert fails in debug build
|
// thrown when assert fails in debug build
|
||||||
class TestAssertFailure
|
class TestAssertFailure
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user