Avoid using wxString::ReadAll() on a file containing binary data
ReadAll() does character set conversion, which will likely fail
This commit is contained in:
@@ -149,7 +149,7 @@ void FileFunctionsTestCase::GetTempFolder()
|
|||||||
|
|
||||||
void FileFunctionsTestCase::CopyFile()
|
void FileFunctionsTestCase::CopyFile()
|
||||||
{
|
{
|
||||||
const wxString filename1(wxT("horse.bmp"));
|
const wxString filename1(wxS("horse.xpm"));
|
||||||
const wxString& filename2 = m_fileNameWork;
|
const wxString& filename2 = m_fileNameWork;
|
||||||
|
|
||||||
const std::string msg =
|
const std::string msg =
|
||||||
@@ -166,8 +166,7 @@ void FileFunctionsTestCase::CopyFile()
|
|||||||
|
|
||||||
wxString s1, s2;
|
wxString s1, s2;
|
||||||
CPPUNIT_ASSERT_MESSAGE( msg, f1.ReadAll(&s1) && f2.ReadAll(&s2) );
|
CPPUNIT_ASSERT_MESSAGE( msg, f1.ReadAll(&s1) && f2.ReadAll(&s2) );
|
||||||
CPPUNIT_ASSERT_MESSAGE( msg, (s1.length() == s2.length()) &&
|
CPPUNIT_ASSERT_MESSAGE( msg, s1 == s2 );
|
||||||
(memcmp(s1.c_str(), s2.c_str(), s1.length()) == 0) );
|
|
||||||
|
|
||||||
CPPUNIT_ASSERT_MESSAGE( msg, f1.Close() && f2.Close() );
|
CPPUNIT_ASSERT_MESSAGE( msg, f1.Close() && f2.Close() );
|
||||||
CPPUNIT_ASSERT_MESSAGE( msg, wxRemoveFile(filename2) );
|
CPPUNIT_ASSERT_MESSAGE( msg, wxRemoveFile(filename2) );
|
||||||
|
Reference in New Issue
Block a user