no real changes, just cleanup and use CPPUNIT_ASSERT_EQUAL instead of CPPUNIT_ASSERT (patch 1762528)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47774 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -43,6 +43,7 @@ private:
|
||||
|
||||
void ReadWriteLocalTest();
|
||||
void RecordingDefaultsTest();
|
||||
void ReadValues(wxConfig *config, bool has_values);
|
||||
|
||||
DECLARE_NO_COPY_CLASS(ConfigTestCase)
|
||||
};
|
||||
@@ -73,36 +74,74 @@ void ConfigTestCase::ReadWriteLocalTest()
|
||||
config = new wxConfig(app, vendor, wxT(""), wxT(""),
|
||||
wxCONFIG_USE_LOCAL_FILE);
|
||||
wxString string1 = config->Read(wxT("string1"));
|
||||
CPPUNIT_ASSERT( string1 == wxT("abc") );
|
||||
CPPUNIT_ASSERT_EQUAL( string1, wxString(wxT("abc")) );
|
||||
string1 = config->Read(wxT("string1"), wxT("defaultvalue"));
|
||||
CPPUNIT_ASSERT( string1 == wxT("abc") );
|
||||
CPPUNIT_ASSERT_EQUAL( string1, wxString(wxT("abc")) );
|
||||
|
||||
wxString string2;
|
||||
bool r = config->Read(wxT("string2"), &string2);
|
||||
CPPUNIT_ASSERT( r == true );
|
||||
CPPUNIT_ASSERT( string2 == wxT("def") );
|
||||
CPPUNIT_ASSERT( r );
|
||||
CPPUNIT_ASSERT_EQUAL( string2, wxString(wxT("def")) );
|
||||
|
||||
r = config->Read(wxT("string2"), &string2, wxT("defaultvalue"));
|
||||
CPPUNIT_ASSERT( r == true );
|
||||
CPPUNIT_ASSERT( string2 == wxT("def") );
|
||||
CPPUNIT_ASSERT( r );
|
||||
CPPUNIT_ASSERT_EQUAL( string2, wxString(wxT("def")) );
|
||||
|
||||
int int1 = config->Read(wxT("int1"), 5);
|
||||
CPPUNIT_ASSERT( int1 == 123 );
|
||||
CPPUNIT_ASSERT_EQUAL( int1, 123 );
|
||||
|
||||
long long1;
|
||||
r = config->Read(wxT("long1"), &long1);
|
||||
CPPUNIT_ASSERT( r == true );
|
||||
CPPUNIT_ASSERT( long1 == 234 );
|
||||
CPPUNIT_ASSERT( r );
|
||||
CPPUNIT_ASSERT_EQUAL( long1, 234L );
|
||||
|
||||
bool bool1;
|
||||
r = config->Read(wxT("foo"), &bool1);
|
||||
CPPUNIT_ASSERT( r == false );
|
||||
CPPUNIT_ASSERT( !r );
|
||||
|
||||
r = config->Read(wxT("bool1"), &bool1);
|
||||
CPPUNIT_ASSERT( r == true );
|
||||
CPPUNIT_ASSERT( bool1 == true );
|
||||
CPPUNIT_ASSERT( r );
|
||||
CPPUNIT_ASSERT_EQUAL( bool1, true );
|
||||
|
||||
wxColour color1;
|
||||
r = config->Read(wxT("color1"), &color1);
|
||||
CPPUNIT_ASSERT( r == true );
|
||||
CPPUNIT_ASSERT( r );
|
||||
CPPUNIT_ASSERT( color1 == wxColour(11,22,33,44) );
|
||||
|
||||
config->DeleteAll();
|
||||
delete config;
|
||||
}
|
||||
|
||||
void ConfigTestCase::ReadValues(wxConfig *config, bool has_values)
|
||||
{
|
||||
bool r;
|
||||
wxString string1 = config->Read(wxT("string1"), wxT("abc"));
|
||||
wxString string2 = config->Read(wxT("string2"), wxString(wxT("def")));
|
||||
wxString string3, string4;
|
||||
r = config->Read(wxT("string3"), &string3, wxT("abc"));
|
||||
CPPUNIT_ASSERT_EQUAL( r, has_values );
|
||||
r = config->Read(wxT("string4"), &string4, wxString(wxT("def")));
|
||||
CPPUNIT_ASSERT_EQUAL( r, has_values );
|
||||
int int1;
|
||||
r = config->Read(wxT("int1"), &int1, 123);
|
||||
CPPUNIT_ASSERT_EQUAL( r, has_values );
|
||||
int int2 = config->Read(wxT("int2"), 1234);
|
||||
CPPUNIT_ASSERT_EQUAL( int2, 1234 );
|
||||
long long1;
|
||||
r = config->Read(wxString(wxT("long1")), &long1, 234L);
|
||||
CPPUNIT_ASSERT_EQUAL( r, has_values );
|
||||
double double1;
|
||||
r = config->Read(wxT("double1"), &double1, 345.67);
|
||||
CPPUNIT_ASSERT_EQUAL( r, has_values );
|
||||
bool bool1;
|
||||
r = config->Read(wxT("bool1"), &bool1, true);
|
||||
CPPUNIT_ASSERT_EQUAL( r, has_values );
|
||||
wxColour color1;
|
||||
r = config->Read(wxT("color1"), &color1, wxColour(11,22,33,44));
|
||||
CPPUNIT_ASSERT_EQUAL( r, has_values );
|
||||
}
|
||||
|
||||
|
||||
void ConfigTestCase::RecordingDefaultsTest()
|
||||
{
|
||||
wxString app = wxT("wxConfigTestCaseRD");
|
||||
@@ -111,63 +150,12 @@ void ConfigTestCase::RecordingDefaultsTest()
|
||||
wxCONFIG_USE_LOCAL_FILE);
|
||||
config->DeleteAll();
|
||||
config->SetRecordDefaults(false); // by default it is false
|
||||
wxString string1, string2, string3, string4;
|
||||
string1 = config->Read(wxT("string1"), wxT("abc"));
|
||||
string2 = config->Read(wxT("string2"), wxString(wxT("def")));
|
||||
config->Read(wxT("string3"), &string3, wxT("abc"));
|
||||
config->Read(wxT("string4"), &string4, wxString(wxT("def")));
|
||||
int int1, int2;
|
||||
config->Read(wxT("int1"), &int1, 123);
|
||||
int2 = config->Read(wxT("int2"), 1234);
|
||||
long long1;
|
||||
config->Read(wxString(wxT("long1")), &long1, 234L);
|
||||
double double1;
|
||||
config->Read(wxT("double1"), &double1, 345.67);
|
||||
bool bool1;
|
||||
config->Read(wxT("bool1"), &bool1, true);
|
||||
wxColour color1;
|
||||
config->Read(wxT("color1"), &color1, wxColour(11,22,33,44));
|
||||
|
||||
CPPUNIT_ASSERT ( config->GetNumberOfEntries() == 0 );
|
||||
|
||||
ReadValues(config, false);
|
||||
CPPUNIT_ASSERT_EQUAL( (int) config->GetNumberOfEntries(), 0 );
|
||||
config->SetRecordDefaults(true);
|
||||
|
||||
bool r;
|
||||
string1 = config->Read(wxT("string1"), wxT("abc"));
|
||||
string2 = config->Read(wxT("string2"), wxString(wxT("def")));
|
||||
r = config->Read(wxT("string3"), &string3, wxT("abc"));
|
||||
CPPUNIT_ASSERT( r == false );
|
||||
r = config->Read(wxT("string4"), &string4, wxString(wxT("def")));
|
||||
CPPUNIT_ASSERT( r == false );
|
||||
r = config->Read(wxT("int1"), &int1, 123);
|
||||
CPPUNIT_ASSERT( r == false );
|
||||
int2 = config->Read(wxT("int2"), 1234);
|
||||
r = config->Read(wxString(wxT("long1")), &long1, 234L);
|
||||
CPPUNIT_ASSERT( r == false );
|
||||
r = config->Read(wxT("double1"), &double1, 345.67);
|
||||
CPPUNIT_ASSERT( r == false );
|
||||
r = config->Read(wxT("bool1"), &bool1, true);
|
||||
CPPUNIT_ASSERT( r == false );
|
||||
r = config->Read(wxT("color1"), &color1, wxColour(11,22,33,44));
|
||||
CPPUNIT_ASSERT( r == false );
|
||||
|
||||
CPPUNIT_ASSERT ( config->GetNumberOfEntries() == 10 );
|
||||
|
||||
r = config->Read(wxT("string3"), &string3, wxT("abc"));
|
||||
CPPUNIT_ASSERT( r == true );
|
||||
r = config->Read(wxT("string4"), &string4, wxString(wxT("def")));
|
||||
CPPUNIT_ASSERT( r == true );
|
||||
r = config->Read(wxT("int1"), &int1, 123);
|
||||
CPPUNIT_ASSERT( r == true );
|
||||
r = config->Read(wxString(wxT("long1")), &long1, 234L);
|
||||
CPPUNIT_ASSERT( r == true );
|
||||
r = config->Read(wxT("double1"), &double1, 345.67);
|
||||
CPPUNIT_ASSERT( r == true );
|
||||
r = config->Read(wxT("bool1"), &bool1, true);
|
||||
CPPUNIT_ASSERT( r == true );
|
||||
r = config->Read(wxT("color1"), &color1, wxColour(11,22,33,44));
|
||||
CPPUNIT_ASSERT( r == true );
|
||||
|
||||
ReadValues(config, false);
|
||||
CPPUNIT_ASSERT_EQUAL( (int) config->GetNumberOfEntries(), 10 );
|
||||
ReadValues(config, true);
|
||||
config->DeleteAll();
|
||||
delete config;
|
||||
}
|
||||
|
Reference in New Issue
Block a user