]> git.saurik.com Git - wxWidgets.git/blob - tests/fileconf/fileconf.cpp
Clean up the soversion/flavour labelling of binary runtime packages.
[wxWidgets.git] / tests / fileconf / fileconf.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/fileconf/fileconf.cpp
3 // Purpose: wxFileConf unit test
4 // Author: Vadim Zeitlin
5 // Created: 2004-09-19
6 // RCS-ID: $Id$
7 // Copyright: (c) 2004 Vadim Zeitlin
8 ///////////////////////////////////////////////////////////////////////////////
9
10 // ----------------------------------------------------------------------------
11 // headers
12 // ----------------------------------------------------------------------------
13
14 #include "wx/wxprec.h"
15
16 #ifdef __BORLANDC__
17 #pragma hdrstop
18 #endif
19
20 #if wxUSE_FILECONFIG
21
22 #ifndef WX_PRECOMP
23 #endif // WX_PRECOMP
24
25 #include "wx/fileconf.h"
26 #include "wx/sstream.h"
27
28 #include "wx/cppunit.h"
29
30 static const wxChar *testconfig =
31 _T("[root]\n")
32 _T("entry=value\n")
33 _T("[root/group1]\n")
34 _T("[root/group1/subgroup]\n")
35 _T("subentry=subvalue\n")
36 _T("[root/group2]\n")
37 ;
38
39 // ----------------------------------------------------------------------------
40 // test class
41 // ----------------------------------------------------------------------------
42
43 class FileConfigTestCase : public CppUnit::TestCase
44 {
45 public:
46 FileConfigTestCase() { }
47
48 private:
49 CPPUNIT_TEST_SUITE( FileConfigTestCase );
50 CPPUNIT_TEST( HasGroup );
51 CPPUNIT_TEST_SUITE_END();
52
53 void HasGroup();
54
55 DECLARE_NO_COPY_CLASS(FileConfigTestCase)
56 };
57
58 // register in the unnamed registry so that these tests are run by default
59 CPPUNIT_TEST_SUITE_REGISTRATION( FileConfigTestCase );
60
61 // also include in it's own registry so that these tests can be run alone
62 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( FileConfigTestCase, "FileConfigTestCase" );
63
64 void FileConfigTestCase::HasGroup()
65 {
66 wxStringInputStream sis(testconfig);
67 wxFileConfig fc(sis);
68
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")) );
77 }
78
79 #endif // wxUSE_FILECONFIG
80