1 Commits
5.0.1 ... 5.0.0

Author SHA1 Message Date
Lee Thomason
81b2194462 setting the version to 5.0.0 2017-06-19 14:39:49 -07:00
6 changed files with 86 additions and 102 deletions

View File

@@ -12,4 +12,4 @@ before_script: cmake .
script: script:
- make -j3 - make -j3
- make test - ./xmltest

View File

@@ -13,7 +13,6 @@ endif()
project(tinyxml2) project(tinyxml2)
include(GNUInstallDirs) include(GNUInstallDirs)
include(CTest)
#enable_testing() #enable_testing()
#CMAKE_BUILD_TOOL #CMAKE_BUILD_TOOL
@@ -21,7 +20,7 @@ include(CTest)
################################ ################################
# set lib version here # set lib version here
set(GENERIC_LIB_VERSION "5.0.1") set(GENERIC_LIB_VERSION "5.0.0")
set(GENERIC_LIB_SOVERSION "5") set(GENERIC_LIB_SOVERSION "5")
################################ ################################
@@ -40,7 +39,7 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
option(BUILD_SHARED_LIBS "build as shared library" ON) option(BUILD_SHARED_LIBS "build as shared library" ON)
option(BUILD_STATIC_LIBS "build as static library" OFF) option(BUILD_STATIC_LIBS "build as static library" OFF)
option(BUILD_TESTS "build xmltest (deprecated: Use BUILD_TESTING)" ON) option(BUILD_TESTS "build xmltest" ON)
set(CMAKE_CXX_VISIBILITY_PRESET hidden) set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
@@ -92,7 +91,7 @@ set_target_properties(tinyxml2_static PROPERTIES
SOVERSION "${GENERIC_LIB_SOVERSION}") SOVERSION "${GENERIC_LIB_SOVERSION}")
set_target_properties( tinyxml2_static PROPERTIES OUTPUT_NAME tinyxml2 ) set_target_properties( tinyxml2_static PROPERTIES OUTPUT_NAME tinyxml2 )
target_compile_definitions(tinyxml2_static PUBLIC -D_CRT_SECURE_NO_WARNINGS) target_compile_definitions(tinyxml2 PUBLIC -D_CRT_SECURE_NO_WARNINGS)
if(DEFINED CMAKE_VERSION AND NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11") if(DEFINED CMAKE_VERSION AND NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11")
target_include_directories(tinyxml2_static PUBLIC target_include_directories(tinyxml2_static PUBLIC
@@ -100,7 +99,7 @@ if(DEFINED CMAKE_VERSION AND NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11")
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include>) $<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include>)
if(MSVC) if(MSVC)
target_compile_definitions(tinyxml2_static PUBLIC -D_CRT_SECURE_NO_WARNINGS) target_compile_definitions(tinyxml2 PUBLIC -D_CRT_SECURE_NO_WARNINGS)
endif(MSVC) endif(MSVC)
else() else()
include_directories(${PROJECT_SOURCE_DIR}) include_directories(${PROJECT_SOURCE_DIR})
@@ -121,7 +120,7 @@ install(TARGETS tinyxml2_static
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif() endif()
if(BUILD_TESTING AND BUILD_TESTS) if(BUILD_TESTS)
add_executable(xmltest xmltest.cpp) add_executable(xmltest xmltest.cpp)
if(BUILD_SHARED_LIBS) if(BUILD_SHARED_LIBS)
add_dependencies(xmltest tinyxml2) add_dependencies(xmltest tinyxml2)
@@ -137,8 +136,6 @@ if(BUILD_TESTING AND BUILD_TESTS)
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:xmltest>/resources/out COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:xmltest>/resources/out
COMMENT "Configuring xmltest resources directory: ${CMAKE_BINARY_DIR}/resources" COMMENT "Configuring xmltest resources directory: ${CMAKE_BINARY_DIR}/resources"
) )
add_test(NAME xmltest COMMAND xmltest)
endif() endif()
install(FILES tinyxml2.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) install(FILES tinyxml2.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
@@ -154,15 +151,13 @@ configure_file(tinyxml2.pc.in tinyxml2.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tinyxml2.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tinyxml2.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
# uninstall target # uninstall target
if(NOT TARGET uninstall) configure_file(
configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY)
IMMEDIATE @ONLY)
add_custom_target(uninstall add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
endif()
file(WRITE file(WRITE
${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake
@@ -173,4 +168,4 @@ install(FILES
DESTINATION lib/cmake/${CMAKE_PROJECT_NAME}) DESTINATION lib/cmake/${CMAKE_PROJECT_NAME})
install(EXPORT ${CMAKE_PROJECT_NAME}Targets install(EXPORT ${CMAKE_PROJECT_NAME}Targets
DESTINATION lib/cmake/${CMAKE_PROJECT_NAME}) DESTINATION lib/cmake/${CMAKE_PROJECT_NAME})

2
dox
View File

@@ -38,7 +38,7 @@ PROJECT_NAME = "TinyXML-2"
# could be handy for archiving the generated documentation or if some version # could be handy for archiving the generated documentation or if some version
# control system is used. # control system is used.
PROJECT_NUMBER = 5.0.1 PROJECT_NUMBER = 5.0.0
# Using the PROJECT_BRIEF tag one can provide an optional one line description # Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a # for a project that appears at the top of each page and should give viewer a

View File

@@ -1966,10 +1966,10 @@ const char* XMLDocument::_errorNames[XML_ERROR_COUNT] = {
"XML_ERROR_FILE_NOT_FOUND", "XML_ERROR_FILE_NOT_FOUND",
"XML_ERROR_FILE_COULD_NOT_BE_OPENED", "XML_ERROR_FILE_COULD_NOT_BE_OPENED",
"XML_ERROR_FILE_READ_ERROR", "XML_ERROR_FILE_READ_ERROR",
"UNUSED_XML_ERROR_ELEMENT_MISMATCH", "XML_ERROR_ELEMENT_MISMATCH",
"XML_ERROR_PARSING_ELEMENT", "XML_ERROR_PARSING_ELEMENT",
"XML_ERROR_PARSING_ATTRIBUTE", "XML_ERROR_PARSING_ATTRIBUTE",
"UNUSED_XML_ERROR_IDENTIFYING_TAG", "XML_ERROR_IDENTIFYING_TAG",
"XML_ERROR_PARSING_TEXT", "XML_ERROR_PARSING_TEXT",
"XML_ERROR_PARSING_CDATA", "XML_ERROR_PARSING_CDATA",
"XML_ERROR_PARSING_COMMENT", "XML_ERROR_PARSING_COMMENT",
@@ -2308,16 +2308,6 @@ void XMLDocument::SetError( XMLError error, const char* str1, const char* str2,
return errorName; return errorName;
} }
const char* XMLDocument::GetErrorStr1() const
{
return _errorStr1.GetStr();
}
const char* XMLDocument::GetErrorStr2() const
{
return _errorStr2.GetStr();
}
const char* XMLDocument::ErrorName() const const char* XMLDocument::ErrorName() const
{ {
return ErrorIDToName(_errorID); return ErrorIDToName(_errorID);

View File

@@ -100,7 +100,7 @@ distribution.
*/ */
static const int TIXML2_MAJOR_VERSION = 5; static const int TIXML2_MAJOR_VERSION = 5;
static const int TIXML2_MINOR_VERSION = 0; static const int TIXML2_MINOR_VERSION = 0;
static const int TIXML2_PATCH_VERSION = 1; static const int TIXML2_PATCH_VERSION = 0;
namespace tinyxml2 namespace tinyxml2
{ {
@@ -513,10 +513,10 @@ enum XMLError {
XML_ERROR_FILE_NOT_FOUND, XML_ERROR_FILE_NOT_FOUND,
XML_ERROR_FILE_COULD_NOT_BE_OPENED, XML_ERROR_FILE_COULD_NOT_BE_OPENED,
XML_ERROR_FILE_READ_ERROR, XML_ERROR_FILE_READ_ERROR,
UNUSED_XML_ERROR_ELEMENT_MISMATCH, // remove at next major version XML_ERROR_ELEMENT_MISMATCH,
XML_ERROR_PARSING_ELEMENT, XML_ERROR_PARSING_ELEMENT,
XML_ERROR_PARSING_ATTRIBUTE, XML_ERROR_PARSING_ATTRIBUTE,
UNUSED_XML_ERROR_IDENTIFYING_TAG, // remove at next major version XML_ERROR_IDENTIFYING_TAG,
XML_ERROR_PARSING_TEXT, XML_ERROR_PARSING_TEXT,
XML_ERROR_PARSING_CDATA, XML_ERROR_PARSING_CDATA,
XML_ERROR_PARSING_COMMENT, XML_ERROR_PARSING_COMMENT,
@@ -1803,11 +1803,13 @@ public:
static const char* ErrorIDToName(XMLError errorID); static const char* ErrorIDToName(XMLError errorID);
/// Return a possibly helpful diagnostic location or string. /// Return a possibly helpful diagnostic location or string.
const char* GetErrorStr1() const; const char* GetErrorStr1() const {
return _errorStr1.GetStr();
}
/// Return a possibly helpful secondary diagnostic location or string. /// Return a possibly helpful secondary diagnostic location or string.
const char* GetErrorStr2() const; const char* GetErrorStr2() const {
return _errorStr2.GetStr();
}
/// Return the line where the error occured, or zero if unknown. /// Return the line where the error occured, or zero if unknown.
int GetErrorLineNum() const int GetErrorLineNum() const
{ {

View File

@@ -435,10 +435,10 @@ int main( int argc, const char ** argv )
XMLTest( "Programmatic DOM", true, doc->FirstChildElement()->FirstChildElement()->BoolAttribute( "attrib" ) ); XMLTest( "Programmatic DOM", true, doc->FirstChildElement()->FirstChildElement()->BoolAttribute( "attrib" ) );
int value1 = 10; int value1 = 10;
int value2 = doc->FirstChildElement()->LastChildElement()->IntAttribute( "attrib", 10 ); int value2 = doc->FirstChildElement()->LastChildElement()->IntAttribute( "attrib", 10 );
XMLError result = doc->FirstChildElement()->LastChildElement()->QueryIntAttribute( "attrib", &value1 ); int result = doc->FirstChildElement()->LastChildElement()->QueryIntAttribute( "attrib", &value1 );
XMLTest( "Programmatic DOM", XML_NO_ATTRIBUTE, result ); XMLTest( "Programmatic DOM", result, (int)XML_NO_ATTRIBUTE );
XMLTest( "Programmatic DOM", 10, value1 ); XMLTest( "Programmatic DOM", value1, 10 );
XMLTest( "Programmatic DOM", 10, value2 ); XMLTest( "Programmatic DOM", value2, 10 );
doc->Print(); doc->Print();
@@ -499,7 +499,7 @@ int main( int argc, const char ** argv )
XMLDocument doc; XMLDocument doc;
doc.Parse( error ); doc.Parse( error );
XMLTest( "Bad XML", XML_ERROR_PARSING_ATTRIBUTE, doc.ErrorID() ); XMLTest( "Bad XML", doc.ErrorID(), XML_ERROR_PARSING_ATTRIBUTE );
} }
{ {
@@ -510,31 +510,30 @@ int main( int argc, const char ** argv )
XMLElement* ele = doc.FirstChildElement(); XMLElement* ele = doc.FirstChildElement();
int iVal; int iVal, result;
XMLError result;
double dVal; double dVal;
result = ele->QueryDoubleAttribute( "attr0", &dVal ); result = ele->QueryDoubleAttribute( "attr0", &dVal );
XMLTest( "Query attribute: int as double", XML_SUCCESS, result); XMLTest( "Query attribute: int as double", result, (int)XML_SUCCESS);
XMLTest( "Query attribute: int as double", 1, (int)dVal ); XMLTest( "Query attribute: int as double", (int)dVal, 1 );
XMLTest( "Query attribute: int as double", 1, (int)ele->DoubleAttribute("attr0")); XMLTest( "Query attribute: int as double", (int)ele->DoubleAttribute("attr0"), 1);
result = ele->QueryDoubleAttribute( "attr1", &dVal ); result = ele->QueryDoubleAttribute( "attr1", &dVal );
XMLTest( "Query attribute: double as double", XML_SUCCESS, result); XMLTest( "Query attribute: double as double", result, (int)XML_SUCCESS);
XMLTest( "Query attribute: double as double", 2.0, dVal ); XMLTest( "Query attribute: double as double", dVal, 2.0 );
XMLTest( "Query attribute: double as double", 2.0, ele->DoubleAttribute("attr1") ); XMLTest( "Query attribute: double as double", ele->DoubleAttribute("attr1"), 2.0 );
result = ele->QueryIntAttribute( "attr1", &iVal ); result = ele->QueryIntAttribute( "attr1", &iVal );
XMLTest( "Query attribute: double as int", XML_SUCCESS, result); XMLTest( "Query attribute: double as int", result, (int)XML_SUCCESS);
XMLTest( "Query attribute: double as int", 2, iVal ); XMLTest( "Query attribute: double as int", iVal, 2 );
result = ele->QueryIntAttribute( "attr2", &iVal ); result = ele->QueryIntAttribute( "attr2", &iVal );
XMLTest( "Query attribute: not a number", XML_WRONG_ATTRIBUTE_TYPE, result ); XMLTest( "Query attribute: not a number", result, (int)XML_WRONG_ATTRIBUTE_TYPE );
XMLTest( "Query attribute: not a number", 4.0, ele->DoubleAttribute("attr2", 4.0) ); XMLTest( "Query attribute: not a number", ele->DoubleAttribute("attr2", 4.0), 4.0 );
result = ele->QueryIntAttribute( "bar", &iVal ); result = ele->QueryIntAttribute( "bar", &iVal );
XMLTest( "Query attribute: does not exist", XML_NO_ATTRIBUTE, result ); XMLTest( "Query attribute: does not exist", result, (int)XML_NO_ATTRIBUTE );
XMLTest( "Query attribute: does not exist", true, ele->BoolAttribute("bar", true) ); XMLTest( "Query attribute: does not exist", ele->BoolAttribute("bar", true), true );
} }
{ {
@@ -559,7 +558,7 @@ int main( int argc, const char ** argv )
ele->QueryAttribute( "int", &iVal2 ); ele->QueryAttribute( "int", &iVal2 );
ele->QueryAttribute( "double", &dVal2 ); ele->QueryAttribute( "double", &dVal2 );
XMLTest( "Attribute match test", "strValue", ele->Attribute( "str", "strValue" ) ); XMLTest( "Attribute match test", ele->Attribute( "str", "strValue" ), "strValue" );
XMLTest( "Attribute round trip. c-string.", "strValue", cStr ); XMLTest( "Attribute round trip. c-string.", "strValue", cStr );
XMLTest( "Attribute round trip. int.", 1, iVal ); XMLTest( "Attribute round trip. int.", 1, iVal );
XMLTest( "Attribute round trip. double.", -1, (int)dVal ); XMLTest( "Attribute round trip. double.", -1, (int)dVal );
@@ -797,7 +796,7 @@ int main( int argc, const char ** argv )
{ {
XMLDocument doc; XMLDocument doc;
doc.LoadFile("resources/printer.xml"); doc.LoadFile("resources/printer.xml");
XMLTest("XMLPrinter Stream mode: load", XML_SUCCESS, doc.ErrorID(), true); XMLTest("XMLPrinter Stream mode: load", doc.ErrorID(), XML_SUCCESS, true);
const XMLDocument& cdoc = doc; const XMLDocument& cdoc = doc;
@@ -830,8 +829,8 @@ int main( int argc, const char ** argv )
doc.Parse( str ); doc.Parse( str );
doc.Print(); doc.Print();
XMLTest( "CDATA parse.", "I am > the rules!\n...since I make symbolic puns", XMLTest( "CDATA parse.", doc.FirstChildElement()->FirstChild()->Value(),
doc.FirstChildElement()->FirstChild()->Value(), "I am > the rules!\n...since I make symbolic puns",
false ); false );
} }
@@ -847,9 +846,8 @@ int main( int argc, const char ** argv )
doc.Parse( str ); doc.Parse( str );
doc.Print(); doc.Print();
XMLTest( "CDATA parse. [ tixml1:1480107 ]", XMLTest( "CDATA parse. [ tixml1:1480107 ]", doc.FirstChildElement()->FirstChild()->Value(),
"<b>I am > the rules!</b>\n...since I make symbolic puns", "<b>I am > the rules!</b>\n...since I make symbolic puns",
doc.FirstChildElement()->FirstChild()->Value(),
false ); false );
} }
@@ -866,7 +864,7 @@ int main( int argc, const char ** argv )
XMLNode* childNode0 = parent->InsertEndChild( childText0 ); XMLNode* childNode0 = parent->InsertEndChild( childText0 );
XMLNode* childNode1 = parent->InsertAfterChild( childNode0, childText1 ); XMLNode* childNode1 = parent->InsertAfterChild( childNode0, childText1 );
XMLTest( "Test InsertAfterChild on empty node. ", true, ( childNode1 == parent->LastChild() ) ); XMLTest( "Test InsertAfterChild on empty node. ", ( childNode1 == parent->LastChild() ), true );
} }
{ {
@@ -921,11 +919,10 @@ int main( int argc, const char ** argv )
XMLDocument doc( false ); XMLDocument doc( false );
doc.Parse( passages ); doc.Parse( passages );
XMLTest( "No entity parsing.", XMLTest( "No entity parsing.", doc.FirstChildElement()->FirstChildElement()->Attribute( "context" ),
"Line 5 has &quot;quotation marks&quot; and &apos;apostrophe marks&apos;.", "Line 5 has &quot;quotation marks&quot; and &apos;apostrophe marks&apos;." );
doc.FirstChildElement()->FirstChildElement()->Attribute( "context" ) ); XMLTest( "No entity parsing.", doc.FirstChildElement()->FirstChildElement()->FirstChild()->Value(),
XMLTest( "No entity parsing.", "Crazy &ttk;", "Crazy &ttk;" );
doc.FirstChildElement()->FirstChildElement()->FirstChild()->Value() );
doc.Print(); doc.Print();
} }
@@ -934,9 +931,9 @@ int main( int argc, const char ** argv )
XMLDocument doc; XMLDocument doc;
doc.Parse( test ); doc.Parse( test );
XMLTest( "dot in names", false, doc.Error() ); XMLTest( "dot in names", doc.Error(), false );
XMLTest( "dot in names", "a.elem", doc.FirstChildElement()->Name() ); XMLTest( "dot in names", doc.FirstChildElement()->Name(), "a.elem" );
XMLTest( "dot in names", "2.0", doc.FirstChildElement()->Attribute( "xmi.version" ) ); XMLTest( "dot in names", doc.FirstChildElement()->Attribute( "xmi.version" ), "2.0" );
} }
{ {
@@ -947,7 +944,7 @@ int main( int argc, const char ** argv )
XMLText* text = doc.FirstChildElement()->FirstChildElement()->FirstChild()->ToText(); XMLText* text = doc.FirstChildElement()->FirstChildElement()->FirstChild()->ToText();
XMLTest( "Entity with one digit.", XMLTest( "Entity with one digit.",
"1.1 Start easy ignore fin thickness\n", text->Value(), text->Value(), "1.1 Start easy ignore fin thickness\n",
false ); false );
} }
@@ -1025,7 +1022,7 @@ int main( int argc, const char ** argv )
XMLDocument doc; XMLDocument doc;
doc.Parse( "<test>&#x0e;</test>" ); doc.Parse( "<test>&#x0e;</test>" );
const char result[] = { 0x0e, 0 }; const char result[] = { 0x0e, 0 };
XMLTest( "Low entities.", result, doc.FirstChildElement()->GetText() ); XMLTest( "Low entities.", doc.FirstChildElement()->GetText(), result );
doc.Print(); doc.Print();
} }
@@ -1033,18 +1030,18 @@ int main( int argc, const char ** argv )
// Attribute values with trailing quotes not handled correctly // Attribute values with trailing quotes not handled correctly
XMLDocument doc; XMLDocument doc;
doc.Parse( "<foo attribute=bar\" />" ); doc.Parse( "<foo attribute=bar\" />" );
XMLTest( "Throw error with bad end quotes.", true, doc.Error() ); XMLTest( "Throw error with bad end quotes.", doc.Error(), true );
} }
{ {
// [ 1663758 ] Failure to report error on bad XML // [ 1663758 ] Failure to report error on bad XML
XMLDocument xml; XMLDocument xml;
xml.Parse("<x>"); xml.Parse("<x>");
XMLTest("Missing end tag at end of input", true, xml.Error()); XMLTest("Missing end tag at end of input", xml.Error(), true);
xml.Parse("<x> "); xml.Parse("<x> ");
XMLTest("Missing end tag with trailing whitespace", true, xml.Error()); XMLTest("Missing end tag with trailing whitespace", xml.Error(), true);
xml.Parse("<x></y>"); xml.Parse("<x></y>");
XMLTest("Mismatched tags", XML_ERROR_MISMATCHED_ELEMENT, xml.ErrorID() ); XMLTest("Mismatched tags", xml.ErrorID(), XML_ERROR_MISMATCHED_ELEMENT);
} }
@@ -1289,7 +1286,7 @@ int main( int argc, const char ** argv )
doc.Parse( xml ); doc.Parse( xml );
XMLElement* ele = XMLHandle( doc ).FirstChildElement( "element" ).FirstChild().ToElement(); XMLElement* ele = XMLHandle( doc ).FirstChildElement( "element" ).FirstChild().ToElement();
XMLTest( "Handle, success, mutable", "sub", ele->Value() ); XMLTest( "Handle, success, mutable", ele->Value(), "sub" );
XMLHandle docH( doc ); XMLHandle docH( doc );
ele = docH.FirstChildElement( "none" ).FirstChildElement( "element" ).ToElement(); ele = docH.FirstChildElement( "none" ).FirstChildElement( "element" ).ToElement();
@@ -1318,8 +1315,8 @@ int main( int argc, const char ** argv )
doc.Print( &printer ); doc.Print( &printer );
static const char* result = "\xef\xbb\xbf<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; static const char* result = "\xef\xbb\xbf<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
XMLTest( "BOM and default declaration", result, printer.CStr(), false ); XMLTest( "BOM and default declaration", printer.CStr(), result, false );
XMLTest( "CStrSize", 42, printer.CStrSize(), false ); XMLTest( "CStrSize", printer.CStrSize(), 42, false );
} }
{ {
const char* xml = "<ipxml ws='1'><info bla=' /></ipxml>"; const char* xml = "<ipxml ws='1'><info bla=' /></ipxml>";
@@ -1349,50 +1346,50 @@ int main( int argc, const char ** argv )
pointElement->FirstChildElement( "valid" )->QueryBoolText( &boolValue ); pointElement->FirstChildElement( "valid" )->QueryBoolText( &boolValue );
XMLTest( "QueryIntText", 1, intValue, false ); XMLTest( "QueryIntText", intValue, 1, false );
XMLTest( "QueryUnsignedText", (unsigned)1, unsignedValue, false ); XMLTest( "QueryUnsignedText", unsignedValue, (unsigned)1, false );
XMLTest( "QueryFloatText", 1.2f, floatValue, false ); XMLTest( "QueryFloatText", floatValue, 1.2f, false );
XMLTest( "QueryDoubleText", 1.2, doubleValue, false ); XMLTest( "QueryDoubleText", doubleValue, 1.2, false );
XMLTest( "QueryBoolText", true, boolValue, false ); XMLTest( "QueryBoolText", boolValue, true, false );
} }
{ {
const char* xml = "<element><_sub/><:sub/><sub:sub/><sub-sub/></element>"; const char* xml = "<element><_sub/><:sub/><sub:sub/><sub-sub/></element>";
XMLDocument doc; XMLDocument doc;
doc.Parse( xml ); doc.Parse( xml );
XMLTest( "Non-alpha element lead letter parses.", false, doc.Error() ); XMLTest( "Non-alpha element lead letter parses.", doc.Error(), false );
} }
{ {
const char* xml = "<element _attr1=\"foo\" :attr2=\"bar\"></element>"; const char* xml = "<element _attr1=\"foo\" :attr2=\"bar\"></element>";
XMLDocument doc; XMLDocument doc;
doc.Parse( xml ); doc.Parse( xml );
XMLTest("Non-alpha attribute lead character parses.", false, doc.Error()); XMLTest("Non-alpha attribute lead character parses.", doc.Error(), false);
} }
{ {
const char* xml = "<3lement></3lement>"; const char* xml = "<3lement></3lement>";
XMLDocument doc; XMLDocument doc;
doc.Parse( xml ); doc.Parse( xml );
XMLTest("Element names with lead digit fail to parse.", true, doc.Error()); XMLTest("Element names with lead digit fail to parse.", doc.Error(), true);
} }
{ {
const char* xml = "<element/>WOA THIS ISN'T GOING TO PARSE"; const char* xml = "<element/>WOA THIS ISN'T GOING TO PARSE";
XMLDocument doc; XMLDocument doc;
doc.Parse( xml, 10 ); doc.Parse( xml, 10 );
XMLTest( "Set length of incoming data", false, doc.Error() ); XMLTest( "Set length of incoming data", doc.Error(), false );
} }
{ {
XMLDocument doc; XMLDocument doc;
XMLTest( "Document is initially empty", true, doc.NoChildren() ); XMLTest( "Document is initially empty", doc.NoChildren(), true );
doc.Clear(); doc.Clear();
XMLTest( "Empty is empty after Clear()", true, doc.NoChildren() ); XMLTest( "Empty is empty after Clear()", doc.NoChildren(), true );
doc.LoadFile( "resources/dream.xml" ); doc.LoadFile( "resources/dream.xml" );
XMLTest( "Document has something to Clear()", false, doc.NoChildren() ); XMLTest( "Document has something to Clear()", doc.NoChildren(), false );
doc.Clear(); doc.Clear();
XMLTest( "Document Clear()'s", true, doc.NoChildren() ); XMLTest( "Document Clear()'s", doc.NoChildren(), true );
} }
// ----------- Whitespace ------------ // ----------- Whitespace ------------
@@ -1696,15 +1693,15 @@ int main( int argc, const char ** argv )
XMLDocument doc; XMLDocument doc;
doc.Parse(xml0); doc.Parse(xml0);
XMLTest("Test that the code changes do not affect normal parsing", false, doc.Error() ); XMLTest("Test that the code changes do not affect normal parsing", doc.Error(), false);
doc.Parse(xml1); doc.Parse(xml1);
XMLTest("Test that the second declaration is allowed", false, doc.Error() ); XMLTest("Test that the second declaration is allowed", doc.Error(), false);
doc.Parse(xml2); doc.Parse(xml2);
XMLTest("Test that declaration after a child is not allowed", XML_ERROR_PARSING_DECLARATION, doc.ErrorID() ); XMLTest("Test that declaration after a child is not allowed", doc.ErrorID(), XML_ERROR_PARSING_DECLARATION);
doc.Parse(xml3); doc.Parse(xml3);
XMLTest("Test that declaration after a child is not allowed", XML_ERROR_PARSING_DECLARATION, doc.ErrorID() ); XMLTest("Test that declaration after a child is not allowed", doc.ErrorID(), XML_ERROR_PARSING_DECLARATION);
doc.Parse(xml4); doc.Parse(xml4);
XMLTest("Test that declaration inside a child is not allowed", XML_ERROR_PARSING_DECLARATION, doc.ErrorID() ); XMLTest("Test that declaration inside a child is not allowed", doc.ErrorID(), XML_ERROR_PARSING_DECLARATION);
} }
{ {
@@ -1777,9 +1774,9 @@ int main( int argc, const char ** argv )
// an interesting test case. // an interesting test case.
XMLDocument doc; XMLDocument doc;
XMLError err = doc.Parse(xml); XMLError err = doc.Parse(xml);
XMLTest("Crash bug parsing", XML_SUCCESS, err );
XMLElement* playlist = doc.FirstChildElement("playlist"); XMLElement* playlist = doc.FirstChildElement("playlist");
XMLTest("Crash bug parsing", err, XML_SUCCESS);
XMLTest("Crash bug parsing", true, playlist != 0); XMLTest("Crash bug parsing", true, playlist != 0);
tinyxml2::XMLElement* entry = playlist->FirstChildElement("entry"); tinyxml2::XMLElement* entry = playlist->FirstChildElement("entry");
@@ -1806,7 +1803,7 @@ int main( int argc, const char ** argv )
for (const XMLElement* p = playlist->FirstChildElement("property"); p; p = p->NextSiblingElement("property")) { for (const XMLElement* p = playlist->FirstChildElement("property"); p; p = p->NextSiblingElement("property")) {
nProperty++; nProperty++;
} }
XMLTest("Crash bug parsing", 2, nProperty); XMLTest("Crash bug parsing", nProperty, 2);
} }
// ----------- Line Number Tracking -------------- // ----------- Line Number Tracking --------------