check if conversion to UTF7 works

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30160 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2004-10-29 09:29:52 +00:00
parent 930357bd25
commit c20d8682bd

View File

@@ -42,8 +42,11 @@ private:
CPPUNIT_TEST( Constructors ); CPPUNIT_TEST( Constructors );
#if wxUSE_WCHAR_T #if wxUSE_WCHAR_T
CPPUNIT_TEST( ConstructorsWithConversion ); CPPUNIT_TEST( ConstructorsWithConversion );
#endif
CPPUNIT_TEST( Conversion ); CPPUNIT_TEST( Conversion );
#endif
#if wxUSE_UNICODE
CPPUNIT_TEST( ConversionUTF7 );
#endif
CPPUNIT_TEST( Extraction ); CPPUNIT_TEST( Extraction );
CPPUNIT_TEST( Find ); CPPUNIT_TEST( Find );
CPPUNIT_TEST( Tokenizer ); CPPUNIT_TEST( Tokenizer );
@@ -61,8 +64,11 @@ private:
void Constructors(); void Constructors();
#if wxUSE_WCHAR_T #if wxUSE_WCHAR_T
void ConstructorsWithConversion(); void ConstructorsWithConversion();
#endif
void Conversion(); void Conversion();
#endif
#if wxUSE_UNICODE
void ConversionUTF7();
#endif
void Extraction(); void Extraction();
void Find(); void Find();
void SingleTokenizerTest( wxChar *str, wxChar *delims, size_t count , wxStringTokenizerMode mode ); void SingleTokenizerTest( wxChar *str, wxChar *delims, size_t count , wxStringTokenizerMode mode );
@@ -180,7 +186,6 @@ void StringTestCase::ConstructorsWithConversion()
CPPUNIT_ASSERT( s3 == sub ); CPPUNIT_ASSERT( s3 == sub );
CPPUNIT_ASSERT( s4 == sub ); CPPUNIT_ASSERT( s4 == sub );
} }
#endif
void StringTestCase::Conversion() void StringTestCase::Conversion()
{ {
@@ -193,7 +198,6 @@ void StringTestCase::Conversion()
wxString szTheString2("The\0String", wxConvLocal, 10); wxString szTheString2("The\0String", wxConvLocal, 10);
CPPUNIT_ASSERT( wxMemcmp(szTheString2.c_str(), L"The\0String", 11) == 0 ); CPPUNIT_ASSERT( wxMemcmp(szTheString2.c_str(), L"The\0String", 11) == 0 );
#else #else
# if wxUSE_WCHAR_T
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);
@@ -205,9 +209,21 @@ void StringTestCase::Conversion()
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 #endif
} }
#endif // wxUSE_WCHAR_T
#if wxUSE_UNICODE
void StringTestCase::ConversionUTF7()
{
const wxChar wdata[] = { 0x00A3, 0x00A3, 0x00A3, 0x00A3, 0 }; // pound signs
const char *utf7 = "+AKM-+AKM-+AKM-+AKM-";
wxString str(wdata);
wxCSConv conv(_T("utf-7"));
CPPUNIT_ASSERT( strcmp(str.mb_str(conv), utf7) == 0 );
}
#endif // wxUSE_UNICODE
void StringTestCase::Extraction() void StringTestCase::Extraction()
{ {