X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/64b989fe0b8684cf4e0a434a78e3300012fbd22a..4f2511d706e5274a34e1521e11c1b95fed735b42:/tests/strings/vsnprintf.cpp diff --git a/tests/strings/vsnprintf.cpp b/tests/strings/vsnprintf.cpp index c69c24a2f6..015480e869 100644 --- a/tests/strings/vsnprintf.cpp +++ b/tests/strings/vsnprintf.cpp @@ -19,6 +19,10 @@ #pragma hdrstop #endif +#include "wx/crt.h" + +#if wxUSE_WXVSNPRINTF + #ifndef WX_PRECOMP #include "wx/wx.h" #include "wx/wxchar.h" @@ -84,8 +88,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 +158,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 +380,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 +421,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 +467,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( @@ -537,3 +553,5 @@ void VsnprintfTestCase::Miscellaneous() DoMisc(5, wxT("%%%%%"), 6, wxT("%%%%%%%%%%")); DoMisc(6, wxT("%%%%12"), 7, wxT("%%%%%%%%%d"), 12); } + +#endif // wxUSE_WXVSNPRINTF