added test UTF-16 string with embedded NUL NUL which makes the current code fail
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38520 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -152,7 +152,7 @@ void UnicodeTestCase::ConversionWithNULs()
|
|||||||
CPPUNIT_ASSERT_EQUAL( lenNulString, szTheString2.length() );
|
CPPUNIT_ASSERT_EQUAL( lenNulString, szTheString2.length() );
|
||||||
CPPUNIT_ASSERT( wxTmemcmp(szTheString2.c_str(), L"The\0String",
|
CPPUNIT_ASSERT( wxTmemcmp(szTheString2.c_str(), L"The\0String",
|
||||||
lenNulString + 1) == 0 );
|
lenNulString + 1) == 0 );
|
||||||
#else
|
#else // !wxUSE_UNICODE
|
||||||
wxString szTheString(wxT("TheString"));
|
wxString szTheString(wxT("TheString"));
|
||||||
szTheString.insert(3, 1, '\0');
|
szTheString.insert(3, 1, '\0');
|
||||||
wxWCharBuffer theBuffer = szTheString.wc_str(wxConvLibc);
|
wxWCharBuffer theBuffer = szTheString.wc_str(wxConvLibc);
|
||||||
@@ -164,7 +164,7 @@ void UnicodeTestCase::ConversionWithNULs()
|
|||||||
wxWCharBuffer theLocalBuffer = szLocalTheString.wc_str(wxConvLocal);
|
wxWCharBuffer theLocalBuffer = szLocalTheString.wc_str(wxConvLocal);
|
||||||
|
|
||||||
CPPUNIT_ASSERT( memcmp(theLocalBuffer.data(), L"The\0String", 11 * sizeof(wchar_t)) == 0 );
|
CPPUNIT_ASSERT( memcmp(theLocalBuffer.data(), L"The\0String", 11 * sizeof(wchar_t)) == 0 );
|
||||||
#endif
|
#endif // wxUSE_UNICODE/!wxUSE_UNICODE
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -266,6 +266,13 @@ void UnicodeTestCase::ConversionUTF16()
|
|||||||
const StringConversionData& d = utf16data[n];
|
const StringConversionData& d = utf16data[n];
|
||||||
DoTestConversion(d.str, d.wcs, conv);
|
DoTestConversion(d.str, d.wcs, conv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// special case: this string has consecutive NULs inside it which don't
|
||||||
|
// terminate the string, this exposed a bug in our conversion code which
|
||||||
|
// got confused in this case
|
||||||
|
size_t len;
|
||||||
|
wxWCharBuffer wbuf(conv.cMB2WC("\x01\0\0B\0C" /* A macron BC */, 6, &len));
|
||||||
|
CPPUNIT_ASSERT_EQUAL( 3u, len );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // wxUSE_WCHAR_T
|
#endif // wxUSE_WCHAR_T
|
||||||
|
Reference in New Issue
Block a user