Remove wxT() from wxConfig unit tests

Just remove the visual noise, no real changes.
This commit is contained in:
Vadim Zeitlin
2021-03-09 17:02:12 +01:00
parent 2e6bb341b7
commit 62cfa638c0
3 changed files with 244 additions and 244 deletions

View File

@@ -34,72 +34,72 @@
TEST_CASE("wxConfig::ReadWriteLocal", "[config]") TEST_CASE("wxConfig::ReadWriteLocal", "[config]")
{ {
wxString app = wxT("wxConfigTestCase"); wxString app = "wxConfigTestCase";
wxString vendor = wxT("wxWidgets"); wxString vendor = "wxWidgets";
wxScopedPtr<wxConfig> config(new wxConfig(app, vendor, wxT(""), wxT(""), wxScopedPtr<wxConfig> config(new wxConfig(app, vendor, "", "",
wxCONFIG_USE_LOCAL_FILE)); wxCONFIG_USE_LOCAL_FILE));
config->DeleteAll(); config->DeleteAll();
config->Write(wxT("string1"), wxT("abc")); config->Write("string1", "abc");
config->Write(wxT("string2"), wxString(wxT("def"))); config->Write("string2", wxString("def"));
config->Write(wxT("int1"), 123); config->Write("int1", 123);
config->Write(wxString(wxT("long1")), 234L); config->Write(wxString("long1"), 234L);
config->Write(wxT("double1"), 345.67); config->Write("double1", 345.67);
config->Write(wxT("bool1"), true); config->Write("bool1", true);
#ifdef wxHAS_CONFIG_TEMPLATE_RW #ifdef wxHAS_CONFIG_TEMPLATE_RW
config->Write(wxT("color1"), wxColour(11,22,33,44)); config->Write("color1", wxColour(11,22,33,44));
#endif // wxHAS_CONFIG_TEMPLATE_RW #endif // wxHAS_CONFIG_TEMPLATE_RW
config->Flush(); config->Flush();
config.reset(new wxConfig(app, vendor, wxT(""), wxT(""), config.reset(new wxConfig(app, vendor, "", "",
wxCONFIG_USE_LOCAL_FILE)); wxCONFIG_USE_LOCAL_FILE));
wxString string1 = config->Read(wxT("string1")); wxString string1 = config->Read("string1");
CHECK( string1 == "abc" ); CHECK( string1 == "abc" );
string1 = config->Read(wxT("string1"), wxT("defaultvalue")); string1 = config->Read("string1", "defaultvalue");
CHECK( string1 == "abc" ); CHECK( string1 == "abc" );
wxString string2; wxString string2;
bool r = config->Read(wxT("string2"), &string2); bool r = config->Read("string2", &string2);
CHECK( r ); CHECK( r );
CHECK( string2 == "def" ); CHECK( string2 == "def" );
r = config->Read(wxT("string2"), &string2, wxT("defaultvalue")); r = config->Read("string2", &string2, "defaultvalue");
CHECK( r ); CHECK( r );
CHECK( string2 == "def" ); CHECK( string2 == "def" );
int int1 = config->Read(wxT("int1"), 5); int int1 = config->Read("int1", 5);
CHECK( int1 == 123 ); CHECK( int1 == 123 );
long long1; long long1;
r = config->Read(wxT("long1"), &long1); r = config->Read("long1", &long1);
CHECK( r ); CHECK( r );
CHECK( long1 == 234L ); CHECK( long1 == 234L );
CHECK( config->ReadLong(wxT("long1"), 0) == 234 ); CHECK( config->ReadLong("long1", 0) == 234 );
double double1; double double1;
r = config->Read(wxT("double1"), &double1); r = config->Read("double1", &double1);
CHECK( r ); CHECK( r );
CHECK( double1 == 345.67 ); CHECK( double1 == 345.67 );
CHECK( config->ReadDouble(wxT("double1"), 0) == double1 ); CHECK( config->ReadDouble("double1", 0) == double1 );
bool bool1; bool bool1;
r = config->Read(wxT("foo"), &bool1); // there is no "foo" key r = config->Read("foo", &bool1); // there is no "foo" key
CHECK( !r ); CHECK( !r );
r = config->Read(wxT("bool1"), &bool1); r = config->Read("bool1", &bool1);
CHECK( r ); CHECK( r );
CHECK( bool1 == true ); CHECK( bool1 == true );
CHECK( config->ReadBool(wxT("bool1"), false) == bool1 ); CHECK( config->ReadBool("bool1", false) == bool1 );
#ifdef wxHAS_CONFIG_TEMPLATE_RW #ifdef wxHAS_CONFIG_TEMPLATE_RW
wxColour color1; wxColour color1;
r = config->Read(wxT("color1"), &color1); r = config->Read("color1", &color1);
CHECK( r ); CHECK( r );
CHECK( color1 == wxColour(11,22,33,44) ); CHECK( color1 == wxColour(11,22,33,44) );
CHECK( config->ReadObject(wxT("color1"), wxNullColour) == color1 ); CHECK( config->ReadObject("color1", wxNullColour) == color1 );
#endif // wxHAS_CONFIG_TEMPLATE_RW #endif // wxHAS_CONFIG_TEMPLATE_RW
config->DeleteAll(); config->DeleteAll();
@@ -112,49 +112,49 @@ size_t ReadValues(const wxConfig& config, bool has_values)
size_t read = 0; size_t read = 0;
bool r; bool r;
wxString string1 = config.Read(wxT("string1"), wxT("abc")); wxString string1 = config.Read("string1", "abc");
read++; read++;
wxString string2 = config.Read(wxT("string2"), wxString(wxT("def"))); wxString string2 = config.Read("string2", wxString("def"));
read++; read++;
wxString string3; wxString string3;
r = config.Read(wxT("string3"), &string3, wxT("abc")); r = config.Read("string3", &string3, "abc");
CHECK( r == has_values ); CHECK( r == has_values );
read++; read++;
wxString string4; wxString string4;
r = config.Read(wxT("string4"), &string4, wxString(wxT("def"))); r = config.Read("string4", &string4, wxString("def"));
CHECK( r == has_values ); CHECK( r == has_values );
read++; read++;
int int1; int int1;
r = config.Read(wxT("int1"), &int1, 123); r = config.Read("int1", &int1, 123);
CHECK( r == has_values ); CHECK( r == has_values );
read++; read++;
int int2 = config.Read(wxT("int2"), 1234); int int2 = config.Read("int2", 1234);
CHECK( 1234 == int2 ); CHECK( 1234 == int2 );
read++; read++;
long long1; long long1;
r = config.Read(wxString(wxT("long1")), &long1, 234L); r = config.Read(wxString("long1"), &long1, 234L);
CHECK( r == has_values ); CHECK( r == has_values );
read++; read++;
double double1; double double1;
r = config.Read(wxT("double1"), &double1, 345.67); r = config.Read("double1", &double1, 345.67);
CHECK( r == has_values ); CHECK( r == has_values );
read++; read++;
bool bool1; bool bool1;
r = config.Read(wxT("bool1"), &bool1, true); r = config.Read("bool1", &bool1, true);
CHECK( r == has_values ); CHECK( r == has_values );
read++; read++;
#ifdef wxHAS_CONFIG_TEMPLATE_RW #ifdef wxHAS_CONFIG_TEMPLATE_RW
wxColour color1; wxColour color1;
r = config.Read(wxT("color1"), &color1, wxColour(11,22,33,44)); r = config.Read("color1", &color1, wxColour(11,22,33,44));
CHECK( r == has_values ); CHECK( r == has_values );
read++; read++;
#endif // wxHAS_CONFIG_TEMPLATE_RW #endif // wxHAS_CONFIG_TEMPLATE_RW
@@ -165,9 +165,9 @@ size_t ReadValues(const wxConfig& config, bool has_values)
TEST_CASE("wxConfig::RecordingDefaults", "[config]") TEST_CASE("wxConfig::RecordingDefaults", "[config]")
{ {
wxString app = wxT("wxConfigTestCaseRD"); wxString app = "wxConfigTestCaseRD";
wxString vendor = wxT("wxWidgets"); wxString vendor = "wxWidgets";
wxScopedPtr<wxConfig> config(new wxConfig(app, vendor, wxT(""), wxT(""), wxScopedPtr<wxConfig> config(new wxConfig(app, vendor, "", "",
wxCONFIG_USE_LOCAL_FILE)); wxCONFIG_USE_LOCAL_FILE));
config->DeleteAll(); config->DeleteAll();
config->SetRecordDefaults(false); // by default it is false config->SetRecordDefaults(false); // by default it is false

View File

@@ -22,14 +22,14 @@
#include "wx/sstream.h" #include "wx/sstream.h"
#include "wx/log.h" #include "wx/log.h"
static const wxChar *testconfig = static const char *testconfig =
wxT("[root]\n") "[root]\n"
wxT("entry=value\n") "entry=value\n"
wxT("[root/group1]\n") "[root/group1]\n"
wxT("[root/group1/subgroup]\n") "[root/group1/subgroup]\n"
wxT("subentry=subvalue\n") "subentry=subvalue\n"
wxT("subentry2=subvalue2\n") "subentry2=subvalue2\n"
wxT("[root/group2]\n") "[root/group2]\n"
; ;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -46,7 +46,7 @@ static wxString Dump(wxFileConfig& fc)
// helper macro to test wxFileConfig contents // helper macro to test wxFileConfig contents
#define wxVERIFY_FILECONFIG(t, fc) CHECK(Dump(fc) == t) #define wxVERIFY_FILECONFIG(t, fc) CHECK(Dump(fc) == t)
static wxString ChangePath(wxFileConfig& fc, const wxChar *path) static wxString ChangePath(wxFileConfig& fc, const char *path)
{ {
fc.SetPath(path); fc.SetPath(path);
@@ -62,34 +62,34 @@ TEST_CASE("wxFileConfig::Path", "[fileconfig][config]")
wxStringInputStream sis(testconfig); wxStringInputStream sis(testconfig);
wxFileConfig fc(sis); wxFileConfig fc(sis);
CHECK( ChangePath(fc, wxT("")) == wxT("") ); CHECK( ChangePath(fc, "") == "" );
CHECK( ChangePath(fc, wxT("/")) == wxT("") ); CHECK( ChangePath(fc, "/") == "" );
CHECK( ChangePath(fc, wxT("root")) == wxT("/root") ); CHECK( ChangePath(fc, "root") == "/root" );
CHECK( ChangePath(fc, wxT("/root")) == wxT("/root") ); CHECK( ChangePath(fc, "/root") == "/root" );
CHECK( ChangePath(fc, wxT("/root/group1/subgroup")) == wxT("/root/group1/subgroup") ); CHECK( ChangePath(fc, "/root/group1/subgroup") == "/root/group1/subgroup" );
CHECK( ChangePath(fc, wxT("/root/group2")) == wxT("/root/group2") ); CHECK( ChangePath(fc, "/root/group2") == "/root/group2" );
} }
TEST_CASE("wxFileConfig::AddEntries", "[fileconfig][config]") TEST_CASE("wxFileConfig::AddEntries", "[fileconfig][config]")
{ {
wxFileConfig fc; wxFileConfig fc;
wxVERIFY_FILECONFIG( wxT(""), fc ); wxVERIFY_FILECONFIG( "", fc );
fc.Write(wxT("/Foo"), wxT("foo")); fc.Write("/Foo", "foo");
wxVERIFY_FILECONFIG( wxT("Foo=foo\n"), fc ); wxVERIFY_FILECONFIG( "Foo=foo\n", fc );
fc.Write(wxT("/Bar/Baz"), wxT("baz")); fc.Write("/Bar/Baz", "baz");
wxVERIFY_FILECONFIG( wxT("Foo=foo\n[Bar]\nBaz=baz\n"), fc ); wxVERIFY_FILECONFIG( "Foo=foo\n[Bar]\nBaz=baz\n", fc );
fc.DeleteAll(); fc.DeleteAll();
wxVERIFY_FILECONFIG( wxT(""), fc ); wxVERIFY_FILECONFIG( "", fc );
fc.Write(wxT("/Bar/Baz"), wxT("baz")); fc.Write("/Bar/Baz", "baz");
wxVERIFY_FILECONFIG( wxT("[Bar]\nBaz=baz\n"), fc ); wxVERIFY_FILECONFIG( "[Bar]\nBaz=baz\n", fc );
fc.Write(wxT("/Foo"), wxT("foo")); fc.Write("/Foo", "foo");
wxVERIFY_FILECONFIG( wxT("Foo=foo\n[Bar]\nBaz=baz\n"), fc ); wxVERIFY_FILECONFIG( "Foo=foo\n[Bar]\nBaz=baz\n", fc );
} }
namespace namespace
@@ -97,11 +97,11 @@ namespace
void void
CheckGroupEntries(const wxFileConfig& fc, CheckGroupEntries(const wxFileConfig& fc,
const wxChar *path, const char *path,
size_t nEntries, size_t nEntries,
...) ...)
{ {
wxConfigPathChanger change(&fc, wxString(path) + wxT("/")); wxConfigPathChanger change(&fc, wxString(path) + "/");
CHECK( fc.GetNumberOfEntries() == nEntries ); CHECK( fc.GetNumberOfEntries() == nEntries );
@@ -114,7 +114,7 @@ CheckGroupEntries(const wxFileConfig& fc,
cont; cont;
cont = fc.GetNextEntry(name, cookie), nEntries-- ) cont = fc.GetNextEntry(name, cookie), nEntries-- )
{ {
CHECK( name == va_arg(ap, wxChar *) ); CHECK( name == va_arg(ap, char *) );
} }
CHECK( nEntries == 0 ); CHECK( nEntries == 0 );
@@ -124,11 +124,11 @@ CheckGroupEntries(const wxFileConfig& fc,
void void
CheckGroupSubgroups(const wxFileConfig& fc, CheckGroupSubgroups(const wxFileConfig& fc,
const wxChar *path, const char *path,
size_t nGroups, size_t nGroups,
...) ...)
{ {
wxConfigPathChanger change(&fc, wxString(path) + wxT("/")); wxConfigPathChanger change(&fc, wxString(path) + "/");
CHECK( fc.GetNumberOfGroups() == nGroups ); CHECK( fc.GetNumberOfGroups() == nGroups );
@@ -141,7 +141,7 @@ CheckGroupSubgroups(const wxFileConfig& fc,
cont; cont;
cont = fc.GetNextGroup(name, cookie), nGroups-- ) cont = fc.GetNextGroup(name, cookie), nGroups-- )
{ {
CHECK( name == va_arg(ap, wxChar *) ); CHECK( name == va_arg(ap, char *) );
} }
CHECK( nGroups == 0 ); CHECK( nGroups == 0 );
@@ -156,11 +156,11 @@ TEST_CASE("wxFileConfig::GetEntries", "[fileconfig][config]")
wxStringInputStream sis(testconfig); wxStringInputStream sis(testconfig);
wxFileConfig fc(sis); wxFileConfig fc(sis);
CheckGroupEntries(fc, wxT(""), 0); CheckGroupEntries(fc, "", 0);
CheckGroupEntries(fc, wxT("/root"), 1, wxT("entry")); CheckGroupEntries(fc, "/root", 1, "entry");
CheckGroupEntries(fc, wxT("/root/group1"), 0); CheckGroupEntries(fc, "/root/group1", 0);
CheckGroupEntries(fc, wxT("/root/group1/subgroup"), CheckGroupEntries(fc, "/root/group1/subgroup",
2, wxT("subentry"), wxT("subentry2")); 2, "subentry", "subentry2");
} }
TEST_CASE("wxFileConfig::GetGroups", "[fileconfig][config]") TEST_CASE("wxFileConfig::GetGroups", "[fileconfig][config]")
@@ -168,10 +168,10 @@ TEST_CASE("wxFileConfig::GetGroups", "[fileconfig][config]")
wxStringInputStream sis(testconfig); wxStringInputStream sis(testconfig);
wxFileConfig fc(sis); wxFileConfig fc(sis);
CheckGroupSubgroups(fc, wxT(""), 1, wxT("root")); CheckGroupSubgroups(fc, "", 1, "root");
CheckGroupSubgroups(fc, wxT("/root"), 2, wxT("group1"), wxT("group2")); CheckGroupSubgroups(fc, "/root", 2, "group1", "group2");
CheckGroupSubgroups(fc, wxT("/root/group1"), 1, wxT("subgroup")); CheckGroupSubgroups(fc, "/root/group1", 1, "subgroup");
CheckGroupSubgroups(fc, wxT("/root/group2"), 0); CheckGroupSubgroups(fc, "/root/group2", 0);
} }
TEST_CASE("wxFileConfig::HasEntry", "[fileconfig][config]") TEST_CASE("wxFileConfig::HasEntry", "[fileconfig][config]")
@@ -179,15 +179,15 @@ TEST_CASE("wxFileConfig::HasEntry", "[fileconfig][config]")
wxStringInputStream sis(testconfig); wxStringInputStream sis(testconfig);
wxFileConfig fc(sis); wxFileConfig fc(sis);
CHECK( !fc.HasEntry(wxT("root")) ); CHECK( !fc.HasEntry("root") );
CHECK( fc.HasEntry(wxT("root/entry")) ); CHECK( fc.HasEntry("root/entry") );
CHECK( fc.HasEntry(wxT("/root/entry")) ); CHECK( fc.HasEntry("/root/entry") );
CHECK( fc.HasEntry(wxT("root/group1/subgroup/subentry")) ); CHECK( fc.HasEntry("root/group1/subgroup/subentry") );
CHECK( !fc.HasEntry(wxT("")) ); CHECK( !fc.HasEntry("") );
CHECK( !fc.HasEntry(wxT("root/group1")) ); CHECK( !fc.HasEntry("root/group1") );
CHECK( !fc.HasEntry(wxT("subgroup/subentry")) ); CHECK( !fc.HasEntry("subgroup/subentry") );
CHECK( !fc.HasEntry(wxT("/root/no_such_group/entry")) ); CHECK( !fc.HasEntry("/root/no_such_group/entry") );
CHECK( !fc.HasGroup(wxT("/root/no_such_group")) ); CHECK( !fc.HasGroup("/root/no_such_group") );
} }
TEST_CASE("wxFileConfig::HasGroup", "[fileconfig][config]") TEST_CASE("wxFileConfig::HasGroup", "[fileconfig][config]")
@@ -195,15 +195,15 @@ TEST_CASE("wxFileConfig::HasGroup", "[fileconfig][config]")
wxStringInputStream sis(testconfig); wxStringInputStream sis(testconfig);
wxFileConfig fc(sis); wxFileConfig fc(sis);
CHECK( fc.HasGroup(wxT("root")) ); CHECK( fc.HasGroup("root") );
CHECK( fc.HasGroup(wxT("root/group1")) ); CHECK( fc.HasGroup("root/group1") );
CHECK( fc.HasGroup(wxT("root/group1/subgroup")) ); CHECK( fc.HasGroup("root/group1/subgroup") );
CHECK( fc.HasGroup(wxT("root/group2")) ); CHECK( fc.HasGroup("root/group2") );
CHECK( !fc.HasGroup(wxT("")) ); CHECK( !fc.HasGroup("") );
CHECK( !fc.HasGroup(wxT("root/group")) ); CHECK( !fc.HasGroup("root/group") );
CHECK( !fc.HasGroup(wxT("root//subgroup")) ); CHECK( !fc.HasGroup("root//subgroup") );
CHECK( !fc.HasGroup(wxT("foot/subgroup")) ); CHECK( !fc.HasGroup("foot/subgroup") );
CHECK( !fc.HasGroup(wxT("foot")) ); CHECK( !fc.HasGroup("foot") );
} }
TEST_CASE("wxFileConfig::Binary", "[fileconfig][config]") TEST_CASE("wxFileConfig::Binary", "[fileconfig][config]")
@@ -242,24 +242,24 @@ TEST_CASE("wxFileConfig::DeleteEntry", "[fileconfig][config]")
wxStringInputStream sis(testconfig); wxStringInputStream sis(testconfig);
wxFileConfig fc(sis); wxFileConfig fc(sis);
CHECK( !fc.DeleteEntry(wxT("foo")) ); CHECK( !fc.DeleteEntry("foo") );
CHECK( fc.DeleteEntry(wxT("root/group1/subgroup/subentry")) ); CHECK( fc.DeleteEntry("root/group1/subgroup/subentry") );
wxVERIFY_FILECONFIG( wxT("[root]\n") wxVERIFY_FILECONFIG( "[root]\n"
wxT("entry=value\n") "entry=value\n"
wxT("[root/group1]\n") "[root/group1]\n"
wxT("[root/group1/subgroup]\n") "[root/group1/subgroup]\n"
wxT("subentry2=subvalue2\n") "subentry2=subvalue2\n"
wxT("[root/group2]\n"), "[root/group2]\n",
fc ); fc );
// group should be deleted now as well as it became empty // group should be deleted now as well as it became empty
wxConfigPathChanger change(&fc, wxT("root/group1/subgroup/subentry2")); wxConfigPathChanger change(&fc, "root/group1/subgroup/subentry2");
CHECK( fc.DeleteEntry(wxT("subentry2")) ); CHECK( fc.DeleteEntry("subentry2") );
wxVERIFY_FILECONFIG( wxT("[root]\n") wxVERIFY_FILECONFIG( "[root]\n"
wxT("entry=value\n") "entry=value\n"
wxT("[root/group1]\n") "[root/group1]\n"
wxT("[root/group2]\n"), "[root/group2]\n",
fc ); fc );
} }
@@ -327,21 +327,21 @@ TEST_CASE("wxFileConfig::DeleteGroup", "[fileconfig][config]")
wxStringInputStream sis(testconfig); wxStringInputStream sis(testconfig);
wxFileConfig fc(sis); wxFileConfig fc(sis);
CHECK( !fc.DeleteGroup(wxT("foo")) ); CHECK( !fc.DeleteGroup("foo") );
CHECK( fc.DeleteGroup(wxT("root/group1")) ); CHECK( fc.DeleteGroup("root/group1") );
wxVERIFY_FILECONFIG( wxT("[root]\n") wxVERIFY_FILECONFIG( "[root]\n"
wxT("entry=value\n") "entry=value\n"
wxT("[root/group2]\n"), "[root/group2]\n",
fc ); fc );
// notice trailing slash: it should be ignored // notice trailing slash: it should be ignored
CHECK( fc.DeleteGroup(wxT("root/group2/")) ); CHECK( fc.DeleteGroup("root/group2/") );
wxVERIFY_FILECONFIG( wxT("[root]\n") wxVERIFY_FILECONFIG( "[root]\n"
wxT("entry=value\n"), "entry=value\n",
fc ); fc );
CHECK( fc.DeleteGroup(wxT("root")) ); CHECK( fc.DeleteGroup("root") );
CHECK( Dump(fc).empty() ); CHECK( Dump(fc).empty() );
} }
@@ -359,29 +359,29 @@ TEST_CASE("wxFileConfig::RenameEntry", "[fileconfig][config]")
wxStringInputStream sis(testconfig); wxStringInputStream sis(testconfig);
wxFileConfig fc(sis); wxFileConfig fc(sis);
fc.SetPath(wxT("root")); fc.SetPath("root");
CHECK( fc.RenameEntry(wxT("entry"), wxT("newname")) ); CHECK( fc.RenameEntry("entry", "newname") );
wxVERIFY_FILECONFIG( wxT("[root]\n") wxVERIFY_FILECONFIG( "[root]\n"
wxT("newname=value\n") "newname=value\n"
wxT("[root/group1]\n") "[root/group1]\n"
wxT("[root/group1/subgroup]\n") "[root/group1/subgroup]\n"
wxT("subentry=subvalue\n") "subentry=subvalue\n"
wxT("subentry2=subvalue2\n") "subentry2=subvalue2\n"
wxT("[root/group2]\n"), "[root/group2]\n",
fc ); fc );
fc.SetPath(wxT("group1/subgroup")); fc.SetPath("group1/subgroup");
CHECK( !fc.RenameEntry(wxT("entry"), wxT("newname")) ); CHECK( !fc.RenameEntry("entry", "newname") );
CHECK( !fc.RenameEntry(wxT("subentry"), wxT("subentry2")) ); CHECK( !fc.RenameEntry("subentry", "subentry2") );
CHECK( fc.RenameEntry(wxT("subentry"), wxT("subentry1")) ); CHECK( fc.RenameEntry("subentry", "subentry1") );
wxVERIFY_FILECONFIG( wxT("[root]\n") wxVERIFY_FILECONFIG( "[root]\n"
wxT("newname=value\n") "newname=value\n"
wxT("[root/group1]\n") "[root/group1]\n"
wxT("[root/group1/subgroup]\n") "[root/group1/subgroup]\n"
wxT("subentry2=subvalue2\n") "subentry2=subvalue2\n"
wxT("subentry1=subvalue\n") "subentry1=subvalue\n"
wxT("[root/group2]\n"), "[root/group2]\n",
fc ); fc );
} }
@@ -390,118 +390,118 @@ TEST_CASE("wxFileConfig::RenameGroup", "[fileconfig][config]")
wxStringInputStream sis(testconfig); wxStringInputStream sis(testconfig);
wxFileConfig fc(sis); wxFileConfig fc(sis);
CHECK( fc.RenameGroup(wxT("root"), wxT("foot")) ); CHECK( fc.RenameGroup("root", "foot") );
wxVERIFY_FILECONFIG( wxT("[foot]\n") wxVERIFY_FILECONFIG( "[foot]\n"
wxT("entry=value\n") "entry=value\n"
wxT("[foot/group1]\n") "[foot/group1]\n"
wxT("[foot/group1/subgroup]\n") "[foot/group1/subgroup]\n"
wxT("subentry=subvalue\n") "subentry=subvalue\n"
wxT("subentry2=subvalue2\n") "subentry2=subvalue2\n"
wxT("[foot/group2]\n"), "[foot/group2]\n",
fc ); fc );
// renaming a path doesn't work, it must be the immediate group // renaming a path doesn't work, it must be the immediate group
CHECK( !fc.RenameGroup(wxT("foot/group1"), wxT("group2")) ); CHECK( !fc.RenameGroup("foot/group1", "group2") );
fc.SetPath(wxT("foot")); fc.SetPath("foot");
// renaming to a name of existing group doesn't work // renaming to a name of existing group doesn't work
CHECK( !fc.RenameGroup(wxT("group1"), wxT("group2")) ); CHECK( !fc.RenameGroup("group1", "group2") );
// try exchanging the groups names and then restore them back // try exchanging the groups names and then restore them back
CHECK( fc.RenameGroup(wxT("group1"), wxT("groupTmp")) ); CHECK( fc.RenameGroup("group1", "groupTmp") );
wxVERIFY_FILECONFIG( wxT("[foot]\n") wxVERIFY_FILECONFIG( "[foot]\n"
wxT("entry=value\n") "entry=value\n"
wxT("[foot/groupTmp]\n") "[foot/groupTmp]\n"
wxT("[foot/groupTmp/subgroup]\n") "[foot/groupTmp/subgroup]\n"
wxT("subentry=subvalue\n") "subentry=subvalue\n"
wxT("subentry2=subvalue2\n") "subentry2=subvalue2\n"
wxT("[foot/group2]\n"), "[foot/group2]\n",
fc ); fc );
CHECK( fc.RenameGroup(wxT("group2"), wxT("group1")) ); CHECK( fc.RenameGroup("group2", "group1") );
wxVERIFY_FILECONFIG( wxT("[foot]\n") wxVERIFY_FILECONFIG( "[foot]\n"
wxT("entry=value\n") "entry=value\n"
wxT("[foot/groupTmp]\n") "[foot/groupTmp]\n"
wxT("[foot/groupTmp/subgroup]\n") "[foot/groupTmp/subgroup]\n"
wxT("subentry=subvalue\n") "subentry=subvalue\n"
wxT("subentry2=subvalue2\n") "subentry2=subvalue2\n"
wxT("[foot/group1]\n"), "[foot/group1]\n",
fc ); fc );
CHECK( fc.RenameGroup(wxT("groupTmp"), wxT("group2")) ); CHECK( fc.RenameGroup("groupTmp", "group2") );
wxVERIFY_FILECONFIG( wxT("[foot]\n") wxVERIFY_FILECONFIG( "[foot]\n"
wxT("entry=value\n") "entry=value\n"
wxT("[foot/group2]\n") "[foot/group2]\n"
wxT("[foot/group2/subgroup]\n") "[foot/group2/subgroup]\n"
wxT("subentry=subvalue\n") "subentry=subvalue\n"
wxT("subentry2=subvalue2\n") "subentry2=subvalue2\n"
wxT("[foot/group1]\n"), "[foot/group1]\n",
fc ); fc );
CHECK( fc.RenameGroup(wxT("group1"), wxT("groupTmp")) ); CHECK( fc.RenameGroup("group1", "groupTmp") );
wxVERIFY_FILECONFIG( wxT("[foot]\n") wxVERIFY_FILECONFIG( "[foot]\n"
wxT("entry=value\n") "entry=value\n"
wxT("[foot/group2]\n") "[foot/group2]\n"
wxT("[foot/group2/subgroup]\n") "[foot/group2/subgroup]\n"
wxT("subentry=subvalue\n") "subentry=subvalue\n"
wxT("subentry2=subvalue2\n") "subentry2=subvalue2\n"
wxT("[foot/groupTmp]\n"), "[foot/groupTmp]\n",
fc ); fc );
CHECK( fc.RenameGroup(wxT("group2"), wxT("group1")) ); CHECK( fc.RenameGroup("group2", "group1") );
wxVERIFY_FILECONFIG( wxT("[foot]\n") wxVERIFY_FILECONFIG( "[foot]\n"
wxT("entry=value\n") "entry=value\n"
wxT("[foot/group1]\n") "[foot/group1]\n"
wxT("[foot/group1/subgroup]\n") "[foot/group1/subgroup]\n"
wxT("subentry=subvalue\n") "subentry=subvalue\n"
wxT("subentry2=subvalue2\n") "subentry2=subvalue2\n"
wxT("[foot/groupTmp]\n"), "[foot/groupTmp]\n",
fc ); fc );
CHECK( fc.RenameGroup(wxT("groupTmp"), wxT("group2")) ); CHECK( fc.RenameGroup("groupTmp", "group2") );
wxVERIFY_FILECONFIG( wxT("[foot]\n") wxVERIFY_FILECONFIG( "[foot]\n"
wxT("entry=value\n") "entry=value\n"
wxT("[foot/group1]\n") "[foot/group1]\n"
wxT("[foot/group1/subgroup]\n") "[foot/group1/subgroup]\n"
wxT("subentry=subvalue\n") "subentry=subvalue\n"
wxT("subentry2=subvalue2\n") "subentry2=subvalue2\n"
wxT("[foot/group2]\n"), "[foot/group2]\n",
fc ); fc );
} }
TEST_CASE("wxFileConfig::CreateSubgroupAndEntries", "[fileconfig][config]") TEST_CASE("wxFileConfig::CreateSubgroupAndEntries", "[fileconfig][config]")
{ {
wxFileConfig fc; wxFileConfig fc;
fc.Write(wxT("sub/sub_first"), wxT("sub_one")); fc.Write("sub/sub_first", "sub_one");
fc.Write(wxT("first"), wxT("one")); fc.Write("first", "one");
wxVERIFY_FILECONFIG( wxT("first=one\n") wxVERIFY_FILECONFIG( "first=one\n"
wxT("[sub]\n") "[sub]\n"
wxT("sub_first=sub_one\n"), "sub_first=sub_one\n",
fc ); fc );
} }
TEST_CASE("wxFileConfig::CreateEntriesAndSubgroup", "[fileconfig][config]") TEST_CASE("wxFileConfig::CreateEntriesAndSubgroup", "[fileconfig][config]")
{ {
wxFileConfig fc; wxFileConfig fc;
fc.Write(wxT("first"), wxT("one")); fc.Write("first", "one");
fc.Write(wxT("second"), wxT("two")); fc.Write("second", "two");
fc.Write(wxT("sub/sub_first"), wxT("sub_one")); fc.Write("sub/sub_first", "sub_one");
wxVERIFY_FILECONFIG( wxT("first=one\n") wxVERIFY_FILECONFIG( "first=one\n"
wxT("second=two\n") "second=two\n"
wxT("[sub]\n") "[sub]\n"
wxT("sub_first=sub_one\n"), "sub_first=sub_one\n",
fc ); fc );
} }
static void EmptyConfigAndWriteKey() static void EmptyConfigAndWriteKey()
{ {
wxFileConfig fc(wxT("deleteconftest")); wxFileConfig fc("deleteconftest");
const wxString groupPath = wxT("/root"); const wxString groupPath = "/root";
if ( fc.Exists(groupPath) ) if ( fc.Exists(groupPath) )
{ {
@@ -515,7 +515,7 @@ static void EmptyConfigAndWriteKey()
// this crashes on second call of this function // this crashes on second call of this function
CHECK( fc.Write(groupPath + wxT("/entry"), wxT("value")) ); CHECK( fc.Write(groupPath + "/entry", "value") );
} }
TEST_CASE("wxFileConfig::DeleteLastGroup", "[fileconfig][config]") TEST_CASE("wxFileConfig::DeleteLastGroup", "[fileconfig][config]")
@@ -535,47 +535,47 @@ TEST_CASE("wxFileConfig::DeleteLastGroup", "[fileconfig][config]")
// clean up // clean up
wxLogNull noLogging; wxLogNull noLogging;
(void) ::wxRemoveFile(wxFileConfig::GetLocalFileName(wxT("deleteconftest"))); (void) ::wxRemoveFile(wxFileConfig::GetLocalFileName("deleteconftest"));
} }
TEST_CASE("wxFileConfig::DeleteAndRecreateGroup", "[fileconfig][config]") TEST_CASE("wxFileConfig::DeleteAndRecreateGroup", "[fileconfig][config]")
{ {
static const wxChar *confInitial = static const char *confInitial =
wxT("[First]\n") "[First]\n"
wxT("Value1=Foo\n") "Value1=Foo\n"
wxT("[Second]\n") "[Second]\n"
wxT("Value2=Bar\n"); "Value2=Bar\n";
wxStringInputStream sis(confInitial); wxStringInputStream sis(confInitial);
wxFileConfig fc(sis); wxFileConfig fc(sis);
fc.DeleteGroup(wxT("Second")); fc.DeleteGroup("Second");
wxVERIFY_FILECONFIG( wxT("[First]\n") wxVERIFY_FILECONFIG( "[First]\n"
wxT("Value1=Foo\n"), "Value1=Foo\n",
fc ); fc );
fc.Write(wxT("Second/Value2"), wxT("New")); fc.Write("Second/Value2", "New");
wxVERIFY_FILECONFIG( wxT("[First]\n") wxVERIFY_FILECONFIG( "[First]\n"
wxT("Value1=Foo\n") "Value1=Foo\n"
wxT("[Second]\n") "[Second]\n"
wxT("Value2=New\n"), "Value2=New\n",
fc ); fc );
} }
TEST_CASE("wxFileConfig::AddToExistingRoot", "[fileconfig][config]") TEST_CASE("wxFileConfig::AddToExistingRoot", "[fileconfig][config]")
{ {
static const wxChar *confInitial = static const char *confInitial =
wxT("[Group]\n") "[Group]\n"
wxT("value1=foo\n"); "value1=foo\n";
wxStringInputStream sis(confInitial); wxStringInputStream sis(confInitial);
wxFileConfig fc(sis); wxFileConfig fc(sis);
fc.Write(wxT("/value1"), wxT("bar")); fc.Write("/value1", "bar");
wxVERIFY_FILECONFIG( wxVERIFY_FILECONFIG(
wxT("value1=bar\n") "value1=bar\n"
wxT("[Group]\n") "[Group]\n"
wxT("value1=foo\n"), "value1=foo\n",
fc fc
); );
} }

View File

@@ -28,31 +28,31 @@
TEST_CASE("wxRegConfig::ReadWrite", "[regconfig][config][registry]") TEST_CASE("wxRegConfig::ReadWrite", "[regconfig][config][registry]")
{ {
wxString app = wxT("wxRegConfigTestCase"); wxString app = "wxRegConfigTestCase";
wxString vendor = wxT("wxWidgets"); wxString vendor = "wxWidgets";
// NOTE: we use wxCONFIG_USE_LOCAL_FILE explicitly to test wxRegConfig // NOTE: we use wxCONFIG_USE_LOCAL_FILE explicitly to test wxRegConfig
// with something different from the default value wxCONFIG_USE_GLOBAL_FILE // with something different from the default value wxCONFIG_USE_GLOBAL_FILE
wxScopedPtr<wxConfigBase> config(new wxRegConfig(app, vendor, wxT(""), wxT(""), wxScopedPtr<wxConfigBase> config(new wxRegConfig(app, vendor, "", "",
wxCONFIG_USE_LOCAL_FILE)); wxCONFIG_USE_LOCAL_FILE));
// test writing // test writing
config->SetPath(wxT("/group1")); config->SetPath("/group1");
CHECK( config->Write(wxT("entry1"), wxT("foo")) ); CHECK( config->Write("entry1", "foo") );
config->SetPath(wxT("/group2")); config->SetPath("/group2");
CHECK( config->Write(wxT("entry1"), wxT("bar")) ); CHECK( config->Write("entry1", "bar") );
// test reading // test reading
wxString str; wxString str;
long dummy; long dummy;
config->SetPath(wxT("/")); config->SetPath("/");
CHECK( config->GetFirstGroup(str, dummy) ); CHECK( config->GetFirstGroup(str, dummy) );
CHECK( str == "group1" ); CHECK( str == "group1" );
CHECK( config->Read(wxT("group1/entry1"), wxT("INVALID DEFAULT")) == "foo" ); CHECK( config->Read("group1/entry1", "INVALID DEFAULT") == "foo" );
CHECK( config->GetNextGroup(str, dummy) ); CHECK( config->GetNextGroup(str, dummy) );
CHECK( str == "group2" ); CHECK( str == "group2" );
CHECK( config->Read(wxT("group2/entry1"), wxT("INVALID DEFAULT")) == "bar" ); CHECK( config->Read("group2/entry1", "INVALID DEFAULT") == "bar" );
config->DeleteAll(); config->DeleteAll();
} }