Show
Ignore:
Timestamp:
10/10/08 08:37:50 (3 months ago)
Author:
VZ
Message:

add a very simple test for Load/Save()

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • wxWidgets/trunk/tests/xml/xmltest.cpp

    r54696 r56212  
    2323 
    2424#include "wx/xml/xml.h" 
     25#include "wx/sstream.h" 
    2526 
    2627#include <stdarg.h> 
     
    7475        CPPUNIT_TEST( InsertChild ); 
    7576        CPPUNIT_TEST( InsertChildAfter ); 
     77        CPPUNIT_TEST( LoadSave ); 
    7678    CPPUNIT_TEST_SUITE_END(); 
    7779 
    7880    void InsertChild(); 
    7981    void InsertChildAfter(); 
     82    void LoadSave(); 
    8083 
    8184    DECLARE_NO_COPY_CLASS(XmlTestCase) 
     
    131134    CheckXml(root, "1", "A", "2", "B", "3", "C", NULL); 
    132135} 
     136 
     137void XmlTestCase::LoadSave() 
     138{ 
     139    // NB: this is not real XRC but rather some XRC-like XML fragment which 
     140    //     exercises different XML constructs to check that they're saved back 
     141    //     correctly 
     142    // 
     143    // Also note that there should be no blank lines here as they disappear 
     144    // after saving. 
     145    const char *xmlText = 
     146"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" 
     147"<resource xmlns=\"http://www.wxwidgets.org/wxxrc\" version=\"2.3.0.1\">\n" 
     148"  <object class=\"wxDialog\" name=\"my_dialog\">\n" 
     149"    <children>\n" 
     150"      <grandchild id=\"1\"/>\n" 
     151"    </children>\n" 
     152"    <subobject/>\n" 
     153"  </object>\n" 
     154"</resource>\n" 
     155    ; 
     156 
     157    wxStringInputStream sis(xmlText); 
     158 
     159    wxXmlDocument doc; 
     160    CPPUNIT_ASSERT( doc.Load(sis) ); 
     161 
     162    wxStringOutputStream sos; 
     163    CPPUNIT_ASSERT( doc.Save(sos) ); 
     164 
     165    CPPUNIT_ASSERT_EQUAL( xmlText, sos.GetString() ); 
     166} 
     167