CPPUNIT_TEST( GetGroups );
CPPUNIT_TEST( HasEntry );
CPPUNIT_TEST( HasGroup );
+ CPPUNIT_TEST( Binary );
CPPUNIT_TEST( Save );
CPPUNIT_TEST( DeleteEntry );
CPPUNIT_TEST( DeleteGroup );
CPPUNIT_TEST( CreateEntriesAndSubgroup );
CPPUNIT_TEST( CreateSubgroupAndEntries );
CPPUNIT_TEST( DeleteLastGroup );
+ CPPUNIT_TEST( DeleteAndRecreateGroup );
CPPUNIT_TEST_SUITE_END();
void Path();
void GetGroups();
void HasEntry();
void HasGroup();
+ void Binary();
void Save();
void DeleteEntry();
void DeleteGroup();
void CreateEntriesAndSubgroup();
void CreateSubgroupAndEntries();
void DeleteLastGroup();
+ void DeleteAndRecreateGroup();
static wxString ChangePath(wxFileConfig& fc, const wxChar *path)
{
CPPUNIT_ASSERT( !fc.HasGroup(_T("foot")) );
}
+void FileConfigTestCase::Binary()
+{
+ wxStringInputStream sis(
+ "[root]\n"
+ "binary=Zm9vCg==\n"
+ );
+ wxFileConfig fc(sis);
+
+ wxMemoryBuffer buf;
+ fc.Read("/root/binary", &buf);
+
+ CPPUNIT_ASSERT( memcmp("foo\n", buf.GetData(), buf.GetDataLen()) == 0 );
+
+ buf.SetDataLen(0);
+ buf.AppendData("\0\1\2", 3);
+ fc.Write("/root/012", buf);
+ wxVERIFY_FILECONFIG(
+ "[root]\n"
+ "binary=Zm9vCg==\n"
+ "012=AAEC\n",
+ fc
+ );
+}
+
void FileConfigTestCase::Save()
{
wxStringInputStream sis(testconfig);
(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