diff --git a/xmltest.cpp b/xmltest.cpp index 91a5626..276c61b 100644 --- a/xmltest.cpp +++ b/xmltest.cpp @@ -435,10 +435,10 @@ int main( int argc, const char ** argv ) XMLTest( "Programmatic DOM", true, doc->FirstChildElement()->FirstChildElement()->BoolAttribute( "attrib" ) ); int value1 = 10; int value2 = doc->FirstChildElement()->LastChildElement()->IntAttribute( "attrib", 10 ); - int result = doc->FirstChildElement()->LastChildElement()->QueryIntAttribute( "attrib", &value1 ); - XMLTest( "Programmatic DOM", result, (int)XML_NO_ATTRIBUTE ); - XMLTest( "Programmatic DOM", value1, 10 ); - XMLTest( "Programmatic DOM", value2, 10 ); + XMLError result = doc->FirstChildElement()->LastChildElement()->QueryIntAttribute( "attrib", &value1 ); + XMLTest( "Programmatic DOM", XML_NO_ATTRIBUTE, result ); + XMLTest( "Programmatic DOM", 10, value1 ); + XMLTest( "Programmatic DOM", 10, value2 ); doc->Print(); @@ -499,7 +499,7 @@ int main( int argc, const char ** argv ) XMLDocument doc; doc.Parse( error ); - XMLTest( "Bad XML", doc.ErrorID(), XML_ERROR_PARSING_ATTRIBUTE ); + XMLTest( "Bad XML", XML_ERROR_PARSING_ATTRIBUTE, doc.ErrorID() ); } { @@ -510,30 +510,31 @@ int main( int argc, const char ** argv ) XMLElement* ele = doc.FirstChildElement(); - int iVal, result; + int iVal; + XMLError result; double dVal; result = ele->QueryDoubleAttribute( "attr0", &dVal ); - XMLTest( "Query attribute: int as double", result, (int)XML_SUCCESS); - XMLTest( "Query attribute: int as double", (int)dVal, 1 ); - XMLTest( "Query attribute: int as double", (int)ele->DoubleAttribute("attr0"), 1); + XMLTest( "Query attribute: int as double", XML_SUCCESS, result); + XMLTest( "Query attribute: int as double", 1, (int)dVal ); + XMLTest( "Query attribute: int as double", 1, (int)ele->DoubleAttribute("attr0")); result = ele->QueryDoubleAttribute( "attr1", &dVal ); - XMLTest( "Query attribute: double as double", result, (int)XML_SUCCESS); - XMLTest( "Query attribute: double as double", dVal, 2.0 ); - XMLTest( "Query attribute: double as double", ele->DoubleAttribute("attr1"), 2.0 ); + XMLTest( "Query attribute: double as double", XML_SUCCESS, result); + XMLTest( "Query attribute: double as double", 2.0, dVal ); + XMLTest( "Query attribute: double as double", 2.0, ele->DoubleAttribute("attr1") ); result = ele->QueryIntAttribute( "attr1", &iVal ); - XMLTest( "Query attribute: double as int", result, (int)XML_SUCCESS); - XMLTest( "Query attribute: double as int", iVal, 2 ); + XMLTest( "Query attribute: double as int", XML_SUCCESS, result); + XMLTest( "Query attribute: double as int", 2, iVal ); result = ele->QueryIntAttribute( "attr2", &iVal ); - XMLTest( "Query attribute: not a number", result, (int)XML_WRONG_ATTRIBUTE_TYPE ); - XMLTest( "Query attribute: not a number", ele->DoubleAttribute("attr2", 4.0), 4.0 ); + XMLTest( "Query attribute: not a number", XML_WRONG_ATTRIBUTE_TYPE, result ); + XMLTest( "Query attribute: not a number", 4.0, ele->DoubleAttribute("attr2", 4.0) ); result = ele->QueryIntAttribute( "bar", &iVal ); - XMLTest( "Query attribute: does not exist", result, (int)XML_NO_ATTRIBUTE ); - XMLTest( "Query attribute: does not exist", ele->BoolAttribute("bar", true), true ); + XMLTest( "Query attribute: does not exist", XML_NO_ATTRIBUTE, result ); + XMLTest( "Query attribute: does not exist", true, ele->BoolAttribute("bar", true) ); } { @@ -558,7 +559,7 @@ int main( int argc, const char ** argv ) ele->QueryAttribute( "int", &iVal2 ); ele->QueryAttribute( "double", &dVal2 ); - XMLTest( "Attribute match test", ele->Attribute( "str", "strValue" ), "strValue" ); + XMLTest( "Attribute match test", "strValue", ele->Attribute( "str", "strValue" ) ); XMLTest( "Attribute round trip. c-string.", "strValue", cStr ); XMLTest( "Attribute round trip. int.", 1, iVal ); XMLTest( "Attribute round trip. double.", -1, (int)dVal ); @@ -796,7 +797,7 @@ int main( int argc, const char ** argv ) { XMLDocument doc; doc.LoadFile("resources/printer.xml"); - XMLTest("XMLPrinter Stream mode: load", doc.ErrorID(), XML_SUCCESS, true); + XMLTest("XMLPrinter Stream mode: load", XML_SUCCESS, doc.ErrorID(), true); const XMLDocument& cdoc = doc; @@ -829,8 +830,8 @@ int main( int argc, const char ** argv ) doc.Parse( str ); doc.Print(); - XMLTest( "CDATA parse.", doc.FirstChildElement()->FirstChild()->Value(), - "I am > the rules!\n...since I make symbolic puns", + XMLTest( "CDATA parse.", "I am > the rules!\n...since I make symbolic puns", + doc.FirstChildElement()->FirstChild()->Value(), false ); } @@ -846,8 +847,9 @@ int main( int argc, const char ** argv ) doc.Parse( str ); doc.Print(); - XMLTest( "CDATA parse. [ tixml1:1480107 ]", doc.FirstChildElement()->FirstChild()->Value(), + XMLTest( "CDATA parse. [ tixml1:1480107 ]", "I am > the rules!\n...since I make symbolic puns", + doc.FirstChildElement()->FirstChild()->Value(), false ); } @@ -864,7 +866,7 @@ int main( int argc, const char ** argv ) XMLNode* childNode0 = parent->InsertEndChild( childText0 ); XMLNode* childNode1 = parent->InsertAfterChild( childNode0, childText1 ); - XMLTest( "Test InsertAfterChild on empty node. ", ( childNode1 == parent->LastChild() ), true ); + XMLTest( "Test InsertAfterChild on empty node. ", true, ( childNode1 == parent->LastChild() ) ); } { @@ -919,10 +921,11 @@ int main( int argc, const char ** argv ) XMLDocument doc( false ); doc.Parse( passages ); - XMLTest( "No entity parsing.", doc.FirstChildElement()->FirstChildElement()->Attribute( "context" ), - "Line 5 has "quotation marks" and 'apostrophe marks'." ); - XMLTest( "No entity parsing.", doc.FirstChildElement()->FirstChildElement()->FirstChild()->Value(), - "Crazy &ttk;" ); + XMLTest( "No entity parsing.", + "Line 5 has "quotation marks" and 'apostrophe marks'.", + doc.FirstChildElement()->FirstChildElement()->Attribute( "context" ) ); + XMLTest( "No entity parsing.", "Crazy &ttk;", + doc.FirstChildElement()->FirstChildElement()->FirstChild()->Value() ); doc.Print(); } @@ -931,9 +934,9 @@ int main( int argc, const char ** argv ) XMLDocument doc; doc.Parse( test ); - XMLTest( "dot in names", doc.Error(), false ); - XMLTest( "dot in names", doc.FirstChildElement()->Name(), "a.elem" ); - XMLTest( "dot in names", doc.FirstChildElement()->Attribute( "xmi.version" ), "2.0" ); + XMLTest( "dot in names", false, doc.Error() ); + XMLTest( "dot in names", "a.elem", doc.FirstChildElement()->Name() ); + XMLTest( "dot in names", "2.0", doc.FirstChildElement()->Attribute( "xmi.version" ) ); } { @@ -944,7 +947,7 @@ int main( int argc, const char ** argv ) XMLText* text = doc.FirstChildElement()->FirstChildElement()->FirstChild()->ToText(); XMLTest( "Entity with one digit.", - text->Value(), "1.1 Start easy ignore fin thickness\n", + "1.1 Start easy ignore fin thickness\n", text->Value(), false ); } @@ -1022,7 +1025,7 @@ int main( int argc, const char ** argv ) XMLDocument doc; doc.Parse( "" ); const char result[] = { 0x0e, 0 }; - XMLTest( "Low entities.", doc.FirstChildElement()->GetText(), result ); + XMLTest( "Low entities.", result, doc.FirstChildElement()->GetText() ); doc.Print(); } @@ -1030,18 +1033,18 @@ int main( int argc, const char ** argv ) // Attribute values with trailing quotes not handled correctly XMLDocument doc; doc.Parse( "" ); - XMLTest( "Throw error with bad end quotes.", doc.Error(), true ); + XMLTest( "Throw error with bad end quotes.", true, doc.Error() ); } { // [ 1663758 ] Failure to report error on bad XML XMLDocument xml; xml.Parse(""); - XMLTest("Missing end tag at end of input", xml.Error(), true); + XMLTest("Missing end tag at end of input", true, xml.Error()); xml.Parse(" "); - XMLTest("Missing end tag with trailing whitespace", xml.Error(), true); + XMLTest("Missing end tag with trailing whitespace", true, xml.Error()); xml.Parse(""); - XMLTest("Mismatched tags", xml.ErrorID(), XML_ERROR_MISMATCHED_ELEMENT); + XMLTest("Mismatched tags", XML_ERROR_MISMATCHED_ELEMENT, xml.ErrorID() ); } @@ -1286,7 +1289,7 @@ int main( int argc, const char ** argv ) doc.Parse( xml ); XMLElement* ele = XMLHandle( doc ).FirstChildElement( "element" ).FirstChild().ToElement(); - XMLTest( "Handle, success, mutable", ele->Value(), "sub" ); + XMLTest( "Handle, success, mutable", "sub", ele->Value() ); XMLHandle docH( doc ); ele = docH.FirstChildElement( "none" ).FirstChildElement( "element" ).ToElement(); @@ -1315,8 +1318,8 @@ int main( int argc, const char ** argv ) doc.Print( &printer ); static const char* result = "\xef\xbb\xbf"; - XMLTest( "BOM and default declaration", printer.CStr(), result, false ); - XMLTest( "CStrSize", printer.CStrSize(), 42, false ); + XMLTest( "BOM and default declaration", result, printer.CStr(), false ); + XMLTest( "CStrSize", 42, printer.CStrSize(), false ); } { const char* xml = "FirstChildElement("property"); p; p = p->NextSiblingElement("property")) { nProperty++; } - XMLTest("Crash bug parsing", nProperty, 2); + XMLTest("Crash bug parsing", 2, nProperty); } // ----------- Line Number Tracking --------------