X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e1a2c7a527cd76a97fcb949d597484af18f2fe8f..08e8a24d33774667342ff103b87e73f1aa6e356b:/tests/fileconf/fileconftest.cpp diff --git a/tests/fileconf/fileconftest.cpp b/tests/fileconf/fileconftest.cpp index 942fdada9d..fa10884e15 100644 --- a/tests/fileconf/fileconftest.cpp +++ b/tests/fileconf/fileconftest.cpp @@ -309,7 +309,8 @@ void FileConfigTestCase::DeleteGroup() _T("[root/group2]\n"), fc ); - CPPUNIT_ASSERT( fc.DeleteGroup(_T("root/group2")) ); + // notice trailing slash: it should be ignored + CPPUNIT_ASSERT( fc.DeleteGroup(_T("root/group2/")) ); wxVERIFY_FILECONFIG( _T("[root]\n") _T("entry=value\n"), fc ); @@ -372,6 +373,76 @@ void FileConfigTestCase::RenameGroup() _T("subentry2=subvalue2\n") _T("[foot/group2]\n"), fc ); + + // renaming a path doesn't work, it must be the immediate group + CPPUNIT_ASSERT( !fc.RenameGroup(_T("foot/group1"), _T("group2")) ); + + + fc.SetPath(_T("foot")); + + // renaming to a name of existing group doesn't work + CPPUNIT_ASSERT( !fc.RenameGroup(_T("group1"), _T("group2")) ); + + // try exchanging the groups names and then restore them back + CPPUNIT_ASSERT( fc.RenameGroup(_T("group1"), _T("groupTmp")) ); + wxVERIFY_FILECONFIG( _T("[foot]\n") + _T("entry=value\n") + _T("[foot/groupTmp]\n") + _T("[foot/groupTmp/subgroup]\n") + _T("subentry=subvalue\n") + _T("subentry2=subvalue2\n") + _T("[foot/group2]\n"), + fc ); + + CPPUNIT_ASSERT( fc.RenameGroup(_T("group2"), _T("group1")) ); + wxVERIFY_FILECONFIG( _T("[foot]\n") + _T("entry=value\n") + _T("[foot/groupTmp]\n") + _T("[foot/groupTmp/subgroup]\n") + _T("subentry=subvalue\n") + _T("subentry2=subvalue2\n") + _T("[foot/group1]\n"), + fc ); + + CPPUNIT_ASSERT( fc.RenameGroup(_T("groupTmp"), _T("group2")) ); + wxVERIFY_FILECONFIG( _T("[foot]\n") + _T("entry=value\n") + _T("[foot/group2]\n") + _T("[foot/group2/subgroup]\n") + _T("subentry=subvalue\n") + _T("subentry2=subvalue2\n") + _T("[foot/group1]\n"), + fc ); + + CPPUNIT_ASSERT( fc.RenameGroup(_T("group1"), _T("groupTmp")) ); + wxVERIFY_FILECONFIG( _T("[foot]\n") + _T("entry=value\n") + _T("[foot/group2]\n") + _T("[foot/group2/subgroup]\n") + _T("subentry=subvalue\n") + _T("subentry2=subvalue2\n") + _T("[foot/groupTmp]\n"), + fc ); + + CPPUNIT_ASSERT( fc.RenameGroup(_T("group2"), _T("group1")) ); + wxVERIFY_FILECONFIG( _T("[foot]\n") + _T("entry=value\n") + _T("[foot/group1]\n") + _T("[foot/group1/subgroup]\n") + _T("subentry=subvalue\n") + _T("subentry2=subvalue2\n") + _T("[foot/groupTmp]\n"), + fc ); + + CPPUNIT_ASSERT( fc.RenameGroup(_T("groupTmp"), _T("group2")) ); + wxVERIFY_FILECONFIG( _T("[foot]\n") + _T("entry=value\n") + _T("[foot/group1]\n") + _T("[foot/group1/subgroup]\n") + _T("subentry=subvalue\n") + _T("subentry2=subvalue2\n") + _T("[foot/group2]\n"), + fc ); } void FileConfigTestCase::CreateSubgroupAndEntries()