]> git.saurik.com Git - wxWidgets.git/blob - tests/strings/crt.cpp
use wx.ART_NEW
[wxWidgets.git] / tests / strings / crt.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/strings/crt.cpp
3 // Purpose: Test for wx C runtime functions wrappers
4 // Author: Vaclav Slavik
5 // Created: 2004-06-03
6 // RCS-ID: $Id$
7 // Copyright: (c) 2004 Vaclav Slavik
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10
11 // ----------------------------------------------------------------------------
12 // headers
13 // ----------------------------------------------------------------------------
14
15 #include "testprec.h"
16
17 #ifdef __BORLANDC__
18 #pragma hdrstop
19 #endif
20
21 #ifndef WX_PRECOMP
22 #include "wx/wx.h"
23 #endif // WX_PRECOMP
24
25 #include "wx/textfile.h"
26
27 // ----------------------------------------------------------------------------
28 // test class
29 // ----------------------------------------------------------------------------
30
31 class CrtTestCase : public CppUnit::TestCase
32 {
33 public:
34 CrtTestCase() {}
35
36 private:
37 CPPUNIT_TEST_SUITE( CrtTestCase );
38 CPPUNIT_TEST( SetGetEnv );
39 CPPUNIT_TEST_SUITE_END();
40
41 void SetGetEnv();
42
43 DECLARE_NO_COPY_CLASS(CrtTestCase)
44 };
45
46 // register in the unnamed registry so that these tests are run by default
47 CPPUNIT_TEST_SUITE_REGISTRATION( CrtTestCase );
48
49 // also include in it's own registry so that these tests can be run alone
50 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( CrtTestCase, "CrtTestCase" );
51
52 void CrtTestCase::SetGetEnv()
53 {
54 wxString val;
55 wxSetEnv(_T("TESTVAR"), _T("value"));
56 CPPUNIT_ASSERT( wxGetEnv(_T("TESTVAR"), &val) == true );
57 CPPUNIT_ASSERT( val == _T("value") );
58 wxSetEnv(_T("TESTVAR"), _T("something else"));
59 CPPUNIT_ASSERT( wxGetEnv(_T("TESTVAR"), &val) );
60 CPPUNIT_ASSERT( val == _T("something else") );
61 CPPUNIT_ASSERT( wxUnsetEnv(_T("TESTVAR")) );
62 CPPUNIT_ASSERT( wxGetEnv(_T("TESTVAR"), NULL) == false );
63 }