]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/config/fileconf.cpp
Don't set cell value in wxDataViewEvent in one place only.
[wxWidgets.git] / tests / config / fileconf.cpp
index b17185d68174be60efe91765ec2a1a77decba8ad..a92bdb6afe7d713f37b6d30800859fc39720d2fa 100644 (file)
@@ -71,6 +71,7 @@ private:
         CPPUNIT_TEST( Save );
         CPPUNIT_TEST( DeleteEntry );
         CPPUNIT_TEST( DeleteAndWriteEntry );
+        CPPUNIT_TEST( DeleteLastRootEntry );
         CPPUNIT_TEST( DeleteGroup );
         CPPUNIT_TEST( DeleteAll );
         CPPUNIT_TEST( RenameEntry );
@@ -95,6 +96,7 @@ private:
     void Save();
     void DeleteEntry();
     void DeleteAndWriteEntry();
+    void DeleteLastRootEntry();
     void DeleteGroup();
     void DeleteAll();
     void RenameEntry();
@@ -131,7 +133,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()
@@ -376,6 +378,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);