CPPUNIT_TEST( G );
CPPUNIT_TEST( S );
CPPUNIT_TEST( Asterisk );
+ CPPUNIT_TEST( Percent );
+ CPPUNIT_TEST( LongLong );
CPPUNIT_TEST( BigToSmallBuffer );
CPPUNIT_TEST_SUITE_END();
void G();
void S();
void Asterisk();
+ void Percent();
+ void LongLong();
+ void Unicode();
void BigToSmallBuffer();
void Misc(wxChar *buffer, int size);
CMP3("abcde", "%.5s", wxT("abcdefghi"));
+ // do the same tests but with Unicode characters:
+#if wxUSE_UNICODE
+ #define ALPHA "\x3B1"
+ #define BETA "\x3B2"
+ #define GAMMA "\x3B3"
+ #define DELTA "\x3B4"
+ #define EPSILON "\x3B5"
+ #define ZETA "\x3B6"
+ #define ETA "\x3B7"
+ #define THETA "\x3B8"
+ #define IOTA "\x3B9"
+
+ #define ABC ALPHA BETA GAMMA
+ #define ABCDE ALPHA BETA GAMMA DELTA EPSILON
+ #define ABCDEFGHI ALPHA BETA GAMMA DELTA EPSILON ZETA ETA THETA IOTA
+
+ CMP3(" " ABC, "%5s", wxT(ABC));
+ CMP3(" " ALPHA, "%5s", wxT(ALPHA));
+ CMP3(ABCDEFGHI, "%5s", wxT(ABCDEFGHI));
+ CMP3(ABC " ", "%-5s", wxT(ABC));
+ CMP3(ABCDEFGHI, "%-5s", wxT(ABCDEFGHI));
+
+ CMP3(ABCDE, "%.5s", wxT(ABCDEFGHI));
+#endif
+}
+
+void VsnprintfTestCase::Asterisk()
+{
+ CMP5(" 0.1", "%*.*f", 10, 1, 0.123);
+ CMP5(" 0.1230", "%*.*f", 10, 4, 0.123);
+ CMP5("0.1", "%*.*f", 3, 1, 0.123);
+
+ CMP4("%0.002", "%%%.*f", 3, 0.0023456789);
+}
+
+void VsnprintfTestCase::Percent()
+{
// some tests without any argument passed through ...
CMP2("%", "%%");
CMP2("%%%", "%%%%%%");
+ CMP3("% abc", "%%%5s", wxT("abc"));
+ CMP3("% abc%", "%%%5s%%", wxT("abc"));
+
// do not test odd number of '%' symbols as different implementations
// of snprintf() give different outputs as this situation is not considered
// by any standard (in fact, GCC will also warn you about a spurious % if
// Compare(wxT("%"), wxT("%%%"));
}
-void VsnprintfTestCase::Asterisk()
+void VsnprintfTestCase::LongLong()
{
- CMP5(" 0.1", "%*.*f", 10, 1, 0.123);
- CMP5(" 0.1230", "%*.*f", 10, 4, 0.123);
- CMP5("0.1", "%*.*f", 3, 1, 0.123);
+ CMP3("123456789", "%lld", (long long int)123456789);
+ CMP3("-123456789", "%lld", (long long int)-123456789);
- CMP4("%0.002", "%%%.*f", 3, 0.0023456789);
+ CMP3("123456789", "%llu", (unsigned long long int)123456789);
}
void VsnprintfTestCase::Misc(wxChar *buffer, int size)