X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9a83f860948059b0273b5cc6d9e43fadad3ebfca..2c336e249e8c3dac4390ba0c23a22d5ba35b579b:/tests/strings/stdstrings.cpp diff --git a/tests/strings/stdstrings.cpp b/tests/strings/stdstrings.cpp index 294eb923d6..94838ff59b 100644 --- a/tests/strings/stdstrings.cpp +++ b/tests/strings/stdstrings.cpp @@ -34,6 +34,7 @@ private: CPPUNIT_TEST_SUITE( StdStringTestCase ); CPPUNIT_TEST( StdConstructors ); CPPUNIT_TEST( StdIterators ); + CPPUNIT_TEST( StdIteratorsCmp ); CPPUNIT_TEST( StdAppend ); CPPUNIT_TEST( StdAssign ); CPPUNIT_TEST( StdCompare ); @@ -54,6 +55,7 @@ private: void StdConstructors(); void StdIterators(); + void StdIteratorsCmp(); void StdAppend(); void StdAssign(); void StdCompare(); @@ -77,7 +79,7 @@ private: // register in the unnamed registry so that these tests are run by default CPPUNIT_TEST_SUITE_REGISTRATION( StdStringTestCase ); -// also include in it's own registry so that these tests can be run alone +// also include in its own registry so that these tests can be run alone CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( StdStringTestCase, "StdStringTestCase" ); StdStringTestCase::StdStringTestCase() @@ -119,6 +121,30 @@ void StdStringTestCase::StdIterators() wxString::const_reverse_iterator i4; } +void StdStringTestCase::StdIteratorsCmp() +{ + wxString s("foobar"); + wxString::iterator i = s.begin(); + wxString::const_iterator ci = s.begin(); + + CPPUNIT_ASSERT( i == ci ); + CPPUNIT_ASSERT( i >= ci ); + CPPUNIT_ASSERT( i <= ci ); + CPPUNIT_ASSERT( ci == i ); + CPPUNIT_ASSERT( ci >= i ); + CPPUNIT_ASSERT( ci <= i ); + + ci++; + + CPPUNIT_ASSERT( i != ci ); + CPPUNIT_ASSERT( i < ci ); + CPPUNIT_ASSERT( !(i > ci) ); + + CPPUNIT_ASSERT( ci != i ); + CPPUNIT_ASSERT( ci > i ); + CPPUNIT_ASSERT( !(ci < i) ); +} + void StdStringTestCase::StdAppend() { wxString s1, s2, s3, s4, s5, s6, s7, s8; @@ -489,10 +515,12 @@ void StdStringTestCase::StdResize() CPPUNIT_ASSERT_EQUAL( wxT("abcABCdefDEF "), s3 ); CPPUNIT_ASSERT_EQUAL( wxT("abcABCdefDEFWW"), s4 ); +#if wxUSE_UNICODE wxString s = wxString::FromUTF8("\xd0\x9f\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82"); s.resize(3); CPPUNIT_ASSERT_EQUAL( wxString::FromUTF8("\xd0\x9f\xd1\x80\xd0\xb8"), s); +#endif // wxUSE_UNICODE } void StdStringTestCase::StdRiter() @@ -559,15 +587,22 @@ void StdStringTestCase::StdConversion() wxString s4("hello"); - // wxString -> std::string conversion is only available in wxUSE_STL case, - // because it conflicts with conversion to const char*/wchar_t*: + // notice that implicit wxString -> std::string conversion is only + // available in wxUSE_STL case, because it conflicts with conversion to + // const char*/wchar_t* #if wxUSE_STL std::string s5 = s4; +#else + std::string s5 = s4.ToStdString(); +#endif CPPUNIT_ASSERT_EQUAL( "hello", s5 ); +#if wxUSE_STL wxStdWideString s6 = s4; - CPPUNIT_ASSERT_EQUAL( "hello", s6 ); +#else + wxStdWideString s6 = s4.ToStdWstring(); #endif + CPPUNIT_ASSERT_EQUAL( "hello", s6 ); std::string s7(s4); CPPUNIT_ASSERT( s7 == "hello" );