+ enum
+ {
+ TEST_BOTH = 0, // test both str -> wcs and wcs -> str
+ ONLY_MB2WC = 1 // only test str -> wcs conversion
+ };
+
+ const int flags;
+
+ // test that the conversion between str and wcs (subject to flags) succeeds
+ //
+ // the first argument is the index in the test array and is used solely for
+ // diagnostics
+ void Test(size_t n, wxMBConv& conv) const
+ {
+ if ( str )
+ {
+ wxWCharBuffer wbuf = conv.cMB2WC(str);
+
+ if ( wcs )
+ {
+ CPPUNIT_ASSERT_MESSAGE
+ (
+ Message(n, "MB2WC failed"),
+ wbuf.data()
+ );
+
+ CPPUNIT_ASSERT_MESSAGE
+ (
+ Message(n, "MB2WC", wbuf, wcs),
+ wxStrcmp(wbuf, wcs) == 0
+ );
+ }
+ else // conversion is supposed to fail
+ {
+ CPPUNIT_ASSERT_MESSAGE
+ (
+ Message(n, "MB2WC succeeded"),
+ !wbuf.data()
+ );
+ }
+ }
+
+ if ( wcs && !(flags & ONLY_MB2WC) )
+ {
+ wxCharBuffer buf = conv.cWC2MB(wcs);
+
+ if ( str )
+ {
+ CPPUNIT_ASSERT_MESSAGE
+ (
+ Message(n, "WC2MB failed"),
+ buf.data()
+ );
+
+ CPPUNIT_ASSERT_MESSAGE
+ (
+ Message(n, "WC2MB", buf, str),
+ strcmp(buf, str) == 0
+ );
+ }
+ else
+ {
+ CPPUNIT_ASSERT_MESSAGE
+ (
+ Message(n, "WC2MB succeeded"),
+ !buf.data()
+ );
+ }
+ }
+ }
+
+private:
+ static std::string
+ Message(size_t n, const wxString& msg)