X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a08711325b69ca25ca9236857bd32abba648aad8..a5655d37db9baabce654849fd66173f95f74e230:/tests/xml/xmltest.cpp
diff --git a/tests/xml/xmltest.cpp b/tests/xml/xmltest.cpp
index 6d7faeb3c8..79ca9ee3c6 100644
--- a/tests/xml/xmltest.cpp
+++ b/tests/xml/xmltest.cpp
@@ -75,11 +75,15 @@ private:
CPPUNIT_TEST( InsertChild );
CPPUNIT_TEST( InsertChildAfter );
CPPUNIT_TEST( LoadSave );
+ CPPUNIT_TEST( CDATA );
+ CPPUNIT_TEST( Escaping );
CPPUNIT_TEST_SUITE_END();
void InsertChild();
void InsertChildAfter();
void LoadSave();
+ void CDATA();
+ void Escaping();
DECLARE_NO_COPY_CLASS(XmlTestCase)
};
@@ -189,3 +193,50 @@ void XmlTestCase::LoadSave()
wxString(sos8.GetString().ToUTF8()) );
}
+void XmlTestCase::CDATA()
+{
+ const char *xmlText =
+ "\n"
+ "\n"
+ " \n"
+ "\n"
+ ;
+
+ wxStringInputStream sis(xmlText);
+ wxXmlDocument doc;
+ CPPUNIT_ASSERT( doc.Load(sis) );
+
+ wxXmlNode *n = doc.GetRoot();
+ CPPUNIT_ASSERT( n );
+
+ n = n->GetChildren();
+ CPPUNIT_ASSERT( n );
+
+ // check that both leading (" ") and trailing white space is not part of
+ // the node contents when CDATA is used and wxXMLDOC_KEEP_WHITESPACE_NODES
+ // is not
+ CPPUNIT_ASSERT_EQUAL( "Giovanni Mittone", n->GetContent() );
+}
+
+void XmlTestCase::Escaping()
+{
+ // Verify that attribute values are escaped correctly, see
+ // http://trac.wxwidgets.org/ticket/12275
+
+ const char *xmlText =
+"\n"
+"\n"
+" \n"
+"\n"
+ ;
+
+ wxStringInputStream sis(xmlText);
+
+ wxXmlDocument doc;
+ CPPUNIT_ASSERT( doc.Load(sis) );
+
+ wxStringOutputStream sos;
+ CPPUNIT_ASSERT( doc.Save(sos) );
+
+ CPPUNIT_ASSERT_EQUAL( xmlText, sos.GetString() );
+}