- wxSetEnv(_T("TESTVAR"), _T("value"));
- CPPUNIT_ASSERT( wxGetEnv(_T("TESTVAR"), &val) == true );
- CPPUNIT_ASSERT( val == _T("value") );
- wxSetEnv(_T("TESTVAR"), _T("something else"));
- CPPUNIT_ASSERT( wxGetEnv(_T("TESTVAR"), &val) );
- CPPUNIT_ASSERT( val == _T("something else") );
- CPPUNIT_ASSERT( wxUnsetEnv(_T("TESTVAR")) );
- CPPUNIT_ASSERT( wxGetEnv(_T("TESTVAR"), NULL) == false );
+ 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, wxT("something else"));
+ CPPUNIT_ASSERT( wxGetEnv(TESTVAR_NAME, &val) );
+ CPPUNIT_ASSERT_EQUAL( "something else", val );
+ CPPUNIT_ASSERT_EQUAL( "something else", wxString(wxGetenv(TESTVAR_NAME)) );
+
+ CPPUNIT_ASSERT( wxUnsetEnv(TESTVAR_NAME) );
+ CPPUNIT_ASSERT( !wxGetEnv(TESTVAR_NAME, NULL) );
+ CPPUNIT_ASSERT( !wxGetenv(TESTVAR_NAME) );
+
+#undef TESTVAR_NAME
+}
+
+#if wxUSE_UNICODE
+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<wchar_t>(smiley)) );