From 1809ade5ad4198d791748ea98b42e9fab8ed10df Mon Sep 17 00:00:00 2001 From: ARATA Mizuki Date: Fri, 25 Mar 2016 16:28:00 +0900 Subject: [PATCH] Test the conversion of wxString from/to UTF-8 std::string in StdStringTestCase::StdConversion --- tests/strings/stdstrings.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/strings/stdstrings.cpp b/tests/strings/stdstrings.cpp index 9c7a56471c..0110e9d0e8 100644 --- a/tests/strings/stdstrings.cpp +++ b/tests/strings/stdstrings.cpp @@ -608,5 +608,12 @@ void StdStringTestCase::StdConversion() wxStdWideString s8(s4); CPPUNIT_ASSERT( s8 == "hello" ); + + std::string s9("\xF0\x9F\x90\xB1\0\xE7\x8C\xAB", 9); /* U+1F431 U+0000 U+732B */ + wxString s10 = wxString::FromUTF8(s9); + CPPUNIT_ASSERT_EQUAL( s9, s10.ToStdString(wxConvUTF8) ); + + std::string s11("xyz\0\xFF", 5); /* an invalid UTF-8 sequence */ + CPPUNIT_ASSERT_EQUAL( wxString::FromUTF8(s11), "" ); } #endif // wxUSE_STD_STRING