From 24b4db9b0de92ef5c899b98a556f8cd09ad1fc54 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 16 Oct 2010 23:05:26 +0000 Subject: [PATCH] Fix FileTestCase to really test strings with embedded NULs. The test was intended to verify that round trip via wxFile::Write/Read() worked even for the strings with embedded NULs but as the string wasn't constructed correctly it didn't actually contain any NULs but was ended by the first of them. Fix this by using explicit length of the string as usual when dealing with strings with embedded NULs. Also fix the conversion back to Unicode to use the correct length. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65835 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- tests/file/filetest.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/file/filetest.cpp b/tests/file/filetest.cpp index 446a59fa8d..4ee972b8b7 100644 --- a/tests/file/filetest.cpp +++ b/tests/file/filetest.cpp @@ -71,7 +71,8 @@ void FileTestCase::DoRoundTripTest(const wxMBConv& conv) { TestFile tf; - const wxString data = "Hello\0UTF"; + // Explicit length is needed because of the embedded NUL. + const wxString data("Hello\0UTF!", 10); { wxFile fout(tf.GetName(), wxFile::write); @@ -88,8 +89,8 @@ void FileTestCase::DoRoundTripTest(const wxMBConv& conv) wxCharBuffer buf(len); CPPUNIT_ASSERT_EQUAL( len, fin.Read(buf.data(), len) ); - wxWCharBuffer wbuf(conv.cMB2WC(buf)); - CPPUNIT_ASSERT_EQUAL( data, wbuf ); + wxString dataReadBack(buf, conv, len); + CPPUNIT_ASSERT_EQUAL( data, dataReadBack ); } }