X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e3778b4d9c7eebc39f496a9dd055638e06fb9140..5f9e369af0c834bbde0f7f5d2047abd736967f58:/tests/config/fileconf.cpp diff --git a/tests/config/fileconf.cpp b/tests/config/fileconf.cpp index 7a9c2d73f6..4e3d8aa42f 100644 --- a/tests/config/fileconf.cpp +++ b/tests/config/fileconf.cpp @@ -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 ); @@ -95,6 +95,7 @@ private: void Save(); void DeleteEntry(); void DeleteAndWriteEntry(); + void DeleteLastRootEntry(); void DeleteGroup(); void DeleteAll(); void RenameEntry(); @@ -376,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);