void CrtTestCase::SetGetEnv()
{
+#define TESTVAR_NAME _T("WXTESTVAR")
+
wxString val;
- 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, _T("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"));
+ 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
}
void CrtTestCase::Strcmp()
CPPUNIT_ASSERT_EQUAL( ',', *wxStrpbrk(strWX.c_str(), s.mb_str()) );
CPPUNIT_ASSERT_EQUAL( L',', *wxStrpbrk(strWX.c_str(), s.wc_str()) );
- CPPUNIT_ASSERT_EQUAL( (char *)NULL, wxStrpbrk(strWX, "xyz") );
- CPPUNIT_ASSERT_EQUAL( (wchar_t *)NULL, wxStrpbrk(strWX.c_str(), L"xyz") );
+ CPPUNIT_ASSERT( !wxStrpbrk(strWX, "xyz") );
+ CPPUNIT_ASSERT( !wxStrpbrk(strWX.c_str(), L"xyz") );
}
void CrtTestCase::Strnlen()
{
- // the following calls should not segfault/crash because when passing 0
- // as maxlen, no bytes at all should be read from the given buffer
- // (which is NULL in this case!)
- CPPUNIT_ASSERT_EQUAL( (size_t)0, wxStrnlen((const char*)NULL, 0) );
- CPPUNIT_ASSERT_EQUAL( (size_t)0, wxStrnlen((const wchar_t*)NULL, 0) );
-
// other misc tests for wxStrnlen(const char*, size_t)
CPPUNIT_ASSERT_EQUAL( (size_t)0, wxStrnlen("", 0) );