]>
git.saurik.com Git - wxWidgets.git/blob - tests/fileconf/fileconf.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/fileconf/fileconf.cpp
3 // Purpose: wxFileConf unit test
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2004 Vadim Zeitlin
8 ///////////////////////////////////////////////////////////////////////////////
10 // ----------------------------------------------------------------------------
12 // ----------------------------------------------------------------------------
14 #include "wx/wxprec.h"
25 #include "wx/fileconf.h"
26 #include "wx/sstream.h"
28 #include "wx/cppunit.h"
30 static const wxChar
*testconfig
=
34 _T("[root/group1/subgroup]\n")
35 _T("subentry=subvalue\n")
39 // ----------------------------------------------------------------------------
41 // ----------------------------------------------------------------------------
43 class FileConfigTestCase
: public CppUnit::TestCase
46 FileConfigTestCase() { }
49 CPPUNIT_TEST_SUITE( FileConfigTestCase
);
50 CPPUNIT_TEST( HasGroup
);
51 CPPUNIT_TEST_SUITE_END();
55 DECLARE_NO_COPY_CLASS(FileConfigTestCase
)
58 // register in the unnamed registry so that these tests are run by default
59 CPPUNIT_TEST_SUITE_REGISTRATION( FileConfigTestCase
);
61 // also include in it's own registry so that these tests can be run alone
62 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( FileConfigTestCase
, "FileConfigTestCase" );
64 void FileConfigTestCase::HasGroup()
66 wxStringInputStream
sis(testconfig
);
69 CPPUNIT_ASSERT( fc
.HasGroup(_T("root")) );
70 CPPUNIT_ASSERT( fc
.HasGroup(_T("root/group1")) );
71 CPPUNIT_ASSERT( fc
.HasGroup(_T("root/group1/subgroup")) );
72 CPPUNIT_ASSERT( fc
.HasGroup(_T("root/group2")) );
73 CPPUNIT_ASSERT( !fc
.HasGroup(_T("foot")) );
74 CPPUNIT_ASSERT( !fc
.HasGroup(_T("")) );
75 CPPUNIT_ASSERT( !fc
.HasGroup(_T("root/group")) );
76 CPPUNIT_ASSERT( !fc
.HasGroup(_T("root//subgroup")) );
79 #endif // wxUSE_FILECONFIG