From e8207c8c59eee5b5916c72e21467cd97210c4ac0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C4=83t=C4=83lin=20R=C4=83ceanu?= Date: Fri, 24 Feb 2017 16:37:37 +0200 Subject: [PATCH] Fix building tests with wxUSE_UNSAFE_WXSTRING_CONV==0 Avoid relying on implicit conversions to std::string in the tests code. --- tests/mbconv/mbconvtest.cpp | 2 +- tests/strings/stdstrings.cpp | 2 ++ tests/strings/strings.cpp | 2 ++ tests/strings/unicode.cpp | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/mbconv/mbconvtest.cpp b/tests/mbconv/mbconvtest.cpp index 4674a67e9a..7045b3673e 100644 --- a/tests/mbconv/mbconvtest.cpp +++ b/tests/mbconv/mbconvtest.cpp @@ -1247,7 +1247,7 @@ void MBConvTestCase::TestStreamDecoder( { wxChar wc = textInputStream.GetChar(); CPPUNIT_ASSERT_EQUAL_MESSAGE( - std::string(wxString::Format("At position %lu", (unsigned long)i)), + wxString::Format("At position %lu", (unsigned long)i).ToStdString(), wideBuffer[i], wc ); diff --git a/tests/strings/stdstrings.cpp b/tests/strings/stdstrings.cpp index cf80f2eb5f..1446a8c040 100644 --- a/tests/strings/stdstrings.cpp +++ b/tests/strings/stdstrings.cpp @@ -607,8 +607,10 @@ void StdStringTestCase::StdConversion() #endif CPPUNIT_ASSERT_EQUAL( "hello", s6 ); +#if wxUSE_UNSAFE_WXSTRING_CONV std::string s7(s4); CPPUNIT_ASSERT( s7 == "hello" ); +#endif wxStdWideString s8(s4); CPPUNIT_ASSERT( s8 == "hello" ); diff --git a/tests/strings/strings.cpp b/tests/strings/strings.cpp index aa65f71954..3562510b51 100644 --- a/tests/strings/strings.cpp +++ b/tests/strings/strings.cpp @@ -1028,8 +1028,10 @@ void StringTestCase::CStrDataImplicitConversion() // implicit conversion of wxString is not available in STL build #if !wxUSE_STL CPPUNIT_ASSERT( CheckStrConstWChar(s, s) ); +#if wxUSE_UNSAFE_WXSTRING_CONV CPPUNIT_ASSERT( CheckStrConstChar(s, s) ); #endif +#endif } void StringTestCase::ExplicitConversion() diff --git a/tests/strings/unicode.cpp b/tests/strings/unicode.cpp index 19587dd99f..04345bf199 100644 --- a/tests/strings/unicode.cpp +++ b/tests/strings/unicode.cpp @@ -113,7 +113,7 @@ private: static std::string Message(size_t n, const wxString& msg) { - return std::string(wxString::Format("#%lu: %s", (unsigned long)n, msg)); + return wxString::Format("#%lu: %s", (unsigned long)n, msg).ToStdString(); } template