]>
git.saurik.com Git - wxWidgets.git/blob - tests/misc/environ.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/misc/environ.cpp
3 // Purpose: Test wxGet/SetEnv
4 // Author: Francesco Montorsi (extracted from console sample)
6 // Copyright: (c) 2010 wxWidgets team
7 ///////////////////////////////////////////////////////////////////////////////
9 // ----------------------------------------------------------------------------
11 // ----------------------------------------------------------------------------
21 // ----------------------------------------------------------------------------
23 // ----------------------------------------------------------------------------
25 class EnvTestCase
: public CppUnit::TestCase
31 CPPUNIT_TEST_SUITE( EnvTestCase
);
32 CPPUNIT_TEST( GetSet
);
34 CPPUNIT_TEST_SUITE_END();
39 DECLARE_NO_COPY_CLASS(EnvTestCase
)
42 // register in the unnamed registry so that these tests are run by default
43 CPPUNIT_TEST_SUITE_REGISTRATION( EnvTestCase
);
45 // also include in its own registry so that these tests can be run alone
46 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( EnvTestCase
, "EnvTestCase" );
48 void EnvTestCase::GetSet()
50 const wxChar
*var
= wxT("wxTestVar");
53 CPPUNIT_ASSERT(!wxGetEnv(var
, &contents
));
54 CPPUNIT_ASSERT(contents
.empty());
56 wxSetEnv(var
, wxT("value for wxTestVar"));
57 CPPUNIT_ASSERT(wxGetEnv(var
, &contents
));
58 CPPUNIT_ASSERT(contents
== wxT("value for wxTestVar"));
60 wxSetEnv(var
, wxT("another value"));
61 CPPUNIT_ASSERT(wxGetEnv(var
, &contents
));
62 CPPUNIT_ASSERT(contents
== wxT("another value"));
65 CPPUNIT_ASSERT(!wxGetEnv(var
, &contents
));
68 void EnvTestCase::Path()
72 CPPUNIT_ASSERT(wxGetEnv(wxT("PATH"), &contents
));
73 CPPUNIT_ASSERT(!contents
.empty());