// get the last line belonging to an entry/subgroup of this group
wxFileConfigLineList *GetGroupLine(); // line which contains [group]
+ // may be NULL for "/" only
wxFileConfigLineList *GetLastEntryLine(); // after which our subgroups start
wxFileConfigLineList *GetLastGroupLine(); // after which the next group starts
// add the line to linked list
if ( bLocal )
- {
LineListAppend(strLine);
- // let the root group have its start line as well
- if ( !n )
- {
- m_pCurrentGroup->SetLine(m_linesTail);
- }
- }
-
// skip leading spaces
for ( pStart = buf; wxIsspace(*pStart); pStart++ )
SetDirty();
- // this will add a line for this group if it didn't have it before
-
+ // this will add a line for this group if it didn't have it before (or
+ // do nothing for the root but it's ok as it always exists anyhow)
(void)m_pCurrentGroup->GetGroupLine();
}
else
CPPUNIT_TEST( CreateSubgroupAndEntries );
CPPUNIT_TEST( DeleteLastGroup );
CPPUNIT_TEST( DeleteAndRecreateGroup );
+ CPPUNIT_TEST( AddToExistingRoot );
CPPUNIT_TEST_SUITE_END();
void Path();
void CreateSubgroupAndEntries();
void DeleteLastGroup();
void DeleteAndRecreateGroup();
+ void AddToExistingRoot();
+
static wxString ChangePath(wxFileConfig& fc, const wxChar *path)
{
fc );
}
+void FileConfigTestCase::AddToExistingRoot()
+{
+ static const wxChar *confInitial =
+ _T("[Group]\n")
+ _T("value1=foo\n");
+
+ wxStringInputStream sis(confInitial);
+ wxFileConfig fc(sis);
+
+ fc.Write(_T("/value1"), _T("bar"));
+ wxVERIFY_FILECONFIG(
+ _T("value1=bar\n")
+ _T("[Group]\n")
+ _T("value1=foo\n"),
+ fc
+ );
+}
+
#endif // wxUSE_FILECONFIG