]>
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)
7 // Copyright: (c) 2010 wxWidgets team
8 ///////////////////////////////////////////////////////////////////////////////
10 // ----------------------------------------------------------------------------
12 // ----------------------------------------------------------------------------
22 // ----------------------------------------------------------------------------
24 // ----------------------------------------------------------------------------
26 class EnvTestCase
: public CppUnit::TestCase
32 CPPUNIT_TEST_SUITE( EnvTestCase
);
33 CPPUNIT_TEST( GetSet
);
35 CPPUNIT_TEST_SUITE_END();
40 DECLARE_NO_COPY_CLASS(EnvTestCase
)
43 // register in the unnamed registry so that these tests are run by default
44 CPPUNIT_TEST_SUITE_REGISTRATION( EnvTestCase
);
46 // also include in it's own registry so that these tests can be run alone
47 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( EnvTestCase
, "EnvTestCase" );
49 void EnvTestCase::GetSet()
51 const wxChar
*var
= wxT("wxTestVar");
54 CPPUNIT_ASSERT(!wxGetEnv(var
, &contents
));
55 CPPUNIT_ASSERT(contents
.empty());
57 wxSetEnv(var
, wxT("value for wxTestVar"));
58 CPPUNIT_ASSERT(wxGetEnv(var
, &contents
));
59 CPPUNIT_ASSERT(contents
== wxT("value for wxTestVar"));
61 wxSetEnv(var
, wxT("another value"));
62 CPPUNIT_ASSERT(wxGetEnv(var
, &contents
));
63 CPPUNIT_ASSERT(contents
== wxT("another value"));
66 CPPUNIT_ASSERT(!wxGetEnv(var
, &contents
));
69 void EnvTestCase::Path()
73 CPPUNIT_ASSERT(wxGetEnv(wxT("PATH"), &contents
));
74 CPPUNIT_ASSERT(!contents
.empty());