X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ca7766b4e51b97913b074ddbc2ba2e7730068c7f..faa112c4ca49e1f1d9467107d6e54cb9986bd900:/tests/fileconf/fileconftest.cpp diff --git a/tests/fileconf/fileconftest.cpp b/tests/fileconf/fileconftest.cpp index c26cf1428f..9b75d89bc9 100644 --- a/tests/fileconf/fileconftest.cpp +++ b/tests/fileconf/fileconftest.cpp @@ -59,6 +59,8 @@ private: CPPUNIT_TEST( DeleteAll ); CPPUNIT_TEST( RenameEntry ); CPPUNIT_TEST( RenameGroup ); + CPPUNIT_TEST( CreateEntriesAndSubgroup ); + CPPUNIT_TEST( CreateSubgroupAndEntries ); CPPUNIT_TEST( DeleteLastGroup ); CPPUNIT_TEST_SUITE_END(); @@ -74,6 +76,8 @@ private: void DeleteAll(); void RenameEntry(); void RenameGroup(); + void CreateEntriesAndSubgroup(); + void CreateSubgroupAndEntries(); void DeleteLastGroup(); static wxString ChangePath(wxFileConfig& fc, const wxChar *path) @@ -243,10 +247,11 @@ void FileConfigTestCase::HasGroup() CPPUNIT_ASSERT( fc.HasGroup(_T("root/group1")) ); CPPUNIT_ASSERT( fc.HasGroup(_T("root/group1/subgroup")) ); CPPUNIT_ASSERT( fc.HasGroup(_T("root/group2")) ); - CPPUNIT_ASSERT( !fc.HasGroup(_T("foot")) ); CPPUNIT_ASSERT( !fc.HasGroup(_T("")) ); CPPUNIT_ASSERT( !fc.HasGroup(_T("root/group")) ); CPPUNIT_ASSERT( !fc.HasGroup(_T("root//subgroup")) ); + CPPUNIT_ASSERT( !fc.HasGroup(_T("foot/subgroup")) ); + CPPUNIT_ASSERT( !fc.HasGroup(_T("foot")) ); } void FileConfigTestCase::Save() @@ -353,6 +358,29 @@ void FileConfigTestCase::RenameGroup() _T("[foot/group2]\n") ); } +void FileConfigTestCase::CreateSubgroupAndEntries() +{ + wxFileConfig fc; + fc.Write(_T("sub/sub_first"), _T("sub_one")); + fc.Write(_T("first"), _T("one")); + + CPPUNIT_ASSERT( Dump(fc) == _T("first=one\n") + _T("[sub]\n") + _T("sub_first=sub_one\n")); +} + +void FileConfigTestCase::CreateEntriesAndSubgroup() +{ + wxFileConfig fc; + fc.Write(_T("first"), _T("one")); + fc.Write(_T("second"), _T("two")); + fc.Write(_T("sub/sub_first"), _T("sub_one")); + + CPPUNIT_ASSERT( Dump(fc) == _T("first=one\n") + _T("second=two\n") + _T("[sub]\n") + _T("sub_first=sub_one\n")); +} static void EmptyConfigAndWriteKey() { @@ -360,7 +388,7 @@ static void EmptyConfigAndWriteKey() const wxString groupPath = _T("/root"); - if (fc.Exists(groupPath)) + if ( fc.Exists(groupPath) ) { // using DeleteGroup exposes the problem, using DeleteAll doesn't CPPUNIT_ASSERT( fc.DeleteGroup(groupPath) ); @@ -392,8 +420,7 @@ void FileConfigTestCase::DeleteLastGroup() // clean up wxLogNull noLogging; - (void) ::wxRemoveFile( - wxFileConfig::GetLocalFileName(_T("deleteconftest")) ); + (void) ::wxRemoveFile(wxFileConfig::GetLocalFileName(_T("deleteconftest"))); } #endif // wxUSE_FILECONFIG