X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4cb0e8d05cadea6be3a7bd93f1fea9a9e0df95f0..38aae140acbfd562df1388ae76108efcc52f871c:/tests/mbconv/convautotest.cpp diff --git a/tests/mbconv/convautotest.cpp b/tests/mbconv/convautotest.cpp index 0c6292f625..85eac6a5bc 100644 --- a/tests/mbconv/convautotest.cpp +++ b/tests/mbconv/convautotest.cpp @@ -17,7 +17,7 @@ #pragma hdrstop #endif -#if wxUSE_WCHAR_T +#if wxUSE_UNICODE #include "wx/convauto.h" @@ -53,7 +53,10 @@ private: // real test function: check that converting the src multibyte string to // wide char using wxConvAuto yields wch as the first result - void TestFirstChar(const char *src, wchar_t wch); + // + // the length of the string may need to be passed explicitly if it has + // embedded NULs, otherwise it's not necessary + void TestFirstChar(const char *src, wchar_t wch, size_t len = wxNO_LEN); void Empty(); void Short(); @@ -81,23 +84,23 @@ private: // register in the unnamed registry so that these tests are run by default CPPUNIT_TEST_SUITE_REGISTRATION(ConvAutoTestCase); -// also include in it's own registry so that these tests can be run alone +// also include in its own registry so that these tests can be run alone CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(ConvAutoTestCase, "ConvAutoTestCase"); // ---------------------------------------------------------------------------- // tests // ---------------------------------------------------------------------------- -void ConvAutoTestCase::TestFirstChar(const char *src, wchar_t wch) +void ConvAutoTestCase::TestFirstChar(const char *src, wchar_t wch, size_t len) { - wxWCharBuffer wbuf = wxConvAuto().cMB2WC(src); + wxWCharBuffer wbuf = wxConvAuto().cMB2WC(src, len, NULL); CPPUNIT_ASSERT( wbuf ); CPPUNIT_ASSERT_EQUAL( wch, *wbuf ); } void ConvAutoTestCase::Empty() { - TestFirstChar("", wxT('\0')); + CPPUNIT_ASSERT( !wxConvAuto().cMB2WC("") ); } void ConvAutoTestCase::Short() @@ -112,22 +115,22 @@ void ConvAutoTestCase::None() void ConvAutoTestCase::UTF32LE() { - TestFirstChar("\xff\xfe\0\0A\0\0\0", wxT('A')); + TestFirstChar("\xff\xfe\0\0A\0\0\0", wxT('A'), 8); } void ConvAutoTestCase::UTF32BE() { - TestFirstChar("\0\0\xfe\xff\0\0\0B", wxT('B')); + TestFirstChar("\0\0\xfe\xff\0\0\0B", wxT('B'), 8); } void ConvAutoTestCase::UTF16LE() { - TestFirstChar("\xff\xfeZ\0", wxT('Z')); + TestFirstChar("\xff\xfeZ\0", wxT('Z'), 4); } void ConvAutoTestCase::UTF16BE() { - TestFirstChar("\xfe\xff\0Y", wxT('Y')); + TestFirstChar("\xfe\xff\0Y", wxT('Y'), 4); } void ConvAutoTestCase::UTF8() @@ -208,5 +211,4 @@ void ConvAutoTestCase::StreamUTF32BE() 20, line1, line2); } -#endif // wxUSE_WCHAR_T - +#endif // wxUSE_UNICODE