Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
37bc3aca42 | ||
|
|
8c9e3133c4 | ||
|
|
563ee82093 | ||
|
|
4ee9ebdfd2 | ||
|
|
a4f48c1167 | ||
|
|
9832a5f05d | ||
|
|
48d45b29a9 | ||
|
|
5381145957 | ||
|
|
a5ab98a582 | ||
|
|
369f306b37 | ||
|
|
8bba8b41d6 | ||
|
|
3f169ac424 | ||
|
|
86be0cdfe5 | ||
|
|
aea64c4b75 | ||
|
|
dfcf5488ea |
@@ -12,4 +12,4 @@ before_script: cmake .
|
||||
|
||||
script:
|
||||
- make -j3
|
||||
- ./xmltest
|
||||
- make test
|
||||
|
||||
@@ -13,6 +13,7 @@ endif()
|
||||
|
||||
project(tinyxml2)
|
||||
include(GNUInstallDirs)
|
||||
include(CTest)
|
||||
#enable_testing()
|
||||
|
||||
#CMAKE_BUILD_TOOL
|
||||
@@ -20,8 +21,8 @@ include(GNUInstallDirs)
|
||||
################################
|
||||
# set lib version here
|
||||
|
||||
set(GENERIC_LIB_VERSION "4.0.1")
|
||||
set(GENERIC_LIB_SOVERSION "4")
|
||||
set(GENERIC_LIB_VERSION "5.0.1")
|
||||
set(GENERIC_LIB_SOVERSION "5")
|
||||
|
||||
################################
|
||||
# Add definitions
|
||||
@@ -39,7 +40,7 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
|
||||
|
||||
option(BUILD_SHARED_LIBS "build as shared library" ON)
|
||||
option(BUILD_STATIC_LIBS "build as static library" OFF)
|
||||
option(BUILD_TESTS "build xmltest" ON)
|
||||
option(BUILD_TESTS "build xmltest (deprecated: Use BUILD_TESTING)" ON)
|
||||
|
||||
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
|
||||
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
|
||||
@@ -91,7 +92,7 @@ set_target_properties(tinyxml2_static PROPERTIES
|
||||
SOVERSION "${GENERIC_LIB_SOVERSION}")
|
||||
set_target_properties( tinyxml2_static PROPERTIES OUTPUT_NAME tinyxml2 )
|
||||
|
||||
target_compile_definitions(tinyxml2 PUBLIC -D_CRT_SECURE_NO_WARNINGS)
|
||||
target_compile_definitions(tinyxml2_static PUBLIC -D_CRT_SECURE_NO_WARNINGS)
|
||||
|
||||
if(DEFINED CMAKE_VERSION AND NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11")
|
||||
target_include_directories(tinyxml2_static PUBLIC
|
||||
@@ -99,7 +100,7 @@ if(DEFINED CMAKE_VERSION AND NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11")
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include>)
|
||||
|
||||
if(MSVC)
|
||||
target_compile_definitions(tinyxml2 PUBLIC -D_CRT_SECURE_NO_WARNINGS)
|
||||
target_compile_definitions(tinyxml2_static PUBLIC -D_CRT_SECURE_NO_WARNINGS)
|
||||
endif(MSVC)
|
||||
else()
|
||||
include_directories(${PROJECT_SOURCE_DIR})
|
||||
@@ -120,7 +121,7 @@ install(TARGETS tinyxml2_static
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
|
||||
if(BUILD_TESTS)
|
||||
if(BUILD_TESTING AND BUILD_TESTS)
|
||||
add_executable(xmltest xmltest.cpp)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
add_dependencies(xmltest tinyxml2)
|
||||
@@ -136,6 +137,8 @@ if(BUILD_TESTS)
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:xmltest>/resources/out
|
||||
COMMENT "Configuring xmltest resources directory: ${CMAKE_BINARY_DIR}/resources"
|
||||
)
|
||||
|
||||
add_test(NAME xmltest COMMAND xmltest)
|
||||
endif()
|
||||
|
||||
install(FILES tinyxml2.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
@@ -151,13 +154,15 @@ configure_file(tinyxml2.pc.in tinyxml2.pc @ONLY)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tinyxml2.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||
|
||||
# uninstall target
|
||||
configure_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
||||
IMMEDIATE @ONLY)
|
||||
if(NOT TARGET uninstall)
|
||||
configure_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
||||
IMMEDIATE @ONLY)
|
||||
|
||||
add_custom_target(uninstall
|
||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
||||
add_custom_target(uninstall
|
||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
||||
endif()
|
||||
|
||||
file(WRITE
|
||||
${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake
|
||||
@@ -168,4 +173,4 @@ install(FILES
|
||||
DESTINATION lib/cmake/${CMAKE_PROJECT_NAME})
|
||||
|
||||
install(EXPORT ${CMAKE_PROJECT_NAME}Targets
|
||||
DESTINATION lib/cmake/${CMAKE_PROJECT_NAME})
|
||||
DESTINATION lib/cmake/${CMAKE_PROJECT_NAME})
|
||||
|
||||
2
dox
2
dox
@@ -38,7 +38,7 @@ PROJECT_NAME = "TinyXML-2"
|
||||
# could be handy for archiving the generated documentation or if some version
|
||||
# control system is used.
|
||||
|
||||
PROJECT_NUMBER = 4.0.1
|
||||
PROJECT_NUMBER = 5.0.1
|
||||
|
||||
# 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
|
||||
|
||||
14
tinyxml2.cpp
14
tinyxml2.cpp
@@ -1966,10 +1966,10 @@ const char* XMLDocument::_errorNames[XML_ERROR_COUNT] = {
|
||||
"XML_ERROR_FILE_NOT_FOUND",
|
||||
"XML_ERROR_FILE_COULD_NOT_BE_OPENED",
|
||||
"XML_ERROR_FILE_READ_ERROR",
|
||||
"XML_ERROR_ELEMENT_MISMATCH",
|
||||
"UNUSED_XML_ERROR_ELEMENT_MISMATCH",
|
||||
"XML_ERROR_PARSING_ELEMENT",
|
||||
"XML_ERROR_PARSING_ATTRIBUTE",
|
||||
"XML_ERROR_IDENTIFYING_TAG",
|
||||
"UNUSED_XML_ERROR_IDENTIFYING_TAG",
|
||||
"XML_ERROR_PARSING_TEXT",
|
||||
"XML_ERROR_PARSING_CDATA",
|
||||
"XML_ERROR_PARSING_COMMENT",
|
||||
@@ -2308,6 +2308,16 @@ void XMLDocument::SetError( XMLError error, const char* str1, const char* str2,
|
||||
return errorName;
|
||||
}
|
||||
|
||||
const char* XMLDocument::GetErrorStr1() const
|
||||
{
|
||||
return _errorStr1.GetStr();
|
||||
}
|
||||
|
||||
const char* XMLDocument::GetErrorStr2() const
|
||||
{
|
||||
return _errorStr2.GetStr();
|
||||
}
|
||||
|
||||
const char* XMLDocument::ErrorName() const
|
||||
{
|
||||
return ErrorIDToName(_errorID);
|
||||
|
||||
16
tinyxml2.h
16
tinyxml2.h
@@ -98,7 +98,7 @@ distribution.
|
||||
/* Versioning, past 1.0.14:
|
||||
http://semver.org/
|
||||
*/
|
||||
static const int TIXML2_MAJOR_VERSION = 4;
|
||||
static const int TIXML2_MAJOR_VERSION = 5;
|
||||
static const int TIXML2_MINOR_VERSION = 0;
|
||||
static const int TIXML2_PATCH_VERSION = 1;
|
||||
|
||||
@@ -513,10 +513,10 @@ enum XMLError {
|
||||
XML_ERROR_FILE_NOT_FOUND,
|
||||
XML_ERROR_FILE_COULD_NOT_BE_OPENED,
|
||||
XML_ERROR_FILE_READ_ERROR,
|
||||
XML_ERROR_ELEMENT_MISMATCH,
|
||||
UNUSED_XML_ERROR_ELEMENT_MISMATCH, // remove at next major version
|
||||
XML_ERROR_PARSING_ELEMENT,
|
||||
XML_ERROR_PARSING_ATTRIBUTE,
|
||||
XML_ERROR_IDENTIFYING_TAG,
|
||||
UNUSED_XML_ERROR_IDENTIFYING_TAG, // remove at next major version
|
||||
XML_ERROR_PARSING_TEXT,
|
||||
XML_ERROR_PARSING_CDATA,
|
||||
XML_ERROR_PARSING_COMMENT,
|
||||
@@ -1803,13 +1803,11 @@ public:
|
||||
static const char* ErrorIDToName(XMLError errorID);
|
||||
|
||||
/// Return a possibly helpful diagnostic location or string.
|
||||
const char* GetErrorStr1() const {
|
||||
return _errorStr1.GetStr();
|
||||
}
|
||||
const char* GetErrorStr1() const;
|
||||
|
||||
/// Return a possibly helpful secondary diagnostic location or string.
|
||||
const char* GetErrorStr2() const {
|
||||
return _errorStr2.GetStr();
|
||||
}
|
||||
const char* GetErrorStr2() const;
|
||||
|
||||
/// Return the line where the error occured, or zero if unknown.
|
||||
int GetErrorLineNum() const
|
||||
{
|
||||
|
||||
125
xmltest.cpp
125
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 ]",
|
||||
"<b>I am > the rules!</b>\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( "<test></test>" );
|
||||
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( "<foo attribute=bar\" />" );
|
||||
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("<x>");
|
||||
XMLTest("Missing end tag at end of input", xml.Error(), true);
|
||||
XMLTest("Missing end tag at end of input", true, xml.Error());
|
||||
xml.Parse("<x> ");
|
||||
XMLTest("Missing end tag with trailing whitespace", xml.Error(), true);
|
||||
XMLTest("Missing end tag with trailing whitespace", true, xml.Error());
|
||||
xml.Parse("<x></y>");
|
||||
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<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
|
||||
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 = "<ipxml ws='1'><info bla=' /></ipxml>";
|
||||
@@ -1346,50 +1349,50 @@ int main( int argc, const char ** argv )
|
||||
pointElement->FirstChildElement( "valid" )->QueryBoolText( &boolValue );
|
||||
|
||||
|
||||
XMLTest( "QueryIntText", intValue, 1, false );
|
||||
XMLTest( "QueryUnsignedText", unsignedValue, (unsigned)1, false );
|
||||
XMLTest( "QueryFloatText", floatValue, 1.2f, false );
|
||||
XMLTest( "QueryDoubleText", doubleValue, 1.2, false );
|
||||
XMLTest( "QueryBoolText", boolValue, true, false );
|
||||
XMLTest( "QueryIntText", 1, intValue, false );
|
||||
XMLTest( "QueryUnsignedText", (unsigned)1, unsignedValue, false );
|
||||
XMLTest( "QueryFloatText", 1.2f, floatValue, false );
|
||||
XMLTest( "QueryDoubleText", 1.2, doubleValue, false );
|
||||
XMLTest( "QueryBoolText", true, boolValue, false );
|
||||
}
|
||||
|
||||
{
|
||||
const char* xml = "<element><_sub/><:sub/><sub:sub/><sub-sub/></element>";
|
||||
XMLDocument doc;
|
||||
doc.Parse( xml );
|
||||
XMLTest( "Non-alpha element lead letter parses.", doc.Error(), false );
|
||||
XMLTest( "Non-alpha element lead letter parses.", false, doc.Error() );
|
||||
}
|
||||
|
||||
{
|
||||
const char* xml = "<element _attr1=\"foo\" :attr2=\"bar\"></element>";
|
||||
XMLDocument doc;
|
||||
doc.Parse( xml );
|
||||
XMLTest("Non-alpha attribute lead character parses.", doc.Error(), false);
|
||||
XMLTest("Non-alpha attribute lead character parses.", false, doc.Error());
|
||||
}
|
||||
|
||||
{
|
||||
const char* xml = "<3lement></3lement>";
|
||||
XMLDocument doc;
|
||||
doc.Parse( xml );
|
||||
XMLTest("Element names with lead digit fail to parse.", doc.Error(), true);
|
||||
XMLTest("Element names with lead digit fail to parse.", true, doc.Error());
|
||||
}
|
||||
|
||||
{
|
||||
const char* xml = "<element/>WOA THIS ISN'T GOING TO PARSE";
|
||||
XMLDocument doc;
|
||||
doc.Parse( xml, 10 );
|
||||
XMLTest( "Set length of incoming data", doc.Error(), false );
|
||||
XMLTest( "Set length of incoming data", false, doc.Error() );
|
||||
}
|
||||
|
||||
{
|
||||
XMLDocument doc;
|
||||
XMLTest( "Document is initially empty", doc.NoChildren(), true );
|
||||
XMLTest( "Document is initially empty", true, doc.NoChildren() );
|
||||
doc.Clear();
|
||||
XMLTest( "Empty is empty after Clear()", doc.NoChildren(), true );
|
||||
XMLTest( "Empty is empty after Clear()", true, doc.NoChildren() );
|
||||
doc.LoadFile( "resources/dream.xml" );
|
||||
XMLTest( "Document has something to Clear()", doc.NoChildren(), false );
|
||||
XMLTest( "Document has something to Clear()", false, doc.NoChildren() );
|
||||
doc.Clear();
|
||||
XMLTest( "Document Clear()'s", doc.NoChildren(), true );
|
||||
XMLTest( "Document Clear()'s", true, doc.NoChildren() );
|
||||
}
|
||||
|
||||
// ----------- Whitespace ------------
|
||||
@@ -1693,15 +1696,15 @@ int main( int argc, const char ** argv )
|
||||
|
||||
XMLDocument doc;
|
||||
doc.Parse(xml0);
|
||||
XMLTest("Test that the code changes do not affect normal parsing", doc.Error(), false);
|
||||
XMLTest("Test that the code changes do not affect normal parsing", false, doc.Error() );
|
||||
doc.Parse(xml1);
|
||||
XMLTest("Test that the second declaration is allowed", doc.Error(), false);
|
||||
XMLTest("Test that the second declaration is allowed", false, doc.Error() );
|
||||
doc.Parse(xml2);
|
||||
XMLTest("Test that declaration after a child is not allowed", doc.ErrorID(), XML_ERROR_PARSING_DECLARATION);
|
||||
XMLTest("Test that declaration after a child is not allowed", XML_ERROR_PARSING_DECLARATION, doc.ErrorID() );
|
||||
doc.Parse(xml3);
|
||||
XMLTest("Test that declaration after a child is not allowed", doc.ErrorID(), XML_ERROR_PARSING_DECLARATION);
|
||||
XMLTest("Test that declaration after a child is not allowed", XML_ERROR_PARSING_DECLARATION, doc.ErrorID() );
|
||||
doc.Parse(xml4);
|
||||
XMLTest("Test that declaration inside a child is not allowed", doc.ErrorID(), XML_ERROR_PARSING_DECLARATION);
|
||||
XMLTest("Test that declaration inside a child is not allowed", XML_ERROR_PARSING_DECLARATION, doc.ErrorID() );
|
||||
}
|
||||
|
||||
{
|
||||
@@ -1774,9 +1777,9 @@ int main( int argc, const char ** argv )
|
||||
// an interesting test case.
|
||||
XMLDocument doc;
|
||||
XMLError err = doc.Parse(xml);
|
||||
XMLElement* playlist = doc.FirstChildElement("playlist");
|
||||
XMLTest("Crash bug parsing", XML_SUCCESS, err );
|
||||
|
||||
XMLTest("Crash bug parsing", err, XML_SUCCESS);
|
||||
XMLElement* playlist = doc.FirstChildElement("playlist");
|
||||
XMLTest("Crash bug parsing", true, playlist != 0);
|
||||
|
||||
tinyxml2::XMLElement* entry = playlist->FirstChildElement("entry");
|
||||
@@ -1803,7 +1806,7 @@ int main( int argc, const char ** argv )
|
||||
for (const XMLElement* p = playlist->FirstChildElement("property"); p; p = p->NextSiblingElement("property")) {
|
||||
nProperty++;
|
||||
}
|
||||
XMLTest("Crash bug parsing", nProperty, 2);
|
||||
XMLTest("Crash bug parsing", 2, nProperty);
|
||||
}
|
||||
|
||||
// ----------- Line Number Tracking --------------
|
||||
|
||||
Reference in New Issue
Block a user