fix bug with not updating the last line correctly when a group was deleted and recreated (bug 1685312); added a unit test for this

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45557 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-04-21 15:04:52 +00:00
parent 11624aa059
commit 6ad0a7d52f
3 changed files with 31 additions and 1 deletions

View File

@@ -76,6 +76,7 @@ private:
CPPUNIT_TEST( CreateEntriesAndSubgroup );
CPPUNIT_TEST( CreateSubgroupAndEntries );
CPPUNIT_TEST( DeleteLastGroup );
CPPUNIT_TEST( DeleteAndRecreateGroup );
CPPUNIT_TEST_SUITE_END();
void Path();
@@ -93,6 +94,7 @@ private:
void CreateEntriesAndSubgroup();
void CreateSubgroupAndEntries();
void DeleteLastGroup();
void DeleteAndRecreateGroup();
static wxString ChangePath(wxFileConfig& fc, const wxChar *path)
{
@@ -512,5 +514,29 @@ void FileConfigTestCase::DeleteLastGroup()
(void) ::wxRemoveFile(wxFileConfig::GetLocalFileName(_T("deleteconftest")));
}
void FileConfigTestCase::DeleteAndRecreateGroup()
{
static const wxChar *confInitial =
_T("[First]\n")
_T("Value1=Foo\n")
_T("[Second]\n")
_T("Value2=Bar\n");
wxStringInputStream sis(confInitial);
wxFileConfig fc(sis);
fc.DeleteGroup(_T("Second"));
wxVERIFY_FILECONFIG( _T("[First]\n")
_T("Value1=Foo\n"),
fc );
fc.Write(_T("Second/Value2"), _T("New"));
wxVERIFY_FILECONFIG( _T("[First]\n")
_T("Value1=Foo\n")
_T("[Second]\n")
_T("Value2=New\n"),
fc );
}
#endif // wxUSE_FILECONFIG