]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/config/config.cpp
Applied #13763 from dghart, to use primary selections if available
[wxWidgets.git] / tests / config / config.cpp
index 9a5eff85ff7c84498e49d2ab7c3405e633d9fe07..0abc18fb3c0622f6a7b577ee9b7c5ace16d0ae88 100644 (file)
@@ -7,7 +7,10 @@
 // Copyright:   (c) 2007 Marcin Wojdyr
 ///////////////////////////////////////////////////////////////////////////////
 
 // Copyright:   (c) 2007 Marcin Wojdyr
 ///////////////////////////////////////////////////////////////////////////////
 
-// see also tests/fileconf/fileconftest.cpp for wxFileConfig specific tests
+// NOTE: this test is compiled in test_gui because it uses wxColour for
+//       its testing purpose.
+// See also tests/config/fileconf.cpp for wxFileConfig specific tests and
+// tests/config/regconf.cpp for wxRegConfig specific tests.
 
 // ----------------------------------------------------------------------------
 // headers
 
 // ----------------------------------------------------------------------------
 // headers
@@ -15,6 +18,8 @@
 
 #include "testprec.h"
 
 
 #include "testprec.h"
 
+#if wxUSE_CONFIG
+
 #ifdef __BORLANDC__
     #pragma hdrstop
 #endif
 #ifdef __BORLANDC__
     #pragma hdrstop
 #endif
@@ -44,7 +49,8 @@ private:
     void ReadWriteLocalTest();
     void RecordingDefaultsTest();
 
     void ReadWriteLocalTest();
     void RecordingDefaultsTest();
 
-    void ReadValues(wxConfig *config, bool has_values);
+    // return the number of values we (attempted to) read
+    int ReadValues(wxConfig *config, bool has_values);
 
     DECLARE_NO_COPY_CLASS(ConfigTestCase)
 };
 
     DECLARE_NO_COPY_CLASS(ConfigTestCase)
 };
@@ -52,7 +58,7 @@ private:
 // register in the unnamed registry so that these tests are run by default
 CPPUNIT_TEST_SUITE_REGISTRATION( ConfigTestCase );
 
 // register in the unnamed registry so that these tests are run by default
 CPPUNIT_TEST_SUITE_REGISTRATION( ConfigTestCase );
 
-// also include in it's own registry so that these tests can be run alone
+// also include in its own registry so that these tests can be run alone
 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ConfigTestCase, "ConfigTestCase" );
 
 void ConfigTestCase::ReadWriteLocalTest()
 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ConfigTestCase, "ConfigTestCase" );
 
 void ConfigTestCase::ReadWriteLocalTest()
@@ -130,35 +136,59 @@ void ConfigTestCase::ReadWriteLocalTest()
     delete config;
 }
 
     delete config;
 }
 
-void ConfigTestCase::ReadValues(wxConfig *config, bool has_values)
+int ConfigTestCase::ReadValues(wxConfig *config, bool has_values)
 {
 {
+    int read = 0;
     bool r;
     bool r;
+
     wxString string1 = config->Read(wxT("string1"), wxT("abc"));
     wxString string1 = config->Read(wxT("string1"), wxT("abc"));
+    read++;
+
     wxString string2 = config->Read(wxT("string2"), wxString(wxT("def")));
     wxString string2 = config->Read(wxT("string2"), wxString(wxT("def")));
-    wxString string3, string4;
+    read++;
+
+    wxString string3;
     r = config->Read(wxT("string3"), &string3, wxT("abc"));
     CPPUNIT_ASSERT_EQUAL( has_values, r );
     r = config->Read(wxT("string3"), &string3, wxT("abc"));
     CPPUNIT_ASSERT_EQUAL( has_values, r );
+    read++;
+
+    wxString string4;
     r = config->Read(wxT("string4"), &string4, wxString(wxT("def")));
     CPPUNIT_ASSERT_EQUAL( has_values, r );
     r = config->Read(wxT("string4"), &string4, wxString(wxT("def")));
     CPPUNIT_ASSERT_EQUAL( has_values, r );
+    read++;
+
     int int1;
     r = config->Read(wxT("int1"), &int1, 123);
     CPPUNIT_ASSERT_EQUAL( has_values, r );
     int int1;
     r = config->Read(wxT("int1"), &int1, 123);
     CPPUNIT_ASSERT_EQUAL( has_values, r );
+    read++;
+
     int int2 = config->Read(wxT("int2"), 1234);
     CPPUNIT_ASSERT_EQUAL( int2, 1234 );
     int int2 = config->Read(wxT("int2"), 1234);
     CPPUNIT_ASSERT_EQUAL( int2, 1234 );
+    read++;
+
     long long1;
     r = config->Read(wxString(wxT("long1")), &long1, 234L);
     CPPUNIT_ASSERT_EQUAL( has_values, r );
     long long1;
     r = config->Read(wxString(wxT("long1")), &long1, 234L);
     CPPUNIT_ASSERT_EQUAL( has_values, r );
+    read++;
+
     double double1;
     r = config->Read(wxT("double1"), &double1, 345.67);
     CPPUNIT_ASSERT_EQUAL( has_values, r );
     double double1;
     r = config->Read(wxT("double1"), &double1, 345.67);
     CPPUNIT_ASSERT_EQUAL( has_values, r );
+    read++;
+
     bool bool1;
     r = config->Read(wxT("bool1"), &bool1, true);
     CPPUNIT_ASSERT_EQUAL( has_values, r );
     bool bool1;
     r = config->Read(wxT("bool1"), &bool1, true);
     CPPUNIT_ASSERT_EQUAL( has_values, r );
+    read++;
+
 #ifdef wxHAS_CONFIG_TEMPLATE_RW
     wxColour color1;
     r = config->Read(wxT("color1"), &color1, wxColour(11,22,33,44));
     CPPUNIT_ASSERT_EQUAL( has_values, r );
 #ifdef wxHAS_CONFIG_TEMPLATE_RW
     wxColour color1;
     r = config->Read(wxT("color1"), &color1, wxColour(11,22,33,44));
     CPPUNIT_ASSERT_EQUAL( has_values, r );
+    read++;
 #endif // wxHAS_CONFIG_TEMPLATE_RW
 #endif // wxHAS_CONFIG_TEMPLATE_RW
+
+    return read;
 }
 
 
 }
 
 
@@ -173,11 +203,11 @@ void ConfigTestCase::RecordingDefaultsTest()
     ReadValues(config, false);
     CPPUNIT_ASSERT_EQUAL( 0, config->GetNumberOfEntries() );
     config->SetRecordDefaults(true);
     ReadValues(config, false);
     CPPUNIT_ASSERT_EQUAL( 0, config->GetNumberOfEntries() );
     config->SetRecordDefaults(true);
-    ReadValues(config, false);
-    CPPUNIT_ASSERT_EQUAL( 10, config->GetNumberOfEntries() );
+    int read = ReadValues(config, false);
+    CPPUNIT_ASSERT_EQUAL( read, config->GetNumberOfEntries() );
     ReadValues(config, true);
     config->DeleteAll();
     delete config;
 }
 
     ReadValues(config, true);
     config->DeleteAll();
     delete config;
 }
 
-
+#endif //wxUSE_CONFIG