X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/78648f606dac99c2af5f8d5bfec3635d9d7031fd..4f2511d706e5274a34e1521e11c1b95fed735b42:/tests/mbconv/mbconvtest.cpp?ds=sidebyside diff --git a/tests/mbconv/mbconvtest.cpp b/tests/mbconv/mbconvtest.cpp index e1db40d81d..b5d0185467 100644 --- a/tests/mbconv/mbconvtest.cpp +++ b/tests/mbconv/mbconvtest.cpp @@ -78,6 +78,7 @@ private: CPPUNIT_TEST( CP1252Tests ); // depends on UTF8 Decoder functioning correctly CPPUNIT_TEST( LibcTests ); CPPUNIT_TEST( IconvTests ); + CPPUNIT_TEST( Latin1Tests ); CPPUNIT_TEST( FontmapTests ); #ifdef HAVE_WCHAR_H CPPUNIT_TEST( UTF8_41 ); @@ -113,6 +114,7 @@ private: void LibcTests(); void FontmapTests(); void IconvTests(); + void Latin1Tests(); // verifies that the specified multibyte sequence decodes to the specified wchar_t sequence void TestDecoder( @@ -828,6 +830,24 @@ void MBConvTestCase::IconvTests() #endif } +void MBConvTestCase::Latin1Tests() +{ + TestCoder( + (const char*)iso8859_1, + sizeof(iso8859_1), + (const char*)iso8859_1_utf8, + sizeof(iso8859_1_utf8), + wxConvISO8859_1, + 1 + ); + + static const char nulstr[] = "foo\0bar\0"; + static const size_t mbLen = WXSIZEOF(nulstr) - 1; + size_t wcLen; + wxWCharBuffer wbuf(wxConvISO8859_1.cMB2WC(nulstr, mbLen, &wcLen)); + CPPUNIT_ASSERT_EQUAL( mbLen, wcLen ); +} + void MBConvTestCase::CP1252Tests() { wxCSConv convCP1252( wxFONTENCODING_CP1252 ); @@ -1018,7 +1038,11 @@ void MBConvTestCase::TestStreamDecoder( for ( size_t i = 0; i < wideChars; i++ ) { wxChar wc = textInputStream.GetChar(); - CPPUNIT_ASSERT( wc == wideBuffer[i] ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + std::string(wxString::Format("At position %lu", (unsigned long)i)), + wideBuffer[i], + wc + ); } CPPUNIT_ASSERT( 0 == textInputStream.GetChar() ); CPPUNIT_ASSERT( memoryInputStream.Eof() ); @@ -1046,6 +1070,9 @@ void MBConvTestCase::TestStreamEncoder( { textOutputStream.PutChar( wideBuffer[i] ); } + + textOutputStream.Flush(); + CPPUNIT_ASSERT_EQUAL( (wxFileOffset)multiBytes, memoryOutputStream.TellO() ); wxCharBuffer copy( memoryOutputStream.TellO() ); memoryOutputStream.CopyTo( copy.data(), memoryOutputStream.TellO());