Remove wxT() from wxConfig unit tests
Just remove the visual noise, no real changes.
This commit is contained in:
@@ -34,72 +34,72 @@
|
||||
|
||||
TEST_CASE("wxConfig::ReadWriteLocal", "[config]")
|
||||
{
|
||||
wxString app = wxT("wxConfigTestCase");
|
||||
wxString vendor = wxT("wxWidgets");
|
||||
wxScopedPtr<wxConfig> config(new wxConfig(app, vendor, wxT(""), wxT(""),
|
||||
wxString app = "wxConfigTestCase";
|
||||
wxString vendor = "wxWidgets";
|
||||
wxScopedPtr<wxConfig> config(new wxConfig(app, vendor, "", "",
|
||||
wxCONFIG_USE_LOCAL_FILE));
|
||||
config->DeleteAll();
|
||||
config->Write(wxT("string1"), wxT("abc"));
|
||||
config->Write(wxT("string2"), wxString(wxT("def")));
|
||||
config->Write(wxT("int1"), 123);
|
||||
config->Write(wxString(wxT("long1")), 234L);
|
||||
config->Write(wxT("double1"), 345.67);
|
||||
config->Write(wxT("bool1"), true);
|
||||
config->Write("string1", "abc");
|
||||
config->Write("string2", wxString("def"));
|
||||
config->Write("int1", 123);
|
||||
config->Write(wxString("long1"), 234L);
|
||||
config->Write("double1", 345.67);
|
||||
config->Write("bool1", true);
|
||||
#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
|
||||
config->Flush();
|
||||
|
||||
config.reset(new wxConfig(app, vendor, wxT(""), wxT(""),
|
||||
config.reset(new wxConfig(app, vendor, "", "",
|
||||
wxCONFIG_USE_LOCAL_FILE));
|
||||
wxString string1 = config->Read(wxT("string1"));
|
||||
wxString string1 = config->Read("string1");
|
||||
CHECK( string1 == "abc" );
|
||||
string1 = config->Read(wxT("string1"), wxT("defaultvalue"));
|
||||
string1 = config->Read("string1", "defaultvalue");
|
||||
CHECK( string1 == "abc" );
|
||||
|
||||
wxString string2;
|
||||
bool r = config->Read(wxT("string2"), &string2);
|
||||
bool r = config->Read("string2", &string2);
|
||||
CHECK( r );
|
||||
CHECK( string2 == "def" );
|
||||
|
||||
r = config->Read(wxT("string2"), &string2, wxT("defaultvalue"));
|
||||
r = config->Read("string2", &string2, "defaultvalue");
|
||||
CHECK( r );
|
||||
CHECK( string2 == "def" );
|
||||
|
||||
int int1 = config->Read(wxT("int1"), 5);
|
||||
int int1 = config->Read("int1", 5);
|
||||
CHECK( int1 == 123 );
|
||||
|
||||
long long1;
|
||||
r = config->Read(wxT("long1"), &long1);
|
||||
r = config->Read("long1", &long1);
|
||||
CHECK( r );
|
||||
CHECK( long1 == 234L );
|
||||
|
||||
CHECK( config->ReadLong(wxT("long1"), 0) == 234 );
|
||||
CHECK( config->ReadLong("long1", 0) == 234 );
|
||||
|
||||
double double1;
|
||||
r = config->Read(wxT("double1"), &double1);
|
||||
r = config->Read("double1", &double1);
|
||||
CHECK( r );
|
||||
CHECK( double1 == 345.67 );
|
||||
|
||||
CHECK( config->ReadDouble(wxT("double1"), 0) == double1 );
|
||||
CHECK( config->ReadDouble("double1", 0) == double1 );
|
||||
|
||||
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 );
|
||||
|
||||
r = config->Read(wxT("bool1"), &bool1);
|
||||
r = config->Read("bool1", &bool1);
|
||||
CHECK( r );
|
||||
CHECK( bool1 == true );
|
||||
|
||||
CHECK( config->ReadBool(wxT("bool1"), false) == bool1 );
|
||||
CHECK( config->ReadBool("bool1", false) == bool1 );
|
||||
|
||||
#ifdef wxHAS_CONFIG_TEMPLATE_RW
|
||||
wxColour color1;
|
||||
r = config->Read(wxT("color1"), &color1);
|
||||
r = config->Read("color1", &color1);
|
||||
CHECK( r );
|
||||
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
|
||||
|
||||
config->DeleteAll();
|
||||
@@ -112,49 +112,49 @@ size_t ReadValues(const wxConfig& config, bool has_values)
|
||||
size_t read = 0;
|
||||
bool r;
|
||||
|
||||
wxString string1 = config.Read(wxT("string1"), wxT("abc"));
|
||||
wxString string1 = config.Read("string1", "abc");
|
||||
read++;
|
||||
|
||||
wxString string2 = config.Read(wxT("string2"), wxString(wxT("def")));
|
||||
wxString string2 = config.Read("string2", wxString("def"));
|
||||
read++;
|
||||
|
||||
wxString string3;
|
||||
r = config.Read(wxT("string3"), &string3, wxT("abc"));
|
||||
r = config.Read("string3", &string3, "abc");
|
||||
CHECK( r == has_values );
|
||||
read++;
|
||||
|
||||
wxString string4;
|
||||
r = config.Read(wxT("string4"), &string4, wxString(wxT("def")));
|
||||
r = config.Read("string4", &string4, wxString("def"));
|
||||
CHECK( r == has_values );
|
||||
read++;
|
||||
|
||||
int int1;
|
||||
r = config.Read(wxT("int1"), &int1, 123);
|
||||
r = config.Read("int1", &int1, 123);
|
||||
CHECK( r == has_values );
|
||||
read++;
|
||||
|
||||
int int2 = config.Read(wxT("int2"), 1234);
|
||||
int int2 = config.Read("int2", 1234);
|
||||
CHECK( 1234 == int2 );
|
||||
read++;
|
||||
|
||||
long long1;
|
||||
r = config.Read(wxString(wxT("long1")), &long1, 234L);
|
||||
r = config.Read(wxString("long1"), &long1, 234L);
|
||||
CHECK( r == has_values );
|
||||
read++;
|
||||
|
||||
double double1;
|
||||
r = config.Read(wxT("double1"), &double1, 345.67);
|
||||
r = config.Read("double1", &double1, 345.67);
|
||||
CHECK( r == has_values );
|
||||
read++;
|
||||
|
||||
bool bool1;
|
||||
r = config.Read(wxT("bool1"), &bool1, true);
|
||||
r = config.Read("bool1", &bool1, true);
|
||||
CHECK( r == has_values );
|
||||
read++;
|
||||
|
||||
#ifdef wxHAS_CONFIG_TEMPLATE_RW
|
||||
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 );
|
||||
read++;
|
||||
#endif // wxHAS_CONFIG_TEMPLATE_RW
|
||||
@@ -165,9 +165,9 @@ size_t ReadValues(const wxConfig& config, bool has_values)
|
||||
|
||||
TEST_CASE("wxConfig::RecordingDefaults", "[config]")
|
||||
{
|
||||
wxString app = wxT("wxConfigTestCaseRD");
|
||||
wxString vendor = wxT("wxWidgets");
|
||||
wxScopedPtr<wxConfig> config(new wxConfig(app, vendor, wxT(""), wxT(""),
|
||||
wxString app = "wxConfigTestCaseRD";
|
||||
wxString vendor = "wxWidgets";
|
||||
wxScopedPtr<wxConfig> config(new wxConfig(app, vendor, "", "",
|
||||
wxCONFIG_USE_LOCAL_FILE));
|
||||
config->DeleteAll();
|
||||
config->SetRecordDefaults(false); // by default it is false
|
||||
|
@@ -22,14 +22,14 @@
|
||||
#include "wx/sstream.h"
|
||||
#include "wx/log.h"
|
||||
|
||||
static const wxChar *testconfig =
|
||||
wxT("[root]\n")
|
||||
wxT("entry=value\n")
|
||||
wxT("[root/group1]\n")
|
||||
wxT("[root/group1/subgroup]\n")
|
||||
wxT("subentry=subvalue\n")
|
||||
wxT("subentry2=subvalue2\n")
|
||||
wxT("[root/group2]\n")
|
||||
static const char *testconfig =
|
||||
"[root]\n"
|
||||
"entry=value\n"
|
||||
"[root/group1]\n"
|
||||
"[root/group1/subgroup]\n"
|
||||
"subentry=subvalue\n"
|
||||
"subentry2=subvalue2\n"
|
||||
"[root/group2]\n"
|
||||
;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -46,7 +46,7 @@ static wxString Dump(wxFileConfig& fc)
|
||||
// helper macro to test wxFileConfig contents
|
||||
#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);
|
||||
|
||||
@@ -62,34 +62,34 @@ TEST_CASE("wxFileConfig::Path", "[fileconfig][config]")
|
||||
wxStringInputStream sis(testconfig);
|
||||
wxFileConfig fc(sis);
|
||||
|
||||
CHECK( ChangePath(fc, wxT("")) == wxT("") );
|
||||
CHECK( ChangePath(fc, wxT("/")) == wxT("") );
|
||||
CHECK( ChangePath(fc, wxT("root")) == wxT("/root") );
|
||||
CHECK( ChangePath(fc, wxT("/root")) == wxT("/root") );
|
||||
CHECK( ChangePath(fc, wxT("/root/group1/subgroup")) == wxT("/root/group1/subgroup") );
|
||||
CHECK( ChangePath(fc, wxT("/root/group2")) == wxT("/root/group2") );
|
||||
CHECK( ChangePath(fc, "") == "" );
|
||||
CHECK( ChangePath(fc, "/") == "" );
|
||||
CHECK( ChangePath(fc, "root") == "/root" );
|
||||
CHECK( ChangePath(fc, "/root") == "/root" );
|
||||
CHECK( ChangePath(fc, "/root/group1/subgroup") == "/root/group1/subgroup" );
|
||||
CHECK( ChangePath(fc, "/root/group2") == "/root/group2" );
|
||||
}
|
||||
|
||||
TEST_CASE("wxFileConfig::AddEntries", "[fileconfig][config]")
|
||||
{
|
||||
wxFileConfig fc;
|
||||
|
||||
wxVERIFY_FILECONFIG( wxT(""), fc );
|
||||
wxVERIFY_FILECONFIG( "", fc );
|
||||
|
||||
fc.Write(wxT("/Foo"), wxT("foo"));
|
||||
wxVERIFY_FILECONFIG( wxT("Foo=foo\n"), fc );
|
||||
fc.Write("/Foo", "foo");
|
||||
wxVERIFY_FILECONFIG( "Foo=foo\n", fc );
|
||||
|
||||
fc.Write(wxT("/Bar/Baz"), wxT("baz"));
|
||||
wxVERIFY_FILECONFIG( wxT("Foo=foo\n[Bar]\nBaz=baz\n"), fc );
|
||||
fc.Write("/Bar/Baz", "baz");
|
||||
wxVERIFY_FILECONFIG( "Foo=foo\n[Bar]\nBaz=baz\n", fc );
|
||||
|
||||
fc.DeleteAll();
|
||||
wxVERIFY_FILECONFIG( wxT(""), fc );
|
||||
wxVERIFY_FILECONFIG( "", fc );
|
||||
|
||||
fc.Write(wxT("/Bar/Baz"), wxT("baz"));
|
||||
wxVERIFY_FILECONFIG( wxT("[Bar]\nBaz=baz\n"), fc );
|
||||
fc.Write("/Bar/Baz", "baz");
|
||||
wxVERIFY_FILECONFIG( "[Bar]\nBaz=baz\n", fc );
|
||||
|
||||
fc.Write(wxT("/Foo"), wxT("foo"));
|
||||
wxVERIFY_FILECONFIG( wxT("Foo=foo\n[Bar]\nBaz=baz\n"), fc );
|
||||
fc.Write("/Foo", "foo");
|
||||
wxVERIFY_FILECONFIG( "Foo=foo\n[Bar]\nBaz=baz\n", fc );
|
||||
}
|
||||
|
||||
namespace
|
||||
@@ -97,11 +97,11 @@ namespace
|
||||
|
||||
void
|
||||
CheckGroupEntries(const wxFileConfig& fc,
|
||||
const wxChar *path,
|
||||
const char *path,
|
||||
size_t nEntries,
|
||||
...)
|
||||
{
|
||||
wxConfigPathChanger change(&fc, wxString(path) + wxT("/"));
|
||||
wxConfigPathChanger change(&fc, wxString(path) + "/");
|
||||
|
||||
CHECK( fc.GetNumberOfEntries() == nEntries );
|
||||
|
||||
@@ -114,7 +114,7 @@ CheckGroupEntries(const wxFileConfig& fc,
|
||||
cont;
|
||||
cont = fc.GetNextEntry(name, cookie), nEntries-- )
|
||||
{
|
||||
CHECK( name == va_arg(ap, wxChar *) );
|
||||
CHECK( name == va_arg(ap, char *) );
|
||||
}
|
||||
|
||||
CHECK( nEntries == 0 );
|
||||
@@ -124,11 +124,11 @@ CheckGroupEntries(const wxFileConfig& fc,
|
||||
|
||||
void
|
||||
CheckGroupSubgroups(const wxFileConfig& fc,
|
||||
const wxChar *path,
|
||||
const char *path,
|
||||
size_t nGroups,
|
||||
...)
|
||||
{
|
||||
wxConfigPathChanger change(&fc, wxString(path) + wxT("/"));
|
||||
wxConfigPathChanger change(&fc, wxString(path) + "/");
|
||||
|
||||
CHECK( fc.GetNumberOfGroups() == nGroups );
|
||||
|
||||
@@ -141,7 +141,7 @@ CheckGroupSubgroups(const wxFileConfig& fc,
|
||||
cont;
|
||||
cont = fc.GetNextGroup(name, cookie), nGroups-- )
|
||||
{
|
||||
CHECK( name == va_arg(ap, wxChar *) );
|
||||
CHECK( name == va_arg(ap, char *) );
|
||||
}
|
||||
|
||||
CHECK( nGroups == 0 );
|
||||
@@ -156,11 +156,11 @@ TEST_CASE("wxFileConfig::GetEntries", "[fileconfig][config]")
|
||||
wxStringInputStream sis(testconfig);
|
||||
wxFileConfig fc(sis);
|
||||
|
||||
CheckGroupEntries(fc, wxT(""), 0);
|
||||
CheckGroupEntries(fc, wxT("/root"), 1, wxT("entry"));
|
||||
CheckGroupEntries(fc, wxT("/root/group1"), 0);
|
||||
CheckGroupEntries(fc, wxT("/root/group1/subgroup"),
|
||||
2, wxT("subentry"), wxT("subentry2"));
|
||||
CheckGroupEntries(fc, "", 0);
|
||||
CheckGroupEntries(fc, "/root", 1, "entry");
|
||||
CheckGroupEntries(fc, "/root/group1", 0);
|
||||
CheckGroupEntries(fc, "/root/group1/subgroup",
|
||||
2, "subentry", "subentry2");
|
||||
}
|
||||
|
||||
TEST_CASE("wxFileConfig::GetGroups", "[fileconfig][config]")
|
||||
@@ -168,10 +168,10 @@ TEST_CASE("wxFileConfig::GetGroups", "[fileconfig][config]")
|
||||
wxStringInputStream sis(testconfig);
|
||||
wxFileConfig fc(sis);
|
||||
|
||||
CheckGroupSubgroups(fc, wxT(""), 1, wxT("root"));
|
||||
CheckGroupSubgroups(fc, wxT("/root"), 2, wxT("group1"), wxT("group2"));
|
||||
CheckGroupSubgroups(fc, wxT("/root/group1"), 1, wxT("subgroup"));
|
||||
CheckGroupSubgroups(fc, wxT("/root/group2"), 0);
|
||||
CheckGroupSubgroups(fc, "", 1, "root");
|
||||
CheckGroupSubgroups(fc, "/root", 2, "group1", "group2");
|
||||
CheckGroupSubgroups(fc, "/root/group1", 1, "subgroup");
|
||||
CheckGroupSubgroups(fc, "/root/group2", 0);
|
||||
}
|
||||
|
||||
TEST_CASE("wxFileConfig::HasEntry", "[fileconfig][config]")
|
||||
@@ -179,15 +179,15 @@ TEST_CASE("wxFileConfig::HasEntry", "[fileconfig][config]")
|
||||
wxStringInputStream sis(testconfig);
|
||||
wxFileConfig fc(sis);
|
||||
|
||||
CHECK( !fc.HasEntry(wxT("root")) );
|
||||
CHECK( fc.HasEntry(wxT("root/entry")) );
|
||||
CHECK( fc.HasEntry(wxT("/root/entry")) );
|
||||
CHECK( fc.HasEntry(wxT("root/group1/subgroup/subentry")) );
|
||||
CHECK( !fc.HasEntry(wxT("")) );
|
||||
CHECK( !fc.HasEntry(wxT("root/group1")) );
|
||||
CHECK( !fc.HasEntry(wxT("subgroup/subentry")) );
|
||||
CHECK( !fc.HasEntry(wxT("/root/no_such_group/entry")) );
|
||||
CHECK( !fc.HasGroup(wxT("/root/no_such_group")) );
|
||||
CHECK( !fc.HasEntry("root") );
|
||||
CHECK( fc.HasEntry("root/entry") );
|
||||
CHECK( fc.HasEntry("/root/entry") );
|
||||
CHECK( fc.HasEntry("root/group1/subgroup/subentry") );
|
||||
CHECK( !fc.HasEntry("") );
|
||||
CHECK( !fc.HasEntry("root/group1") );
|
||||
CHECK( !fc.HasEntry("subgroup/subentry") );
|
||||
CHECK( !fc.HasEntry("/root/no_such_group/entry") );
|
||||
CHECK( !fc.HasGroup("/root/no_such_group") );
|
||||
}
|
||||
|
||||
TEST_CASE("wxFileConfig::HasGroup", "[fileconfig][config]")
|
||||
@@ -195,15 +195,15 @@ TEST_CASE("wxFileConfig::HasGroup", "[fileconfig][config]")
|
||||
wxStringInputStream sis(testconfig);
|
||||
wxFileConfig fc(sis);
|
||||
|
||||
CHECK( fc.HasGroup(wxT("root")) );
|
||||
CHECK( fc.HasGroup(wxT("root/group1")) );
|
||||
CHECK( fc.HasGroup(wxT("root/group1/subgroup")) );
|
||||
CHECK( fc.HasGroup(wxT("root/group2")) );
|
||||
CHECK( !fc.HasGroup(wxT("")) );
|
||||
CHECK( !fc.HasGroup(wxT("root/group")) );
|
||||
CHECK( !fc.HasGroup(wxT("root//subgroup")) );
|
||||
CHECK( !fc.HasGroup(wxT("foot/subgroup")) );
|
||||
CHECK( !fc.HasGroup(wxT("foot")) );
|
||||
CHECK( fc.HasGroup("root") );
|
||||
CHECK( fc.HasGroup("root/group1") );
|
||||
CHECK( fc.HasGroup("root/group1/subgroup") );
|
||||
CHECK( fc.HasGroup("root/group2") );
|
||||
CHECK( !fc.HasGroup("") );
|
||||
CHECK( !fc.HasGroup("root/group") );
|
||||
CHECK( !fc.HasGroup("root//subgroup") );
|
||||
CHECK( !fc.HasGroup("foot/subgroup") );
|
||||
CHECK( !fc.HasGroup("foot") );
|
||||
}
|
||||
|
||||
TEST_CASE("wxFileConfig::Binary", "[fileconfig][config]")
|
||||
@@ -242,24 +242,24 @@ TEST_CASE("wxFileConfig::DeleteEntry", "[fileconfig][config]")
|
||||
wxStringInputStream sis(testconfig);
|
||||
wxFileConfig fc(sis);
|
||||
|
||||
CHECK( !fc.DeleteEntry(wxT("foo")) );
|
||||
CHECK( !fc.DeleteEntry("foo") );
|
||||
|
||||
CHECK( fc.DeleteEntry(wxT("root/group1/subgroup/subentry")) );
|
||||
wxVERIFY_FILECONFIG( wxT("[root]\n")
|
||||
wxT("entry=value\n")
|
||||
wxT("[root/group1]\n")
|
||||
wxT("[root/group1/subgroup]\n")
|
||||
wxT("subentry2=subvalue2\n")
|
||||
wxT("[root/group2]\n"),
|
||||
CHECK( fc.DeleteEntry("root/group1/subgroup/subentry") );
|
||||
wxVERIFY_FILECONFIG( "[root]\n"
|
||||
"entry=value\n"
|
||||
"[root/group1]\n"
|
||||
"[root/group1/subgroup]\n"
|
||||
"subentry2=subvalue2\n"
|
||||
"[root/group2]\n",
|
||||
fc );
|
||||
|
||||
// group should be deleted now as well as it became empty
|
||||
wxConfigPathChanger change(&fc, wxT("root/group1/subgroup/subentry2"));
|
||||
CHECK( fc.DeleteEntry(wxT("subentry2")) );
|
||||
wxVERIFY_FILECONFIG( wxT("[root]\n")
|
||||
wxT("entry=value\n")
|
||||
wxT("[root/group1]\n")
|
||||
wxT("[root/group2]\n"),
|
||||
wxConfigPathChanger change(&fc, "root/group1/subgroup/subentry2");
|
||||
CHECK( fc.DeleteEntry("subentry2") );
|
||||
wxVERIFY_FILECONFIG( "[root]\n"
|
||||
"entry=value\n"
|
||||
"[root/group1]\n"
|
||||
"[root/group2]\n",
|
||||
fc );
|
||||
}
|
||||
|
||||
@@ -327,21 +327,21 @@ TEST_CASE("wxFileConfig::DeleteGroup", "[fileconfig][config]")
|
||||
wxStringInputStream sis(testconfig);
|
||||
wxFileConfig fc(sis);
|
||||
|
||||
CHECK( !fc.DeleteGroup(wxT("foo")) );
|
||||
CHECK( !fc.DeleteGroup("foo") );
|
||||
|
||||
CHECK( fc.DeleteGroup(wxT("root/group1")) );
|
||||
wxVERIFY_FILECONFIG( wxT("[root]\n")
|
||||
wxT("entry=value\n")
|
||||
wxT("[root/group2]\n"),
|
||||
CHECK( fc.DeleteGroup("root/group1") );
|
||||
wxVERIFY_FILECONFIG( "[root]\n"
|
||||
"entry=value\n"
|
||||
"[root/group2]\n",
|
||||
fc );
|
||||
|
||||
// notice trailing slash: it should be ignored
|
||||
CHECK( fc.DeleteGroup(wxT("root/group2/")) );
|
||||
wxVERIFY_FILECONFIG( wxT("[root]\n")
|
||||
wxT("entry=value\n"),
|
||||
CHECK( fc.DeleteGroup("root/group2/") );
|
||||
wxVERIFY_FILECONFIG( "[root]\n"
|
||||
"entry=value\n",
|
||||
fc );
|
||||
|
||||
CHECK( fc.DeleteGroup(wxT("root")) );
|
||||
CHECK( fc.DeleteGroup("root") );
|
||||
CHECK( Dump(fc).empty() );
|
||||
}
|
||||
|
||||
@@ -359,29 +359,29 @@ TEST_CASE("wxFileConfig::RenameEntry", "[fileconfig][config]")
|
||||
wxStringInputStream sis(testconfig);
|
||||
wxFileConfig fc(sis);
|
||||
|
||||
fc.SetPath(wxT("root"));
|
||||
CHECK( fc.RenameEntry(wxT("entry"), wxT("newname")) );
|
||||
wxVERIFY_FILECONFIG( wxT("[root]\n")
|
||||
wxT("newname=value\n")
|
||||
wxT("[root/group1]\n")
|
||||
wxT("[root/group1/subgroup]\n")
|
||||
wxT("subentry=subvalue\n")
|
||||
wxT("subentry2=subvalue2\n")
|
||||
wxT("[root/group2]\n"),
|
||||
fc.SetPath("root");
|
||||
CHECK( fc.RenameEntry("entry", "newname") );
|
||||
wxVERIFY_FILECONFIG( "[root]\n"
|
||||
"newname=value\n"
|
||||
"[root/group1]\n"
|
||||
"[root/group1/subgroup]\n"
|
||||
"subentry=subvalue\n"
|
||||
"subentry2=subvalue2\n"
|
||||
"[root/group2]\n",
|
||||
fc );
|
||||
|
||||
fc.SetPath(wxT("group1/subgroup"));
|
||||
CHECK( !fc.RenameEntry(wxT("entry"), wxT("newname")) );
|
||||
CHECK( !fc.RenameEntry(wxT("subentry"), wxT("subentry2")) );
|
||||
fc.SetPath("group1/subgroup");
|
||||
CHECK( !fc.RenameEntry("entry", "newname") );
|
||||
CHECK( !fc.RenameEntry("subentry", "subentry2") );
|
||||
|
||||
CHECK( fc.RenameEntry(wxT("subentry"), wxT("subentry1")) );
|
||||
wxVERIFY_FILECONFIG( wxT("[root]\n")
|
||||
wxT("newname=value\n")
|
||||
wxT("[root/group1]\n")
|
||||
wxT("[root/group1/subgroup]\n")
|
||||
wxT("subentry2=subvalue2\n")
|
||||
wxT("subentry1=subvalue\n")
|
||||
wxT("[root/group2]\n"),
|
||||
CHECK( fc.RenameEntry("subentry", "subentry1") );
|
||||
wxVERIFY_FILECONFIG( "[root]\n"
|
||||
"newname=value\n"
|
||||
"[root/group1]\n"
|
||||
"[root/group1/subgroup]\n"
|
||||
"subentry2=subvalue2\n"
|
||||
"subentry1=subvalue\n"
|
||||
"[root/group2]\n",
|
||||
fc );
|
||||
}
|
||||
|
||||
@@ -390,118 +390,118 @@ TEST_CASE("wxFileConfig::RenameGroup", "[fileconfig][config]")
|
||||
wxStringInputStream sis(testconfig);
|
||||
wxFileConfig fc(sis);
|
||||
|
||||
CHECK( fc.RenameGroup(wxT("root"), wxT("foot")) );
|
||||
wxVERIFY_FILECONFIG( wxT("[foot]\n")
|
||||
wxT("entry=value\n")
|
||||
wxT("[foot/group1]\n")
|
||||
wxT("[foot/group1/subgroup]\n")
|
||||
wxT("subentry=subvalue\n")
|
||||
wxT("subentry2=subvalue2\n")
|
||||
wxT("[foot/group2]\n"),
|
||||
CHECK( fc.RenameGroup("root", "foot") );
|
||||
wxVERIFY_FILECONFIG( "[foot]\n"
|
||||
"entry=value\n"
|
||||
"[foot/group1]\n"
|
||||
"[foot/group1/subgroup]\n"
|
||||
"subentry=subvalue\n"
|
||||
"subentry2=subvalue2\n"
|
||||
"[foot/group2]\n",
|
||||
fc );
|
||||
|
||||
// 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
|
||||
CHECK( !fc.RenameGroup(wxT("group1"), wxT("group2")) );
|
||||
CHECK( !fc.RenameGroup("group1", "group2") );
|
||||
|
||||
// try exchanging the groups names and then restore them back
|
||||
CHECK( fc.RenameGroup(wxT("group1"), wxT("groupTmp")) );
|
||||
wxVERIFY_FILECONFIG( wxT("[foot]\n")
|
||||
wxT("entry=value\n")
|
||||
wxT("[foot/groupTmp]\n")
|
||||
wxT("[foot/groupTmp/subgroup]\n")
|
||||
wxT("subentry=subvalue\n")
|
||||
wxT("subentry2=subvalue2\n")
|
||||
wxT("[foot/group2]\n"),
|
||||
CHECK( fc.RenameGroup("group1", "groupTmp") );
|
||||
wxVERIFY_FILECONFIG( "[foot]\n"
|
||||
"entry=value\n"
|
||||
"[foot/groupTmp]\n"
|
||||
"[foot/groupTmp/subgroup]\n"
|
||||
"subentry=subvalue\n"
|
||||
"subentry2=subvalue2\n"
|
||||
"[foot/group2]\n",
|
||||
fc );
|
||||
|
||||
CHECK( fc.RenameGroup(wxT("group2"), wxT("group1")) );
|
||||
wxVERIFY_FILECONFIG( wxT("[foot]\n")
|
||||
wxT("entry=value\n")
|
||||
wxT("[foot/groupTmp]\n")
|
||||
wxT("[foot/groupTmp/subgroup]\n")
|
||||
wxT("subentry=subvalue\n")
|
||||
wxT("subentry2=subvalue2\n")
|
||||
wxT("[foot/group1]\n"),
|
||||
CHECK( fc.RenameGroup("group2", "group1") );
|
||||
wxVERIFY_FILECONFIG( "[foot]\n"
|
||||
"entry=value\n"
|
||||
"[foot/groupTmp]\n"
|
||||
"[foot/groupTmp/subgroup]\n"
|
||||
"subentry=subvalue\n"
|
||||
"subentry2=subvalue2\n"
|
||||
"[foot/group1]\n",
|
||||
fc );
|
||||
|
||||
CHECK( fc.RenameGroup(wxT("groupTmp"), wxT("group2")) );
|
||||
wxVERIFY_FILECONFIG( wxT("[foot]\n")
|
||||
wxT("entry=value\n")
|
||||
wxT("[foot/group2]\n")
|
||||
wxT("[foot/group2/subgroup]\n")
|
||||
wxT("subentry=subvalue\n")
|
||||
wxT("subentry2=subvalue2\n")
|
||||
wxT("[foot/group1]\n"),
|
||||
CHECK( fc.RenameGroup("groupTmp", "group2") );
|
||||
wxVERIFY_FILECONFIG( "[foot]\n"
|
||||
"entry=value\n"
|
||||
"[foot/group2]\n"
|
||||
"[foot/group2/subgroup]\n"
|
||||
"subentry=subvalue\n"
|
||||
"subentry2=subvalue2\n"
|
||||
"[foot/group1]\n",
|
||||
fc );
|
||||
|
||||
CHECK( fc.RenameGroup(wxT("group1"), wxT("groupTmp")) );
|
||||
wxVERIFY_FILECONFIG( wxT("[foot]\n")
|
||||
wxT("entry=value\n")
|
||||
wxT("[foot/group2]\n")
|
||||
wxT("[foot/group2/subgroup]\n")
|
||||
wxT("subentry=subvalue\n")
|
||||
wxT("subentry2=subvalue2\n")
|
||||
wxT("[foot/groupTmp]\n"),
|
||||
CHECK( fc.RenameGroup("group1", "groupTmp") );
|
||||
wxVERIFY_FILECONFIG( "[foot]\n"
|
||||
"entry=value\n"
|
||||
"[foot/group2]\n"
|
||||
"[foot/group2/subgroup]\n"
|
||||
"subentry=subvalue\n"
|
||||
"subentry2=subvalue2\n"
|
||||
"[foot/groupTmp]\n",
|
||||
fc );
|
||||
|
||||
CHECK( fc.RenameGroup(wxT("group2"), wxT("group1")) );
|
||||
wxVERIFY_FILECONFIG( wxT("[foot]\n")
|
||||
wxT("entry=value\n")
|
||||
wxT("[foot/group1]\n")
|
||||
wxT("[foot/group1/subgroup]\n")
|
||||
wxT("subentry=subvalue\n")
|
||||
wxT("subentry2=subvalue2\n")
|
||||
wxT("[foot/groupTmp]\n"),
|
||||
CHECK( fc.RenameGroup("group2", "group1") );
|
||||
wxVERIFY_FILECONFIG( "[foot]\n"
|
||||
"entry=value\n"
|
||||
"[foot/group1]\n"
|
||||
"[foot/group1/subgroup]\n"
|
||||
"subentry=subvalue\n"
|
||||
"subentry2=subvalue2\n"
|
||||
"[foot/groupTmp]\n",
|
||||
fc );
|
||||
|
||||
CHECK( fc.RenameGroup(wxT("groupTmp"), wxT("group2")) );
|
||||
wxVERIFY_FILECONFIG( wxT("[foot]\n")
|
||||
wxT("entry=value\n")
|
||||
wxT("[foot/group1]\n")
|
||||
wxT("[foot/group1/subgroup]\n")
|
||||
wxT("subentry=subvalue\n")
|
||||
wxT("subentry2=subvalue2\n")
|
||||
wxT("[foot/group2]\n"),
|
||||
CHECK( fc.RenameGroup("groupTmp", "group2") );
|
||||
wxVERIFY_FILECONFIG( "[foot]\n"
|
||||
"entry=value\n"
|
||||
"[foot/group1]\n"
|
||||
"[foot/group1/subgroup]\n"
|
||||
"subentry=subvalue\n"
|
||||
"subentry2=subvalue2\n"
|
||||
"[foot/group2]\n",
|
||||
fc );
|
||||
}
|
||||
|
||||
TEST_CASE("wxFileConfig::CreateSubgroupAndEntries", "[fileconfig][config]")
|
||||
{
|
||||
wxFileConfig fc;
|
||||
fc.Write(wxT("sub/sub_first"), wxT("sub_one"));
|
||||
fc.Write(wxT("first"), wxT("one"));
|
||||
fc.Write("sub/sub_first", "sub_one");
|
||||
fc.Write("first", "one");
|
||||
|
||||
wxVERIFY_FILECONFIG( wxT("first=one\n")
|
||||
wxT("[sub]\n")
|
||||
wxT("sub_first=sub_one\n"),
|
||||
wxVERIFY_FILECONFIG( "first=one\n"
|
||||
"[sub]\n"
|
||||
"sub_first=sub_one\n",
|
||||
fc );
|
||||
}
|
||||
|
||||
TEST_CASE("wxFileConfig::CreateEntriesAndSubgroup", "[fileconfig][config]")
|
||||
{
|
||||
wxFileConfig fc;
|
||||
fc.Write(wxT("first"), wxT("one"));
|
||||
fc.Write(wxT("second"), wxT("two"));
|
||||
fc.Write(wxT("sub/sub_first"), wxT("sub_one"));
|
||||
fc.Write("first", "one");
|
||||
fc.Write("second", "two");
|
||||
fc.Write("sub/sub_first", "sub_one");
|
||||
|
||||
wxVERIFY_FILECONFIG( wxT("first=one\n")
|
||||
wxT("second=two\n")
|
||||
wxT("[sub]\n")
|
||||
wxT("sub_first=sub_one\n"),
|
||||
wxVERIFY_FILECONFIG( "first=one\n"
|
||||
"second=two\n"
|
||||
"[sub]\n"
|
||||
"sub_first=sub_one\n",
|
||||
fc );
|
||||
}
|
||||
|
||||
static void EmptyConfigAndWriteKey()
|
||||
{
|
||||
wxFileConfig fc(wxT("deleteconftest"));
|
||||
wxFileConfig fc("deleteconftest");
|
||||
|
||||
const wxString groupPath = wxT("/root");
|
||||
const wxString groupPath = "/root";
|
||||
|
||||
if ( fc.Exists(groupPath) )
|
||||
{
|
||||
@@ -515,7 +515,7 @@ static void EmptyConfigAndWriteKey()
|
||||
|
||||
|
||||
// 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]")
|
||||
@@ -535,47 +535,47 @@ TEST_CASE("wxFileConfig::DeleteLastGroup", "[fileconfig][config]")
|
||||
|
||||
// clean up
|
||||
wxLogNull noLogging;
|
||||
(void) ::wxRemoveFile(wxFileConfig::GetLocalFileName(wxT("deleteconftest")));
|
||||
(void) ::wxRemoveFile(wxFileConfig::GetLocalFileName("deleteconftest"));
|
||||
}
|
||||
|
||||
TEST_CASE("wxFileConfig::DeleteAndRecreateGroup", "[fileconfig][config]")
|
||||
{
|
||||
static const wxChar *confInitial =
|
||||
wxT("[First]\n")
|
||||
wxT("Value1=Foo\n")
|
||||
wxT("[Second]\n")
|
||||
wxT("Value2=Bar\n");
|
||||
static const char *confInitial =
|
||||
"[First]\n"
|
||||
"Value1=Foo\n"
|
||||
"[Second]\n"
|
||||
"Value2=Bar\n";
|
||||
|
||||
wxStringInputStream sis(confInitial);
|
||||
wxFileConfig fc(sis);
|
||||
|
||||
fc.DeleteGroup(wxT("Second"));
|
||||
wxVERIFY_FILECONFIG( wxT("[First]\n")
|
||||
wxT("Value1=Foo\n"),
|
||||
fc.DeleteGroup("Second");
|
||||
wxVERIFY_FILECONFIG( "[First]\n"
|
||||
"Value1=Foo\n",
|
||||
fc );
|
||||
|
||||
fc.Write(wxT("Second/Value2"), wxT("New"));
|
||||
wxVERIFY_FILECONFIG( wxT("[First]\n")
|
||||
wxT("Value1=Foo\n")
|
||||
wxT("[Second]\n")
|
||||
wxT("Value2=New\n"),
|
||||
fc.Write("Second/Value2", "New");
|
||||
wxVERIFY_FILECONFIG( "[First]\n"
|
||||
"Value1=Foo\n"
|
||||
"[Second]\n"
|
||||
"Value2=New\n",
|
||||
fc );
|
||||
}
|
||||
|
||||
TEST_CASE("wxFileConfig::AddToExistingRoot", "[fileconfig][config]")
|
||||
{
|
||||
static const wxChar *confInitial =
|
||||
wxT("[Group]\n")
|
||||
wxT("value1=foo\n");
|
||||
static const char *confInitial =
|
||||
"[Group]\n"
|
||||
"value1=foo\n";
|
||||
|
||||
wxStringInputStream sis(confInitial);
|
||||
wxFileConfig fc(sis);
|
||||
|
||||
fc.Write(wxT("/value1"), wxT("bar"));
|
||||
fc.Write("/value1", "bar");
|
||||
wxVERIFY_FILECONFIG(
|
||||
wxT("value1=bar\n")
|
||||
wxT("[Group]\n")
|
||||
wxT("value1=foo\n"),
|
||||
"value1=bar\n"
|
||||
"[Group]\n"
|
||||
"value1=foo\n",
|
||||
fc
|
||||
);
|
||||
}
|
||||
|
@@ -28,31 +28,31 @@
|
||||
|
||||
TEST_CASE("wxRegConfig::ReadWrite", "[regconfig][config][registry]")
|
||||
{
|
||||
wxString app = wxT("wxRegConfigTestCase");
|
||||
wxString vendor = wxT("wxWidgets");
|
||||
wxString app = "wxRegConfigTestCase";
|
||||
wxString vendor = "wxWidgets";
|
||||
|
||||
// NOTE: we use wxCONFIG_USE_LOCAL_FILE explicitly to test wxRegConfig
|
||||
// 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));
|
||||
|
||||
// test writing
|
||||
config->SetPath(wxT("/group1"));
|
||||
CHECK( config->Write(wxT("entry1"), wxT("foo")) );
|
||||
config->SetPath(wxT("/group2"));
|
||||
CHECK( config->Write(wxT("entry1"), wxT("bar")) );
|
||||
config->SetPath("/group1");
|
||||
CHECK( config->Write("entry1", "foo") );
|
||||
config->SetPath("/group2");
|
||||
CHECK( config->Write("entry1", "bar") );
|
||||
|
||||
// test reading
|
||||
wxString str;
|
||||
long dummy;
|
||||
|
||||
config->SetPath(wxT("/"));
|
||||
config->SetPath("/");
|
||||
CHECK( config->GetFirstGroup(str, dummy) );
|
||||
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( str == "group2" );
|
||||
CHECK( config->Read(wxT("group2/entry1"), wxT("INVALID DEFAULT")) == "bar" );
|
||||
CHECK( config->Read("group2/entry1", "INVALID DEFAULT") == "bar" );
|
||||
|
||||
config->DeleteAll();
|
||||
}
|
||||
|
Reference in New Issue
Block a user