X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/64b989fe0b8684cf4e0a434a78e3300012fbd22a..82d1a19568ce7c468067a11f09aafaf3a770c9f8:/tests/strings/vsnprintf.cpp diff --git a/tests/strings/vsnprintf.cpp b/tests/strings/vsnprintf.cpp index c69c24a2f6..61b9abae3f 100644 --- a/tests/strings/vsnprintf.cpp +++ b/tests/strings/vsnprintf.cpp @@ -84,8 +84,9 @@ int r; // // use with extreme care and only when you're really sure the warnings must be // suppressed! +template static int -wxUnsafeSnprintf(wxChar *buf, size_t len, const wxChar *fmt, ...) +wxUnsafeSnprintf(T *buf, size_t len, const wxChar *fmt, ...) { va_list args; va_start(args, fmt); @@ -153,7 +154,7 @@ private: void WrongFormatStrings(); #endif // wxUSE_WXVSNPRINTF void Miscellaneous(); - void Misc(wxChar *buffer, int size); + template void Misc(T *buffer, int size); // compares the expectedString and the result of wxVsnprintf() char by char // for all its lenght (not only for first expectedLen chars) and also @@ -375,12 +376,13 @@ void VsnprintfTestCase::LongLong() #ifdef __WXMSW__ CMP3("123456789", "%I64d", (wxLongLong_t)123456789); - CMP3("123456789abcdef", "%I64x", (wxLongLong_t)0x123456789abcdef); + CMP3("123456789abcdef", "%I64x", wxLL(0x123456789abcdef)); #endif } #endif -void VsnprintfTestCase::Misc(wxChar *buffer, int size) +template +void VsnprintfTestCase::Misc(T *buffer, int size) { // Remember that wx*printf could be mapped either to system // implementation or to wx implementation. @@ -415,7 +417,7 @@ void VsnprintfTestCase::Misc(wxChar *buffer, int size) // format and gcc would warn about this otherwise r = wxUnsafeSnprintf(buffer, size, - "unicode string: %ls %lc - ansi string: %hs %hc\n\n", + _T("unicode string: %ls %lc - ansi string: %hs %hc\n\n"), L"unicode!!", L'W', "ansi!!", 'w'); CPPUNIT_ASSERT( r != -1 ); CPPUNIT_ASSERT_EQUAL( @@ -461,12 +463,22 @@ void VsnprintfTestCase::WrongFormatStrings() void VsnprintfTestCase::BigToSmallBuffer() { - wxChar buf[1024], buf2[16], buf3[4], buf4; - - Misc(buf, 1024); - Misc(buf2, 16); - Misc(buf3, 4); - Misc(&buf4, 1); + // VC6 can't compile this code +#if !defined(__VISUALC__) || (__VISUALC__ >= 1310) +#if wxUSE_UNICODE + wchar_t bufw[1024], bufw2[16], bufw3[4], bufw4; + Misc(bufw, 1024); + Misc(bufw2, 16); + Misc(bufw3, 4); + Misc(&bufw4, 1); +#endif // wxUSE_UNICODE + + char bufa[1024], bufa2[16], bufa3[4], bufa4; + Misc(bufa, 1024); + Misc(bufa2, 16); + Misc(bufa3, 4); + Misc(&bufa4, 1); +#endif // !VC6 } void VsnprintfTestCase::DoMisc(