]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/config/fileconf.cpp
Use wxFindWindowAtPoint() for hit testing in wxPopupTransientWindow.
[wxWidgets.git] / tests / config / fileconf.cpp
index 4a354479b992bc5f9ed5a189c84c7f3164971849..4e3d8aa42f4fd560914f6ca12c54c6d30981c1b4 100644 (file)
@@ -3,7 +3,6 @@
 // Purpose:     wxFileConf unit test
 // Author:      Vadim Zeitlin
 // Created:     2004-09-19
-// RCS-ID:      $Id$
 // Copyright:   (c) 2004 Vadim Zeitlin
 ///////////////////////////////////////////////////////////////////////////////
 
@@ -71,6 +70,7 @@ private:
         CPPUNIT_TEST( Save );
         CPPUNIT_TEST( DeleteEntry );
         CPPUNIT_TEST( DeleteAndWriteEntry );
+        CPPUNIT_TEST( DeleteLastRootEntry );
         CPPUNIT_TEST( DeleteGroup );
         CPPUNIT_TEST( DeleteAll );
         CPPUNIT_TEST( RenameEntry );
@@ -82,6 +82,7 @@ private:
         CPPUNIT_TEST( AddToExistingRoot );
         CPPUNIT_TEST( ReadNonExistent );
         CPPUNIT_TEST( ReadEmpty );
+        CPPUNIT_TEST( ReadFloat );
     CPPUNIT_TEST_SUITE_END();
 
     void Path();
@@ -94,6 +95,7 @@ private:
     void Save();
     void DeleteEntry();
     void DeleteAndWriteEntry();
+    void DeleteLastRootEntry();
     void DeleteGroup();
     void DeleteAll();
     void RenameEntry();
@@ -105,6 +107,7 @@ private:
     void AddToExistingRoot();
     void ReadNonExistent();
     void ReadEmpty();
+    void ReadFloat();
 
 
     static wxString ChangePath(wxFileConfig& fc, const wxChar *path)
@@ -129,7 +132,7 @@ private:
 // register in the unnamed registry so that these tests are run by default
 CPPUNIT_TEST_SUITE_REGISTRATION( FileConfigTestCase );
 
-// 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( FileConfigTestCase, "FileConfigTestCase" );
 
 void FileConfigTestCase::Path()
@@ -374,6 +377,24 @@ void FileConfigTestCase::DeleteAndWriteEntry()
     wxVERIFY_FILECONFIG( "", fc );
 }
 
+void FileConfigTestCase::DeleteLastRootEntry()
+{
+    // This tests for the bug which occurred when the last entry of the root
+    // group was deleted: this corrupted internal state and resulted in a crash
+    // after trying to write the just deleted entry again.
+    wxStringInputStream sis("");
+    wxFileConfig fc(sis);
+
+    fc.Write("key", "value");
+    wxVERIFY_FILECONFIG( "key=value\n", fc );
+
+    fc.DeleteEntry("key");
+    wxVERIFY_FILECONFIG( "", fc );
+
+    fc.Write("key", "value");
+    wxVERIFY_FILECONFIG( "key=value\n", fc );
+}
+
 void FileConfigTestCase::DeleteGroup()
 {
     wxStringInputStream sis(testconfig);
@@ -659,5 +680,24 @@ void FileConfigTestCase::ReadEmpty()
     wxFileConfig fc(sis);
 }
 
+void FileConfigTestCase::ReadFloat()
+{
+    static const char *confTest =
+        "x=1.234\n"
+        "y=-9876.5432\n"
+        "z=2e+308\n"
+    ;
+
+    wxStringInputStream sis(confTest);
+    wxFileConfig fc(sis);
+
+    float f;
+    CPPUNIT_ASSERT( fc.Read("x", &f) );
+    CPPUNIT_ASSERT_EQUAL( 1.234f, f );
+
+    CPPUNIT_ASSERT( fc.Read("y", &f) );
+    CPPUNIT_ASSERT_EQUAL( -9876.5432f, f );
+}
+
 #endif // wxUSE_FILECONFIG