added small UTF 8 conversion test case
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31665 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
900a87655f
commit
ec54fe9e18
@ -42,7 +42,8 @@ private:
|
||||
CPPUNIT_TEST( ConstructorsWithConversion );
|
||||
CPPUNIT_TEST( Conversion );
|
||||
CPPUNIT_TEST( ConversionUTF7 );
|
||||
#endif
|
||||
CPPUNIT_TEST( ConversionUTF8 );
|
||||
#endif // wxUSE_WCHAR_T
|
||||
CPPUNIT_TEST( Extraction );
|
||||
CPPUNIT_TEST( Find );
|
||||
CPPUNIT_TEST( Tokenizer );
|
||||
@ -62,7 +63,8 @@ private:
|
||||
void ConstructorsWithConversion();
|
||||
void Conversion();
|
||||
void ConversionUTF7();
|
||||
#endif
|
||||
void ConversionUTF8();
|
||||
#endif // wxUSE_WCHAR_T
|
||||
void Extraction();
|
||||
void Find();
|
||||
void SingleTokenizerTest( wxChar *str, wxChar *delims, size_t count , wxStringTokenizerMode mode );
|
||||
@ -248,6 +250,24 @@ void StringTestCase::ConversionUTF7()
|
||||
#endif // wxUSE_UNICODE
|
||||
}
|
||||
|
||||
void StringTestCase::ConversionUTF8()
|
||||
{
|
||||
const wchar_t wcs[] = { 0x00A3, 0x00A3, 0x00A3, 0x00A3, 0 }; // pound signs
|
||||
const char *utf8 = "\xc2\xa3\xc2\xa3\xc2\xa3\xc2\xa3";
|
||||
|
||||
wxCSConv conv(_T("utf-8"));
|
||||
|
||||
#if wxUSE_UNICODE
|
||||
wxCharBuffer buf(wxString(wcs).mb_str(conv));
|
||||
|
||||
CPPUNIT_ASSERT( strcmp(buf, utf8) == 0 );
|
||||
#else // !wxUSE_UNICODE
|
||||
wxWCharBuffer wbuf(wxString(utf8).wc_str(conv));
|
||||
|
||||
CPPUNIT_ASSERT( wcscmp(wbuf, wcs) == 0 );
|
||||
#endif // wxUSE_UNICODE/!wxUSE_UNICODE
|
||||
}
|
||||
|
||||
#endif // wxUSE_WCHAR_T
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user