Check result of LoadFile()/SaveFile()

This commit is contained in:
Dmitry-Me 2017-07-10 17:54:24 +03:00
parent 3a6e51a12f
commit 46b70ce517
1 changed files with 10 additions and 0 deletions

View File

@ -471,7 +471,9 @@ int main( int argc, const char ** argv )
XMLTest( "Compact mode", "<element><sub attrib=\"true\"/><sub/></element>", streamer.CStr(), false ); XMLTest( "Compact mode", "<element><sub attrib=\"true\"/><sub/></element>", streamer.CStr(), false );
} }
doc->SaveFile( "./resources/out/pretty.xml" ); doc->SaveFile( "./resources/out/pretty.xml" );
XMLTest( "Save pretty.xml", false, doc->Error() );
doc->SaveFile( "./resources/out/compact.xml", true ); doc->SaveFile( "./resources/out/compact.xml", true );
XMLTest( "Save compact.xml", false, doc->Error() );
delete doc; delete doc;
} }
{ {
@ -481,8 +483,10 @@ int main( int argc, const char ** argv )
//int newStart = gNew; //int newStart = gNew;
XMLDocument doc; XMLDocument doc;
doc.LoadFile( "resources/dream.xml" ); doc.LoadFile( "resources/dream.xml" );
XMLTest( "Load dream.xml", false, doc.Error() );
doc.SaveFile( "resources/out/dreamout.xml" ); doc.SaveFile( "resources/out/dreamout.xml" );
XMLTest( "Save dreamout.xml", false, doc.Error() );
doc.PrintError(); doc.PrintError();
XMLTest( "Dream", "xml version=\"1.0\"", XMLTest( "Dream", "xml version=\"1.0\"",
@ -497,6 +501,7 @@ int main( int argc, const char ** argv )
XMLDocument doc2; XMLDocument doc2;
doc2.LoadFile( "resources/out/dreamout.xml" ); doc2.LoadFile( "resources/out/dreamout.xml" );
XMLTest( "Load dreamout.xml", false, doc2.Error() );
XMLTest( "Dream-out", "xml version=\"1.0\"", XMLTest( "Dream-out", "xml version=\"1.0\"",
doc2.FirstChild()->ToDeclaration()->Value() ); doc2.FirstChild()->ToDeclaration()->Value() );
XMLTest( "Dream-out", true, doc2.FirstChild()->NextSibling()->ToUnknown() ? true : false ); XMLTest( "Dream-out", true, doc2.FirstChild()->NextSibling()->ToUnknown() ? true : false );
@ -592,6 +597,7 @@ int main( int argc, const char ** argv )
{ {
XMLDocument doc; XMLDocument doc;
doc.LoadFile( "resources/utf8test.xml" ); doc.LoadFile( "resources/utf8test.xml" );
XMLTest( "Load utf8test.xml", false, doc.Error() );
// Get the attribute "value" from the "Russian" element and check it. // Get the attribute "value" from the "Russian" element and check it.
XMLElement* element = doc.FirstChildElement( "document" )->FirstChildElement( "Russian" ); XMLElement* element = doc.FirstChildElement( "document" )->FirstChildElement( "Russian" );
@ -613,6 +619,7 @@ int main( int argc, const char ** argv )
// Now try for a round trip. // Now try for a round trip.
doc.SaveFile( "resources/out/utf8testout.xml" ); doc.SaveFile( "resources/out/utf8testout.xml" );
XMLTest( "UTF-8: Save testout.xml", false, doc.Error() );
// Check the round trip. // Check the round trip.
int okay = 0; int okay = 0;
@ -1442,6 +1449,7 @@ int main( int argc, const char ** argv )
doc.Clear(); doc.Clear();
XMLTest( "Empty is empty after Clear()", true, doc.NoChildren() ); XMLTest( "Empty is empty after Clear()", true, doc.NoChildren() );
doc.LoadFile( "resources/dream.xml" ); doc.LoadFile( "resources/dream.xml" );
XMLTest( "Load dream.xml", false, doc.Error() );
XMLTest( "Document has something to Clear()", false, doc.NoChildren() ); XMLTest( "Document has something to Clear()", false, doc.NoChildren() );
doc.Clear(); doc.Clear();
XMLTest( "Document Clear()'s", true, doc.NoChildren() ); XMLTest( "Document Clear()'s", true, doc.NoChildren() );
@ -1531,10 +1539,12 @@ int main( int argc, const char ** argv )
XMLTest( "BOM preservation (compare)", xml_bom_preservation, printer.CStr(), false, true ); XMLTest( "BOM preservation (compare)", xml_bom_preservation, printer.CStr(), false, true );
doc.SaveFile( "resources/bomtest.xml" ); doc.SaveFile( "resources/bomtest.xml" );
XMLTest( "Save bomtest.xml", false, doc.Error() );
} }
{ {
XMLDocument doc; XMLDocument doc;
doc.LoadFile( "resources/bomtest.xml" ); doc.LoadFile( "resources/bomtest.xml" );
XMLTest( "Load bomtest.xml", false, doc.Error() );
XMLTest( "BOM preservation (load)", true, doc.HasBOM(), false ); XMLTest( "BOM preservation (load)", true, doc.HasBOM(), false );
XMLPrinter printer; XMLPrinter printer;