X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/787de19a134a346130706556c964db5ee34f5a1d..f6b4a1b98d5a22a88a5a9a28076079116a2f892e:/tests/strings/crt.cpp diff --git a/tests/strings/crt.cpp b/tests/strings/crt.cpp index e4e69caa16..e0623f6ac5 100644 --- a/tests/strings/crt.cpp +++ b/tests/strings/crt.cpp @@ -44,6 +44,7 @@ public: private: CPPUNIT_TEST_SUITE( CrtTestCase ); CPPUNIT_TEST( SetGetEnv ); + CPPUNIT_TEST( Strchr ); CPPUNIT_TEST( Strcmp ); CPPUNIT_TEST( Strspn ); CPPUNIT_TEST( Strcspn ); @@ -52,6 +53,7 @@ private: CPPUNIT_TEST_SUITE_END(); void SetGetEnv(); + void Strchr(); void Strcmp(); void Strspn(); void Strcspn(); @@ -69,15 +71,15 @@ CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( CrtTestCase, "CrtTestCase" ); void CrtTestCase::SetGetEnv() { -#define TESTVAR_NAME _T("WXTESTVAR") +#define TESTVAR_NAME wxT("WXTESTVAR") wxString val; - wxSetEnv(TESTVAR_NAME, _T("value")); + wxSetEnv(TESTVAR_NAME, wxT("value")); CPPUNIT_ASSERT( wxGetEnv(TESTVAR_NAME, &val) ); CPPUNIT_ASSERT_EQUAL( "value", val ); CPPUNIT_ASSERT_EQUAL( "value", wxString(wxGetenv(TESTVAR_NAME)) ); - wxSetEnv(TESTVAR_NAME, _T("something else")); + wxSetEnv(TESTVAR_NAME, wxT("something else")); CPPUNIT_ASSERT( wxGetEnv(TESTVAR_NAME, &val) ); CPPUNIT_ASSERT_EQUAL( "something else", val ); CPPUNIT_ASSERT_EQUAL( "something else", wxString(wxGetenv(TESTVAR_NAME)) ); @@ -89,6 +91,19 @@ void CrtTestCase::SetGetEnv() #undef TESTVAR_NAME } +void CrtTestCase::Strchr() +{ + // test that searching for a wide character in a narrow string simply + // doesn't find it but doesn't fail with an assert (#11487) + const wxUniChar smiley = *wxString::FromUTF8("\xe2\x98\xba").begin(); + + CPPUNIT_ASSERT( !wxStrchr("hello", smiley) ); + + // but searching for an explicitly wide character does find it + CPPUNIT_ASSERT( wxStrchr(wxString::FromUTF8(":-) == \xe2\x98\xba"), + static_cast(smiley)) ); +} + void CrtTestCase::Strcmp() { // this code tests if all possible ways of calling wxStrcmp() compile: