]> git.saurik.com Git - wxWidgets.git/blame - tests/config/regconf.cpp
Ignore empty LC_XXX variables in locale detection code.
[wxWidgets.git] / tests / config / regconf.cpp
CommitLineData
7b8ccf33
FM
1///////////////////////////////////////////////////////////////////////////////
2// Name: tests/config/regconf.cpp
3// Purpose: wxRegConfig unit test
4// Author: Francesco Montorsi (extracted from console sample)
5// Created: 2010-06-02
6// RCS-ID: $Id$
7// Copyright: (c) 2010 wxWidgets team
8///////////////////////////////////////////////////////////////////////////////
9
10// ----------------------------------------------------------------------------
11// headers
12// ----------------------------------------------------------------------------
13
14#include "testprec.h"
15
16#ifdef __BORLANDC__
17 #pragma hdrstop
18#endif
19
20#if wxUSE_CONFIG && wxUSE_REGKEY
21
22#ifndef WX_PRECOMP
23#endif // WX_PRECOMP
24
25#include "wx/msw/regconf.h"
26
27// ----------------------------------------------------------------------------
28// test class
29// ----------------------------------------------------------------------------
30
31class RegConfigTestCase : public CppUnit::TestCase
32{
33public:
34 RegConfigTestCase() { }
35
36private:
37 CPPUNIT_TEST_SUITE( RegConfigTestCase );
38 CPPUNIT_TEST( ReadWrite );
39 CPPUNIT_TEST_SUITE_END();
40
41 void ReadWrite();
42
43 DECLARE_NO_COPY_CLASS(RegConfigTestCase)
44};
45
46// register in the unnamed registry so that these tests are run by default
47CPPUNIT_TEST_SUITE_REGISTRATION( RegConfigTestCase );
48
e3778b4d 49// also include in its own registry so that these tests can be run alone
7b8ccf33
FM
50CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( RegConfigTestCase, "RegConfigTestCase" );
51
52void RegConfigTestCase::ReadWrite()
53{
54 wxString app = wxT("wxRegConfigTestCase");
55 wxString vendor = wxT("wxWidgets");
56
57 // NOTE: we use wxCONFIG_USE_LOCAL_FILE explicitly to test wxRegConfig
58 // with something different from the default value wxCONFIG_USE_GLOBAL_FILE
59 wxConfigBase *config = new wxRegConfig(app, vendor, wxT(""), wxT(""),
60 wxCONFIG_USE_LOCAL_FILE);
61
62 // test writing
63 config->SetPath(wxT("/group1"));
64 CPPUNIT_ASSERT( config->Write(wxT("entry1"), wxT("foo")) );
65 config->SetPath(wxT("/group2"));
66 CPPUNIT_ASSERT( config->Write(wxT("entry1"), wxT("bar")) );
67
68 // test reading
69 wxString str;
70 long dummy;
71
72 config->SetPath(wxT("/"));
73 CPPUNIT_ASSERT( config->GetFirstGroup(str, dummy) );
74 CPPUNIT_ASSERT( str == "group1" );
75 CPPUNIT_ASSERT( config->Read(wxT("group1/entry1"), wxT("INVALID DEFAULT")) == "foo" );
76 CPPUNIT_ASSERT( config->GetNextGroup(str, dummy) );
77 CPPUNIT_ASSERT( str == "group2" );
78 CPPUNIT_ASSERT( config->Read(wxT("group2/entry1"), wxT("INVALID DEFAULT")) == "bar" );
79
80 config->DeleteAll();
81 delete config;
82}
83
84#endif // wxUSE_CONFIG && wxUSE_REGKEY
85