]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/xml/xmltest.cpp
Somehow, setting a tint color makes gauge work :/.
[wxWidgets.git] / tests / xml / xmltest.cpp
index ee41451a3801f303005645784ce8040bab990a46..8a824e7e4aafacb41bf40f7c1e53d738f87a97fc 100644 (file)
@@ -3,7 +3,6 @@
 // Purpose:     XML classes unit test
 // Author:      Vaclav Slavik
 // Created:     2008-03-29
-// RCS-ID:      $Id$
 // Copyright:   (c) 2008 Vaclav Slavik
 ///////////////////////////////////////////////////////////////////////////////
 
@@ -82,6 +81,7 @@ private:
         CPPUNIT_TEST( DetachRoot );
         CPPUNIT_TEST( AppendToProlog );
         CPPUNIT_TEST( SetRoot );
+        CPPUNIT_TEST( CopyNode );
     CPPUNIT_TEST_SUITE_END();
 
     void InsertChild();
@@ -93,6 +93,7 @@ private:
     void DetachRoot();
     void AppendToProlog();
     void SetRoot();
+    void CopyNode();
 
     DECLARE_NO_COPY_CLASS(XmlTestCase)
 };
@@ -469,3 +470,40 @@ void XmlTestCase::SetRoot()
     doc.SetRoot(root);
     CPPUNIT_ASSERT( doc.IsOk() );
 }
+
+void XmlTestCase::CopyNode()
+{
+    const char *xmlText =
+"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+"<root>\n"
+"  <first><sub1/><sub2/><sub3/></first>\n"
+"  <second/>\n"
+"</root>\n"
+    ;
+    wxXmlDocument doc;
+    wxStringInputStream sis(xmlText);
+    CPPUNIT_ASSERT( doc.Load(sis) );
+
+    wxXmlNode* const root = doc.GetRoot();
+    CPPUNIT_ASSERT( root );
+
+    wxXmlNode* const first = root->GetChildren();
+    CPPUNIT_ASSERT( first );
+
+    wxXmlNode* const second = first->GetNext();
+    CPPUNIT_ASSERT( second );
+
+    *first = *second;
+
+    wxStringOutputStream sos;
+    CPPUNIT_ASSERT( doc.Save(sos) );
+
+    const char *xmlTextResult =
+"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+"<root>\n"
+"  <second/>\n"
+"  <second/>\n"
+"</root>\n"
+    ;
+    CPPUNIT_ASSERT_EQUAL( xmlTextResult, sos.GetString() );
+}