X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/75b16a30bdad8c3376ac9ec52ba7f897fc1b422a..23a081d436044ea5c827fc677f0e678cd8da4d7d:/tests/mbconv/mbconvtest.cpp diff --git a/tests/mbconv/mbconvtest.cpp b/tests/mbconv/mbconvtest.cpp index 0a57609cdc..6d385495ef 100644 --- a/tests/mbconv/mbconvtest.cpp +++ b/tests/mbconv/mbconvtest.cpp @@ -120,7 +120,7 @@ private: size_t wideChars, // the number of wide characters at wideBuffer const char* multiBuffer, // a multibyte encoded character sequence that can be decoded by "converter" size_t multiBytes, // the byte length of the multibyte character sequence that can be decoded by "converter" - wxMBConv* converter, // the wxMBConv object that can decode multiBuffer into a wide character sequence + wxMBConv& converter, // the wxMBConv object that can decode multiBuffer into a wide character sequence int sizeofNull // number of bytes occupied by terminating null in this encoding ); @@ -130,7 +130,7 @@ private: size_t wideChars, // the number of wide characters at wideBuffer const char* multiBuffer, // a multibyte encoded character sequence that can be decoded by "converter" size_t multiBytes, // the byte length of the multibyte character sequence that can be decoded by "converter" - wxMBConv* converter, // the wxMBConv object that can decode multiBuffer into a wide character sequence + wxMBConv& converter, // the wxMBConv object that can decode multiBuffer into a wide character sequence int sizeofNull // number of bytes occupied by terminating null in this encoding ); @@ -142,7 +142,7 @@ private: size_t wideChars, // the number of wide characters at wideBuffer const char* multiBuffer, // a multibyte encoded character sequence that can be decoded by "converter" size_t multiBytes, // the byte length of the multibyte character sequence that can be decoded by "converter" - wxMBConv* converter // the wxMBConv object that can decode multiBuffer into a wide character sequence + wxMBConv& converter // the wxMBConv object that can decode multiBuffer into a wide character sequence ); // use wxTextOutputStream to exercise wxMBConv interface @@ -152,7 +152,7 @@ private: size_t wideChars, // the number of wide characters at wideBuffer const char* multiBuffer, // a multibyte encoded character sequence that can be decoded by "converter" size_t multiBytes, // the byte length of the multibyte character sequence that can be decoded by "converter" - wxMBConv* converter // the wxMBConv object that can decode multiBuffer into a wide character sequence + wxMBConv& converter // the wxMBConv object that can decode multiBuffer into a wide character sequence ); #endif @@ -167,7 +167,7 @@ private: size_t multiBytes, // the byte length of the multibyte character sequence that can be decoded by "converter" const char* utf8Buffer, // the same character sequence as multiBuffer, encoded as UTF-8 size_t utf8Bytes, // the byte length of the UTF-8 encoded character sequence - wxMBConv* converter, // the wxMBConv object that can decode multiBuffer into a wide character sequence + wxMBConv& converter, // the wxMBConv object that can decode multiBuffer into a wide character sequence int sizeofNull // the number of bytes occupied by a terminating null in the converter's encoding ); @@ -212,6 +212,7 @@ private: CPPUNIT_TEST_SUITE_REGISTRATION( MBConvTestCase ); // also include in it's own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( MBConvTestCase, "MBConvTestCase" ); CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( MBConvTestCase, "MBConv" ); void MBConvTestCase::WC2CP1250() @@ -392,7 +393,7 @@ void MBConvTestCase::UTF7Tests() sizeof(welcome_wchar_t)/sizeof(wchar_t), (const char*)welcome_utf7_iconv, sizeof(welcome_utf7_iconv), - &wxConvUTF7, + wxConvUTF7, 1 ); TestDecoder @@ -401,7 +402,7 @@ void MBConvTestCase::UTF7Tests() sizeof(welcome_wchar_t)/sizeof(wchar_t), (const char*)welcome_utf7_wx, sizeof(welcome_utf7_wx), - &wxConvUTF7, + wxConvUTF7, 1 ); #if 0 @@ -414,7 +415,7 @@ void MBConvTestCase::UTF7Tests() sizeof(welcome_wchar_t)/sizeof(wchar_t), (const char*)welcome_utf7_iconv, sizeof(welcome_utf7_iconv), - &wxConvUTF7, + wxConvUTF7, 1 ); #endif @@ -424,7 +425,7 @@ void MBConvTestCase::UTF7Tests() sizeof(welcome_wchar_t)/sizeof(wchar_t), (const char*)welcome_utf7_wx, sizeof(welcome_utf7_wx), - &wxConvUTF7, + wxConvUTF7, 1 ); } @@ -437,7 +438,7 @@ void MBConvTestCase::UTF8Tests() sizeof(welcome_wchar_t)/sizeof(wchar_t), (const char*)welcome_utf8, sizeof(welcome_utf8), - &wxConvUTF8, + wxConvUTF8, 1 ); TestEncoder @@ -446,7 +447,7 @@ void MBConvTestCase::UTF8Tests() sizeof(welcome_wchar_t)/sizeof(wchar_t), (const char*)welcome_utf8, sizeof(welcome_utf8), - &wxConvUTF8, + wxConvUTF8, 1 ); } @@ -460,7 +461,7 @@ void MBConvTestCase::UTF16LETests() sizeof(welcome_wchar_t)/sizeof(wchar_t), (const char*)welcome_utf16le, sizeof(welcome_utf16le), - &convUTF16LE, + convUTF16LE, 2 ); TestEncoder @@ -469,7 +470,7 @@ void MBConvTestCase::UTF16LETests() sizeof(welcome_wchar_t)/sizeof(wchar_t), (const char*)welcome_utf16le, sizeof(welcome_utf16le), - &convUTF16LE, + convUTF16LE, 2 ); } @@ -483,7 +484,7 @@ void MBConvTestCase::UTF16BETests() sizeof(welcome_wchar_t)/sizeof(wchar_t), (const char*)welcome_utf16be, sizeof(welcome_utf16be), - &convUTF16BE, + convUTF16BE, 2 ); TestEncoder @@ -492,7 +493,7 @@ void MBConvTestCase::UTF16BETests() sizeof(welcome_wchar_t)/sizeof(wchar_t), (const char*)welcome_utf16be, sizeof(welcome_utf16be), - &convUTF16BE, + convUTF16BE, 2 ); } @@ -506,7 +507,7 @@ void MBConvTestCase::UTF32LETests() sizeof(welcome_wchar_t)/sizeof(wchar_t), (const char*)welcome_utf32le, sizeof(welcome_utf32le), - &convUTF32LE, + convUTF32LE, 4 ); TestEncoder @@ -515,7 +516,7 @@ void MBConvTestCase::UTF32LETests() sizeof(welcome_wchar_t)/sizeof(wchar_t), (const char*)welcome_utf32le, sizeof(welcome_utf32le), - &convUTF32LE, + convUTF32LE, 4 ); } @@ -529,7 +530,7 @@ void MBConvTestCase::UTF32BETests() sizeof(welcome_wchar_t)/sizeof(wchar_t), (const char*)welcome_utf32be, sizeof(welcome_utf32be), - &convUTF32BE, + convUTF32BE, 4 ); TestEncoder @@ -538,7 +539,7 @@ void MBConvTestCase::UTF32BETests() sizeof(welcome_wchar_t)/sizeof(wchar_t), (const char*)welcome_utf32be, sizeof(welcome_utf32be), - &convUTF32BE, + convUTF32BE, 4 ); } @@ -552,7 +553,7 @@ void MBConvTestCase::CP932Tests() sizeof(welcome_wchar_t)/sizeof(wchar_t), (const char*)welcome_cp932, sizeof(welcome_cp932), - &convCP932, + convCP932, 1 ); TestEncoder @@ -561,7 +562,7 @@ void MBConvTestCase::CP932Tests() sizeof(welcome_wchar_t)/sizeof(wchar_t), (const char*)welcome_cp932, sizeof(welcome_cp932), - &convCP932, + convCP932, 1 ); } @@ -742,7 +743,7 @@ void MBConvTestCase::TestCoder( size_t multiBytes, // the byte length of the multibyte character sequence that can be decoded by "converter" const char* utf8Buffer, // the same character sequence as multiBuffer, encoded as UTF-8 size_t utf8Bytes, // the byte length of the UTF-8 encoded character sequence - wxMBConv* converter, // the wxMBConv object thta can decode multiBuffer into a wide character sequence + wxMBConv& converter, // the wxMBConv object thta can decode multiBuffer into a wide character sequence int sizeofNull // the number of bytes occupied by a terminating null in the converter's encoding ) { @@ -776,12 +777,12 @@ void MBConvTestCase::TestCoder( } -WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_wxwin( const wxChar* name ); +WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_wxwin( const char* name ); void MBConvTestCase::FontmapTests() { #ifdef wxUSE_FONTMAP - wxMBConv* converter = new_wxMBConv_wxwin( _T("CP1252") ); + wxMBConv* converter = new_wxMBConv_wxwin("CP1252"); if ( !converter ) { return; @@ -791,7 +792,7 @@ void MBConvTestCase::FontmapTests() sizeof(CP1252), (const char*)CP1252_utf8, sizeof(CP1252_utf8), - converter, + *converter, 1 ); delete converter; @@ -799,12 +800,12 @@ void MBConvTestCase::FontmapTests() } -WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_iconv( const wxChar* name ); +WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_iconv( const char* name ); void MBConvTestCase::IconvTests() { #ifdef HAVE_ICONV - wxMBConv* converter = new_wxMBConv_iconv( _T("CP932") ); + wxMBConv* converter = new_wxMBConv_iconv("CP932"); if ( !converter ) { return; @@ -814,7 +815,7 @@ void MBConvTestCase::IconvTests() sizeof(welcome_cp932), (const char*)welcome_utf8, sizeof(welcome_utf8), - converter, + *converter, 1 ); delete converter; @@ -829,7 +830,7 @@ void MBConvTestCase::CP1252Tests() sizeof(CP1252), (const char*)CP1252_utf8, sizeof(CP1252_utf8), - &convCP1252, + convCP1252, 1 ); } @@ -860,7 +861,7 @@ void MBConvTestCase::LibcTests() systemMB_size, (const char*)systemMB_utf8, systemMB_utf8_size, - &convLibc, + convLibc, 1 ); @@ -873,7 +874,7 @@ void MBConvTestCase::TestDecoder( size_t wideChars, // the number of wide characters at wideBuffer const char* multiBuffer, // a multibyte encoded character sequence that can be decoded by "converter" size_t multiBytes, // the byte length of the multibyte character sequence that can be decoded by "converter" - wxMBConv* converter, // the wxMBConv object that can decode multiBuffer into a wide character sequence + wxMBConv& converter, // the wxMBConv object that can decode multiBuffer into a wide character sequence int sizeofNull // number of bytes occupied by terminating null in this encoding ) { @@ -885,7 +886,7 @@ void MBConvTestCase::TestDecoder( memset( &inputCopy.data()[multiBytes], 0, sizeofNull ); // calculate the output size - size_t outputWritten = converter->MB2WC + size_t outputWritten = converter.MB2WC ( 0, (const char*)inputCopy.data(), @@ -901,7 +902,7 @@ void MBConvTestCase::TestDecoder( wxWCharBuffer outputBuffer(outputBufferChars); memset( outputBuffer.data(), UNINITIALIZED, outputBufferChars*sizeof(wchar_t) ); - outputWritten = converter->MB2WC + outputWritten = converter.MB2WC ( outputBuffer.data(), (const char*)inputCopy.data(), @@ -933,7 +934,7 @@ void MBConvTestCase::TestEncoder( size_t wideChars, // the number of wide characters at wideBuffer const char* multiBuffer, // a multibyte encoded character sequence that can be decoded by "converter" size_t multiBytes, // the byte length of the multibyte character sequence that can be decoded by "converter" - wxMBConv* converter, // the wxMBConv object that can decode multiBuffer into a wide character sequence + wxMBConv& converter, // the wxMBConv object that can decode multiBuffer into a wide character sequence int sizeofNull // number of bytes occupied by terminating null in this encoding ) { @@ -945,7 +946,7 @@ void MBConvTestCase::TestEncoder( inputCopy.data()[wideChars] = 0; // calculate the output size - size_t outputWritten = converter->WC2MB + size_t outputWritten = converter.WC2MB ( 0, (const wchar_t*)inputCopy.data(), @@ -960,7 +961,7 @@ void MBConvTestCase::TestEncoder( wxCharBuffer outputBuffer(outputBufferSize); memset( outputBuffer.data(), UNINITIALIZED, outputBufferSize ); - outputWritten = converter->WC2MB + outputWritten = converter.WC2MB ( outputBuffer.data(), (const wchar_t*)inputCopy.data(), @@ -1000,14 +1001,14 @@ void MBConvTestCase::TestStreamDecoder( size_t wideChars, // the number of wide characters at wideBuffer const char* multiBuffer, // a multibyte encoded character sequence that can be decoded by "converter" size_t multiBytes, // the byte length of the multibyte character sequence that can be decoded by "converter" - wxMBConv* converter // the wxMBConv object that can decode multiBuffer into a wide character sequence + wxMBConv& converter // the wxMBConv object that can decode multiBuffer into a wide character sequence ) { // this isn't meant to test wxMemoryInputStream or wxTextInputStream // it's meant to test the way wxTextInputStream uses wxMBConv // (which has exposed some problems with wxMBConv) wxMemoryInputStream memoryInputStream( multiBuffer, multiBytes ); - wxTextInputStream textInputStream( memoryInputStream, wxT(""), *converter ); + wxTextInputStream textInputStream( memoryInputStream, wxT(""), converter ); for ( size_t i = 0; i < wideChars; i++ ) { wxChar wc = textInputStream.GetChar(); @@ -1026,7 +1027,7 @@ void MBConvTestCase::TestStreamEncoder( size_t wideChars, // the number of wide characters at wideBuffer const char* multiBuffer, // a multibyte encoded character sequence that can be decoded by "converter" size_t multiBytes, // the byte length of the multibyte character sequence that can be decoded by "converter" - wxMBConv* converter // the wxMBConv object that can decode multiBuffer into a wide character sequence + wxMBConv& converter // the wxMBConv object that can decode multiBuffer into a wide character sequence ) { // this isn't meant to test wxMemoryOutputStream or wxTextOutputStream @@ -1034,7 +1035,7 @@ void MBConvTestCase::TestStreamEncoder( // (which has exposed some problems with wxMBConv) wxMemoryOutputStream memoryOutputStream; // wxEOL_UNIX will pass \n \r unchanged - wxTextOutputStream textOutputStream( memoryOutputStream, wxEOL_UNIX, *converter ); + wxTextOutputStream textOutputStream( memoryOutputStream, wxEOL_UNIX, converter ); for ( size_t i = 0; i < wideChars; i++ ) { textOutputStream.PutChar( wideBuffer[i] );