]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/config/fileconf.cpp
added wxICON_NONE and implement support for it in wxGTK (closes #2897)
[wxWidgets.git] / tests / config / fileconf.cpp
index d3694190478543c84f83da72e89a9f74d1f357da..65e2e6fbaa6944bb96d66d4756ba8194c6bac9b0 100644 (file)
@@ -70,6 +70,7 @@ private:
         CPPUNIT_TEST( Binary );
         CPPUNIT_TEST( Save );
         CPPUNIT_TEST( DeleteEntry );
         CPPUNIT_TEST( Binary );
         CPPUNIT_TEST( Save );
         CPPUNIT_TEST( DeleteEntry );
+        CPPUNIT_TEST( DeleteAndWriteEntry );
         CPPUNIT_TEST( DeleteGroup );
         CPPUNIT_TEST( DeleteAll );
         CPPUNIT_TEST( RenameEntry );
         CPPUNIT_TEST( DeleteGroup );
         CPPUNIT_TEST( DeleteAll );
         CPPUNIT_TEST( RenameEntry );
@@ -78,6 +79,8 @@ private:
         CPPUNIT_TEST( CreateSubgroupAndEntries );
         CPPUNIT_TEST( DeleteLastGroup );
         CPPUNIT_TEST( DeleteAndRecreateGroup );
         CPPUNIT_TEST( CreateSubgroupAndEntries );
         CPPUNIT_TEST( DeleteLastGroup );
         CPPUNIT_TEST( DeleteAndRecreateGroup );
+        CPPUNIT_TEST( AddToExistingRoot );
+        CPPUNIT_TEST( ReadNonExistent );
     CPPUNIT_TEST_SUITE_END();
 
     void Path();
     CPPUNIT_TEST_SUITE_END();
 
     void Path();
@@ -89,6 +92,7 @@ private:
     void Binary();
     void Save();
     void DeleteEntry();
     void Binary();
     void Save();
     void DeleteEntry();
+    void DeleteAndWriteEntry();
     void DeleteGroup();
     void DeleteAll();
     void RenameEntry();
     void DeleteGroup();
     void DeleteAll();
     void RenameEntry();
@@ -97,6 +101,9 @@ private:
     void CreateSubgroupAndEntries();
     void DeleteLastGroup();
     void DeleteAndRecreateGroup();
     void CreateSubgroupAndEntries();
     void DeleteLastGroup();
     void DeleteAndRecreateGroup();
+    void AddToExistingRoot();
+    void ReadNonExistent();
+
 
     static wxString ChangePath(wxFileConfig& fc, const wxChar *path)
     {
 
     static wxString ChangePath(wxFileConfig& fc, const wxChar *path)
     {
@@ -324,6 +331,47 @@ void FileConfigTestCase::DeleteEntry()
                          fc );
 }
 
                          fc );
 }
 
+void FileConfigTestCase::DeleteAndWriteEntry()
+{
+    wxStringInputStream sis(
+            "[root/group1]\n"
+            "subentry=subvalue\n"
+            "subentry2=subvalue2\n"
+            "subentry3=subvalue3\n"
+    );
+
+    wxFileConfig fc(sis);
+
+    fc.DeleteEntry("/root/group1/subentry2");
+    fc.Write("/root/group1/subentry2", "testvalue");
+    fc.DeleteEntry("/root/group2/subentry2");
+    fc.Write("/root/group2/subentry2", "testvalue2");
+    fc.DeleteEntry("/root/group1/subentry2");
+    fc.Write("/root/group1/subentry2", "testvalue");
+    fc.DeleteEntry("/root/group2/subentry2");
+    fc.Write("/root/group2/subentry2", "testvalue2");
+
+    wxVERIFY_FILECONFIG( "[root/group1]\n"
+                         "subentry=subvalue\n"
+                         "subentry3=subvalue3\n"
+                         "subentry2=testvalue\n"
+                         "[root/group2]\n"
+                         "subentry2=testvalue2\n",
+                         fc );
+
+    fc.DeleteEntry("/root/group2/subentry2");
+    wxVERIFY_FILECONFIG( "[root/group1]\n"
+                         "subentry=subvalue\n"
+                         "subentry3=subvalue3\n"
+                         "subentry2=testvalue\n",
+                         fc );
+
+    fc.DeleteEntry("/root/group1/subentry2");
+    fc.DeleteEntry("/root/group1/subentry");
+    fc.DeleteEntry("/root/group1/subentry3");
+    wxVERIFY_FILECONFIG( "", fc );
+}
+
 void FileConfigTestCase::DeleteGroup()
 {
     wxStringInputStream sis(testconfig);
 void FileConfigTestCase::DeleteGroup()
 {
     wxStringInputStream sis(testconfig);
@@ -564,5 +612,42 @@ void FileConfigTestCase::DeleteAndRecreateGroup()
                          fc );
 }
 
                          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
+    );
+}
+
+void FileConfigTestCase::ReadNonExistent()
+{
+    static const char *confTest =
+        "community=censored\n"
+        "[City1]\n"
+        "URL=www.fake1.na\n"
+        "[City1/A1]\n"
+        "[City1/A1/1]\n"
+        "IP=192.168.1.66\n"
+        "URL=www.fake2.na\n"
+    ;
+
+    wxStringInputStream sis(confTest);
+    wxFileConfig fc(sis);
+
+    wxString url;
+    CPPUNIT_ASSERT( !fc.Read("URL", &url) );
+}
+
 #endif // wxUSE_FILECONFIG
 
 #endif // wxUSE_FILECONFIG