Handle strings with embedded NULs in wxDataStream

Read/write the entire string and not just the part until the first NUL in it.

Closes #17556.
This commit is contained in:
Vadim Zeitlin
2016-06-04 21:47:12 +02:00
parent 889cbd8e04
commit d68eb10e3d
3 changed files with 19 additions and 2 deletions

View File

@@ -39,6 +39,7 @@ private:
CPPUNIT_TEST_SUITE( DataStreamTestCase );
CPPUNIT_TEST( FloatRW );
CPPUNIT_TEST( DoubleRW );
CPPUNIT_TEST( StringRW );
#if wxUSE_LONGLONG
CPPUNIT_TEST( LongLongRW );
#endif
@@ -66,6 +67,7 @@ private:
void FloatRW();
void DoubleRW();
void StringRW();
#if wxUSE_LONGLONG
void LongLongRW();
#endif
@@ -236,6 +238,19 @@ void DataStreamTestCase::DoubleRW()
CPPUNIT_ASSERT( TestFloatRW(21321343431.1232143432) == 21321343431.1232143432 );
}
void DataStreamTestCase::StringRW()
{
wxString s(wxT("Test1"));
CPPUNIT_ASSERT_EQUAL( TestRW(s), s );
s.append(2, wxT('\0'));
s.append(wxT("Test2"));
CPPUNIT_ASSERT_EQUAL( TestRW(s), s );
s = wxString::FromUTF8("\xc3\xbc"); // U+00FC LATIN SMALL LETTER U WITH DIAERESIS
CPPUNIT_ASSERT_EQUAL( TestRW(s), s );
}
#if wxUSE_LONGLONG
void DataStreamTestCase::LongLongRW()
{