+ // this call is required to avoid check failures when running on machines
+ // with a locale where the decimal point is not '.'
+ wxSetlocale(LC_ALL, "C");
+}
+
+void VsnprintfTestCase::C()
+{
+ CMP5("hi!", "%c%c%c", wxT('h'), wxT('i'), wxT('!'));
+
+ // NOTE:
+ // the NULL characters _can_ be passed to %c to e.g. create strings
+ // with embedded NULs (because strings are not always supposed to be
+ // NUL-terminated).
+
+ DoMisc(14, wxT("Hello \0 World!"), 16, wxT("Hello %c World!"), wxT('\0'));
+}
+
+void VsnprintfTestCase::D()
+{
+ CMP3("+123456", "%+d", 123456);
+ CMP3("-123456", "%d", -123456);
+ CMP3(" 123456", "% d", 123456);
+ CMP3(" 123456", "%10d", 123456);
+ CMP3("0000123456", "%010d", 123456);
+ CMP3("-123456 ", "%-10d", -123456);
+}
+
+void VsnprintfTestCase::X()
+{
+ CMP3("ABCD", "%X", 0xABCD);
+ CMP3("0XABCD", "%#X", 0xABCD);
+ CMP3("0xabcd", "%#x", 0xABCD);
+}
+
+void VsnprintfTestCase::O()
+{
+ CMP3("1234567", "%o", 01234567);
+ CMP3("01234567", "%#o", 01234567);
+}
+
+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 by default so uses the same rules
+#if defined(__VISUALC__) || (defined(__MINGW32__) && !__USE_MINGW_ANSI_STDIO)
+ #if SIZEOF_VOID_P == 4
+ CMP3("00ABCDEF", "%p", (void*)0xABCDEF);
+ CMP3("00000000", "%p", (void*)NULL);
+ #elif SIZEOF_VOID_P == 8
+ CMP3("0000ABCDEFABCDEF", "%p", (void*)0xABCDEFABCDEF);
+ CMP3("0000000000000000", "%p", (void*)NULL);
+ #endif
+#elif defined(__MINGW32__)
+ CMP3("0xabcdef", "%p", (void*)0xABCDEF);
+ CMP3("0", "%p", (void*)NULL);
+#elif defined(__GNUG__)
+ CMP3("0xabcdef", "%p", (void*)0xABCDEF);
+ CMP3("(nil)", "%p", (void*)NULL);
+#endif
+}
+
+void VsnprintfTestCase::N()
+{
+ int nchar;
+
+ wxSnprintf(buf, MAX_TEST_LEN, _T("%d %s%n\n"), 3, _T("bears"), &nchar);
+ CPPUNIT_ASSERT_EQUAL( 7, nchar );