23 #if defined( WIN32 ) && defined( TUNE ) 25 _CrtMemState startMemState;
26 _CrtMemState endMemState;
31 bool XmlTest (
const char* testString,
const char* expected,
const char* found,
bool noEcho =
false);
32 bool XmlTest(
const char* testString,
int expected,
int found,
bool noEcho =
false );
39 bool XmlTest (
const char* testString,
const char* expected,
const char* found,
bool noEcho )
41 bool pass = !strcmp( expected, found );
48 printf (
" %s\n", testString);
50 printf (
" %s [%s][%s]\n", testString, expected, found);
60 bool XmlTest(
const char* testString,
int expected,
int found,
bool noEcho )
62 bool pass = ( expected == found );
69 printf (
" %s\n", testString);
71 printf (
" %s [%d][%d]\n", testString, expected, found);
84 if ( *p ==
'\n' || *p ==
'\r' ) {
106 const char* demoStart =
107 "<?xml version=\"1.0\" standalone='no' >\n" 108 "<!-- Our to do list data -->" 110 "<!-- Do I need a secure PDA? -->\n" 111 "<Item priority=\"1\" distance='close'> Go to the <bold>Toy store!</bold></Item>" 112 "<Item priority=\"2\" distance='none'> Do bills </Item>" 113 "<Item priority=\"2\" distance='far & back'> Look for Evil Dinosaurs! </Item>" 121 const char* demoEnd =
122 "<?xml version=\"1.0\" standalone=\"no\" ?>" 123 "<!-- Our to do list data -->" 125 "<!-- Do I need a secure PDA? -->" 126 "<Item priority=\"2\" distance=\"close\">Go to the" 130 "<Item priority=\"1\" distance=\"far\">Talk to:" 131 "<Meeting where=\"School\">" 132 "<Attendee name=\"Marple\" position=\"teacher\" />" 133 "<Attendee name=\"Voel\" position=\"counselor\" />" 135 "<Meeting where=\"Lunch\" />" 137 "<Item priority=\"2\" distance=\"here\">Do bills" 143 #if defined( WIN32 ) && defined( TUNE ) 144 _CrtMemCheckpoint( &startMemState );
151 doc.
Parse( demoStart );
166 printf(
"Could not load test file 'demotest.xml'. Error='%s'. Exiting.\n", doc.
ErrorDesc() );
170 printf(
"** Demo doc read from disk: ** \n\n" );
171 printf(
"** Printing via doc.Print **\n" );
175 printf(
"** Printing via TiXmlPrinter **\n" );
178 fprintf( stdout,
"%s", printer.
CStr() );
182 printf(
"** Printing via operator<< **\n" );
201 assert( todoElement );
208 assert( itemElement );
214 assert( itemElement );
263 assert( itemElement );
267 printf(
"\n** Demo doc processed: ** \n\n" );
272 printf(
"** Demo doc processed to stream: ** \n\n" );
273 cout << doc << endl << endl;
286 cout <<
"** Basic structure. **\n";
287 ostringstream outputStream( ostringstream::out );
289 XmlTest(
"Output stream correct.",
string( demoEnd ).c_str(),
290 outputStream.str().c_str(), true );
293 node = doc.RootElement();
295 XmlTest(
"Root element exists.",
true, ( node != 0 && node->ToElement() ) );
296 XmlTest (
"Root element value is 'ToDo'.",
"ToDo", node->Value());
298 node = node->FirstChild();
299 XmlTest(
"First child exists & is a comment.",
true, ( node != 0 && node->ToComment() ) );
300 node = node->NextSibling();
301 XmlTest(
"Sibling element exists & is an element.",
true, ( node != 0 && node->ToElement() ) );
302 XmlTest (
"Value is 'Item'.",
"Item", node->Value() );
304 node = node->FirstChild();
305 XmlTest (
"First child exists.",
true, ( node != 0 && node->ToText() ) );
306 XmlTest (
"Value is 'Go to the'.",
"Go to the", node->Value() );
310 printf (
"\n** Iterators. **\n");
314 for( node = doc.FirstChild();
316 node = node->NextSibling() )
320 XmlTest(
"Top level nodes, using First / Next.", 3, count );
323 for( node = doc.LastChild();
325 node = node->PreviousSibling() )
329 XmlTest(
"Top level nodes, using Last / Previous.", 3, count );
334 for( node = doc.IterateChildren( 0 );
336 node = doc.IterateChildren( node ) )
340 XmlTest(
"Top level nodes, using IterateChildren.", 3, count );
350 XmlTest(
"Children of the 'ToDo' element, using First / Next.",
355 for( node = todoElement->
FirstChild(
"Item" );
361 XmlTest(
"'Item' children of the 'ToDo' element, using First/Next.", 3, count );
364 for( node = todoElement->
LastChild(
"Item" );
370 XmlTest(
"'Item' children of the 'ToDo' element, using Last/Previous.", 3, count );
374 cout <<
"\n** Parsing. **\n";
375 istringstream parse0(
"<Element0 attribute0='foo0' attribute1= noquotes attribute2 = '>' />" );
379 XmlTest (
"Element parsed, value is 'Element0'.",
"Element0", element0.Value() );
380 XmlTest (
"Reads attribute 'attribute0=\"foo0\"'.",
"foo0", element0.Attribute(
"attribute0" ));
381 XmlTest (
"Reads incorrectly formatted 'attribute1=noquotes'.",
"noquotes", element0.Attribute(
"attribute1" ) );
382 XmlTest (
"Read attribute with entity value '>'.",
">", element0.Attribute(
"attribute2" ) );
387 const char* error =
"<?xml version=\"1.0\" standalone=\"no\" ?>\n" 388 "<passages count=\"006\" formatversion=\"20020620\">\n" 393 docTest.
Parse( error );
403 cout <<
"\n** Streaming. **\n";
408 istringstream inputStringStream( outputStream.str() );
411 inputStringStream >> document0;
413 ostringstream outputStream0( ostringstream::out );
414 outputStream0 << document0;
416 XmlTest(
"Stream round trip correct.",
string( demoEnd ).c_str(),
417 outputStream0.str().c_str(), true );
422 XmlTest(
"String printing correct.",
string( demoEnd ).c_str(),
429 const char* str =
"<doc attr0='1' attr1='2.0' attr2='foo' />";
441 XmlTest(
"Query attribute: int as double", (
int)dVal, 1 );
443 XmlTest(
"Query attribute: double as double", (
int)dVal, 2 );
446 XmlTest(
"Query attribute: double as int", iVal, 2 );
454 const char* str =
"<doc/>";
468 const char* cStr = ele->
Attribute(
"str" );
472 XmlTest(
"Attribute round trip. c-string.",
"strValue", cStr );
473 XmlTest(
"Attribute round trip. int.", 1, iVal );
474 XmlTest(
"Attribute round trip. double.", -1, (
int)dVal );
478 const char* str =
"\t<?xml version=\"1.0\" standalone=\"no\" ?>\t<room doors='2'>\n" 488 assert( docHandle.
Node() );
489 assert( roomHandle.
Element() );
496 XmlTest(
"Location tracking: Tab 8: room row", room->Row(), 1 );
497 XmlTest(
"Location tracking: Tab 8: room col", room->Column(), 49 );
498 XmlTest(
"Location tracking: Tab 8: doors row", doors->
Row(), 1 );
499 XmlTest(
"Location tracking: Tab 8: doors col", doors->
Column(), 55 );
503 const char* str =
"\t<?xml version=\"1.0\" standalone=\"no\" ?>\t<room doors='2'>\n" 504 " <!-- Silly example -->\n" 505 " <door wall='north'>A great door!</door>\n" 506 "\t<door wall='east'/>" 519 assert( docHandle.
Node() );
520 assert( roomHandle.
Element() );
521 assert( commentHandle.
Node() );
522 assert( textHandle.
Text() );
523 assert( door0Handle.
Element() );
524 assert( door1Handle.
Element() );
527 assert( declaration );
538 XmlTest(
"Location tracking: Declaration row", declaration->Row(), 1 );
539 XmlTest(
"Location tracking: Declaration col", declaration->Column(), 5 );
540 XmlTest(
"Location tracking: room row", room->
Row(), 1 );
541 XmlTest(
"Location tracking: room col", room->
Column(), 45 );
542 XmlTest(
"Location tracking: doors row", doors->
Row(), 1 );
543 XmlTest(
"Location tracking: doors col", doors->
Column(), 51 );
544 XmlTest(
"Location tracking: Comment row", comment->
Row(), 2 );
545 XmlTest(
"Location tracking: Comment col", comment->
Column(), 3 );
546 XmlTest(
"Location tracking: text row", text->
Row(), 3 );
547 XmlTest(
"Location tracking: text col", text->
Column(), 24 );
548 XmlTest(
"Location tracking: door0 row", door0->
Row(), 3 );
549 XmlTest(
"Location tracking: door0 col", door0->
Column(), 5 );
550 XmlTest(
"Location tracking: door1 row", door1->
Row(), 4 );
551 XmlTest(
"Location tracking: door1 col", door1->
Column(), 5 );
561 printf (
"\n** UTF-8 **\n");
566 printf(
"WARNING: File 'utf8test.xml' not found.\n" 567 "(Are you running the test from the wrong directory?)\n" 568 "Could not test UTF-8 functionality.\n" );
575 const unsigned char correctValue[] = { 0xd1U, 0x86U, 0xd0U, 0xb5U, 0xd0U, 0xbdU, 0xd0U, 0xbdU,
576 0xd0U, 0xbeU, 0xd1U, 0x81U, 0xd1U, 0x82U, 0xd1U, 0x8cU, 0 };
578 XmlTest(
"UTF-8: Russian value.", (
const char*)correctValue, element->
Attribute(
"value" ), true );
579 XmlTest(
"UTF-8: Russian value row.", 4, element->
Row() );
580 XmlTest(
"UTF-8: Russian value column.", 5, element->
Column() );
582 const unsigned char russianElementName[] = { 0xd0U, 0xa0U, 0xd1U, 0x83U,
583 0xd1U, 0x81U, 0xd1U, 0x81U,
584 0xd0U, 0xbaU, 0xd0U, 0xb8U,
586 const char russianText[] =
"<\xD0\xB8\xD0\xBC\xD0\xB5\xD0\xB5\xD1\x82>";
589 XmlTest(
"UTF-8: Browsing russian element name.",
593 XmlTest(
"UTF-8: Russian element name row.", 7, text->
Row() );
594 XmlTest(
"UTF-8: Russian element name column.", 47, text->
Column() );
597 XmlTest(
"UTF-8: Declaration column.", 1, dec->Column() );
608 FILE* saved = fopen(
"utf8testout.xml",
"r" );
609 FILE* verify = fopen(
"utf8testverify.xml",
"r" );
612 if ( saved && verify )
614 while ( fgets( verifyBuf, 256, verify ) )
616 fgets( savedBuf, 256, saved );
620 if ( strcmp( verifyBuf, savedBuf ) )
622 printf(
"verify:%s<\n", verifyBuf );
623 printf(
"saved :%s<\n", savedBuf );
634 XmlTest(
"UTF-8: Verified multi-language round trip.", 1, okay );
640 const char latin[] =
"<element>r\x82sum\x82</element>";
646 XmlTest(
"Legacy encoding: Verify text element.",
"r\x82sum\x82", text->
Value() );
653 printf (
"\n** Copy and Assignment **\n");
661 elementAssign = element;
663 XmlTest(
"Copy/Assign: element copy #1.",
"element", elementCopy.
Value() );
664 XmlTest(
"Copy/Assign: element copy #2.",
"value", elementCopy.
Attribute(
"name" ) );
665 XmlTest(
"Copy/Assign: element assign #1.",
"element", elementAssign.
Value() );
666 XmlTest(
"Copy/Assign: element assign #2.",
"value", elementAssign.
Attribute(
"name" ) );
667 XmlTest(
"Copy/Assign: element assign #3.",
true, ( 0 == elementAssign.
Attribute(
"foo" )) );
673 commentAssign = commentCopy;
674 XmlTest(
"Copy/Assign: comment copy.",
"comment", commentCopy.
Value() );
675 XmlTest(
"Copy/Assign: comment assign.",
"comment", commentAssign.
Value() );
682 unknownAssign = unknownCopy;
683 XmlTest(
"Copy/Assign: unknown copy.",
"[unknown]", unknownCopy.
Value() );
684 XmlTest(
"Copy/Assign: unknown assign.",
"[unknown]", unknownAssign.
Value() );
690 XmlTest(
"Copy/Assign: text copy.",
"TextNode", textCopy.
Value() );
691 XmlTest(
"Copy/Assign: text assign.",
"TextNode", textAssign.
Value() );
699 XmlTest(
"Copy/Assign: declaration copy.",
"UTF-8", decCopy.
Encoding() );
713 std::string original, copy, assign;
717 XmlTest(
"Copy/Assign: document copy.", original.c_str(), copy.c_str(), true );
718 XmlTest(
"Copy/Assign: document assign.", original.c_str(), assign.c_str(), true );
725 printf (
"\n** Parsing, no Condense Whitespace **\n");
728 istringstream parse1(
"<start>This is \ntext</start>" );
732 XmlTest (
"Condense white space OFF.",
"This is \ntext",
733 text1.FirstChild()->Value(),
742 const char* str =
"<foo>This is text</foo>";
747 XmlTest(
"GetText() normal use.",
"This is text", element->
GetText() );
749 str =
"<foo><b>This is text</b></foo>";
754 XmlTest(
"GetText() contained element.", element->
GetText() == 0, true );
756 str =
"<foo>This is <b>text</b></foo>";
770 const char* str =
"<xmlElement>" 772 "I am > the rules!\n" 773 "...since I make symbolic puns" 781 "I am > the rules!\n...since I make symbolic puns",
789 istringstream parse0( str );
793 XmlTest(
"CDATA stream.", doc.FirstChildElement()->FirstChild()->Value(),
794 "I am > the rules!\n...since I make symbolic puns",
801 XmlTest(
"CDATA copy.", doc1.FirstChildElement()->FirstChild()->Value(),
802 "I am > the rules!\n...since I make symbolic puns",
809 for(
int i=0;
i<255; ++
i ) {
810 buf[
i] = (char)((
i>=32) ?
i : 32);
814 str +=
"]]></xmlElement>";
817 doc.
Parse( str.c_str() );
823 XmlTest(
"CDATA with all bytes #1.", str.c_str(), printer.
CStr(), true );
827 istringstream iss( printer.Str() );
831 XmlTest(
"CDATA with all bytes #2.", out.c_str(), printer.
CStr(), true );
837 const char* str =
"<xmlElement>" 839 "<b>I am > the rules!</b>\n" 840 "...since I make symbolic puns" 848 "<b>I am > the rules!</b>\n...since I make symbolic puns",
855 istringstream parse0( str );
858 XmlTest(
"CDATA stream. [ 1480107 ]", doc.FirstChildElement()->FirstChild()->Value(),
859 "<b>I am > the rules!</b>\n...since I make symbolic puns",
866 XmlTest(
"CDATA copy. [ 1480107 ]", doc1.FirstChildElement()->FirstChild()->Value(),
867 "<b>I am > the rules!</b>\n...since I make symbolic puns",
876 printf(
"\n** Fuzzing... **\n" );
878 const int FUZZ_ITERATION = 300;
881 int len = (int) strlen( demoStart );
882 for(
int i=0;
i<FUZZ_ITERATION; ++
i )
884 char* demoCopy =
new char[ len+1 ];
885 strcpy( demoCopy, demoStart );
887 demoCopy[
i%len ] = (char)((
i+1)*3);
888 demoCopy[ (
i*7)%len ] =
'>';
889 demoCopy[ (
i*11)%len ] =
'<';
892 xml.
Parse( demoCopy );
896 printf(
"** Fuzzing Complete. **\n" );
899 printf (
"\n** Bug regression tests **\n");
909 XmlTest(
"Test InsertBeforeChild on empty node.", ( childNode1 == parent.
FirstChild() ),
true );
920 XmlTest(
"Test InsertAfterChild on empty node. ", ( childNode1 == parent.
LastChild() ),
true );
931 string name =
"missing";
946 XmlTest(
"Basic TiXmlString test. ",
"Hello World!", a.
c_str() );
952 TiXmlDocument doc(
"midsummerNightsDreamWithAVeryLongFilenameToConfuseTheStringHandlingRoutines.xml" );
963 const char* passages =
964 "<?xml version=\"1.0\" standalone=\"no\" ?>" 965 "<passages count=\"006\" formatversion=\"20020620\">" 966 "<psg context=\"Line 5 has "quotation marks" and 'apostrophe marks'." 967 " It also has <, >, and &, as well as a fake copyright ©.\"> </psg>" 971 doc.
Parse( passages );
973 const char* context = psg->
Attribute(
"context" );
974 const char* expected =
"Line 5 has \"quotation marks\" and 'apostrophe marks'. It also has <, >, and &, as well as a fake copyright \xC2\xA9.";
976 XmlTest(
"Entity transformation: read. ", expected, context,
true );
978 FILE* textfile = fopen(
"textfile.txt",
"w" );
981 psg->
Print( textfile, 0 );
984 textfile = fopen(
"textfile.txt",
"r" );
989 fgets( buf, 1024, textfile );
990 XmlTest(
"Entity transformation: write. ",
991 "<psg context=\'Line 5 has "quotation marks" and 'apostrophe marks'." 992 " It also has <, >, and &, as well as a fake copyright \xC2\xA9.' />",
1000 FILE* textfile = fopen(
"test5.xml",
"w" );
1003 fputs(
"<?xml version='1.0'?><a.elem xmi.version='2.0'/>", textfile);
1008 XmlTest(
"dot in element attributes and names", doc.
Error(), 0);
1013 FILE* textfile = fopen(
"test6.xml",
"w" );
1016 fputs(
"<element><Name>1.1 Start easy ignore fin thickness
</Name></element>", textfile );
1020 bool result = doc.
LoadFile(
"test6.xml" );
1021 XmlTest(
"Entity with one digit.", result,
true );
1024 XmlTest(
"Entity with one digit.",
1025 text->
Value(),
"1.1 Start easy ignore fin thickness\n" );
1032 const char* doctype =
1033 "<?xml version=\"1.0\" ?>" 1034 "<!DOCTYPE PLAY SYSTEM 'play.dtd'>" 1035 "<!ELEMENT title (#PCDATA)>" 1036 "<!ELEMENT books (title,authors)>" 1040 doc.
Parse( doctype );
1047 XmlTest(
"Correct value of unknown.",
"!DOCTYPE PLAY SYSTEM 'play.dtd'", unknown->
Value() );
1048 #ifdef TIXML_USE_STL 1052 XmlTest(
"Correct streaming of unknown.",
"<!ELEMENT title (#PCDATA)>", str.c_str() );
1059 const char* doctype =
1060 "<!-- Somewhat<evil> -->";
1062 doc.
Parse( doctype );
1067 XmlTest(
"Comment formatting.",
" Somewhat<evil> ", comment->
Value() );
1068 #ifdef TIXML_USE_STL 1071 XmlTest(
"Comment streaming.",
"<!-- Somewhat<evil> -->", str.c_str() );
1081 const char* doctype0 =
"<element> This has leading and trailing space </element>";
1082 const char* doctype1 =
"<element>This has internal space</element>";
1083 const char* doctype2 =
"<element> This has leading, trailing, and internal space </element>";
1087 doc.
Parse( doctype0 );
1089 XmlTest(
"White space kept.",
" This has leading and trailing space ", text->
Value() );
1092 doc.
Parse( doctype1 );
1094 XmlTest(
"White space kept.",
"This has internal space", text->
Value() );
1097 doc.
Parse( doctype2 );
1099 XmlTest(
"White space kept.",
" This has leading, trailing, and internal space ", text->
Value() );
1103 doc.
Parse( doctype0 );
1105 XmlTest(
"White space condensed.",
"This has leading and trailing space", text->
Value() );
1108 doc.
Parse( doctype1 );
1110 XmlTest(
"White space condensed.",
"This has internal space", text->
Value() );
1113 doc.
Parse( doctype2 );
1115 XmlTest(
"White space condensed.",
"This has leading, trailing, and internal space", text->
Value() );
1120 const char* doctype =
"<element attr='red' attr='blue' />";
1123 doc.
Parse( doctype );
1125 XmlTest(
"Parsing repeated attributes.",
true, doc.
Error() );
1131 const char* doctype =
"<element att\0r='red' attr='blue' />";
1134 doc.
Parse( doctype );
1135 XmlTest(
"Embedded null throws error.",
true, doc.
Error() );
1137 #ifdef TIXML_USE_STL 1138 istringstream strm( doctype );
1142 XmlTest(
"Embedded null throws error.",
true, doc.Error() );
1149 "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" 1151 "C�nt�nt�������
"</�>";
TiXmlDocument doc;
doc.Parse( str );
TiXmlHandle docHandle( &doc );
TiXmlHandle aHandle = docHandle.FirstChildElement( "�" );
TiXmlHandle tHandle = aHandle.Child( 0 );
assert( aHandle.Element() );
assert( tHandle.Text() );
XmlTest( "ISO-8859-1 Parsing.", "C�nt�nt�������", tHandle.Text()->Value() );
}
{
// Empty documents should return TIXML_ERROR_PARSING_EMPTY, bug 1070717
const char* str = " ";
TiXmlDocument doc;
doc.Parse( str );
XmlTest( "Empty document error TIXML_ERROR_DOCUMENT_EMPTY", TiXmlBase::TIXML_ERROR_DOCUMENT_EMPTY, doc.ErrorId() );
}
#ifndef TIXML_USE_STL
{
// String equality. [ 1006409 ] string operator==/!= no worky in all cases
TiXmlString temp;
XmlTest( "Empty tinyxml string compare equal", ( temp == "" ), true );
TiXmlString foo;
TiXmlString bar( "" );
XmlTest( "Empty tinyxml string compare equal", ( foo == bar ), true );
}
#endif
{
// Bug [ 1195696 ] from marlonism
TiXmlBase::SetCondenseWhiteSpace(false);
TiXmlDocument xml;
xml.Parse("<text><break/>This hangs</text>");
XmlTest( "Test safe error return.", xml.Error(), false );
}
{
// Bug [ 1243992 ] - another infinite loop
TiXmlDocument doc;
doc.SetCondenseWhiteSpace(false);
doc.Parse("<p><pb></pb>test</p>");
}
{
// Low entities
TiXmlDocument xml;
xml.Parse( "<test></test>" );
const char result[] = { 0x0e, 0 };
XmlTest( "Low entities.", xml.FirstChildElement()->GetText(), result );
xml.Print();
}
{
// Bug [ 1451649 ] Attribute values with trailing quotes not handled correctly
TiXmlDocument xml;
xml.Parse( "<foo attribute=bar\" />" );
XmlTest( "Throw error with bad end quotes.", xml.Error(), true );
}
#ifdef TIXML_USE_STL
{
// Bug [ 1449463 ] Consider generic query
TiXmlDocument xml;
xml.Parse( "<foo bar='3' barStr='a string'/>" );
TiXmlElement* ele = xml.FirstChildElement();
double d;
int i;
float f;
bool b;
std::string str;
XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "bar", &d ), TIXML_SUCCESS );
XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "bar", &i ), TIXML_SUCCESS );
XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "bar", &f ), TIXML_SUCCESS );
XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "bar", &b ), TIXML_WRONG_TYPE );
XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "nobar", &b ), TIXML_NO_ATTRIBUTE );
XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "barStr", &str ), TIXML_SUCCESS );
XmlTest( "QueryValueAttribute", (d==3.0), true );
XmlTest( "QueryValueAttribute", (i==3), true );
XmlTest( "QueryValueAttribute", (f==3.0f), true );
XmlTest( "QueryValueAttribute", (str==std::string( "a string" )), true );
}
#endif
#ifdef TIXML_USE_STL
{
// [ 1505267 ] redundant malloc in TiXmlElement::Attribute
TiXmlDocument xml;
xml.Parse( "<foo bar='3' />" );
TiXmlElement* ele = xml.FirstChildElement();
double d;
int i;
std::string bar = "bar";
const std::string* atrrib = ele->Attribute( bar );
ele->Attribute( bar, &d );
ele->Attribute( bar, &i );
XmlTest( "Attribute", atrrib->empty(), false );
XmlTest( "Attribute", (d==3.0), true );
XmlTest( "Attribute", (i==3), true );
}
#endif
{
// [ 1356059 ] Allow TiXMLDocument to only be at the top level
TiXmlDocument xml, xml2;
xml.InsertEndChild( xml2 );
XmlTest( "Document only at top level.", xml.Error(), true );
XmlTest( "Document only at top level.", xml.ErrorId(), TiXmlBase::TIXML_ERROR_DOCUMENT_TOP_ONLY );
}
{
// [ 1663758 ] Failure to report error on bad XML
TiXmlDocument xml;
xml.Parse("<x>");
XmlTest("Missing end tag at end of input", xml.Error(), true);
xml.Parse("<x> ");
XmlTest("Missing end tag with trailing whitespace", xml.Error(), true);
}
{
// [ 1635701 ] fail to parse files with a tag separated into two lines
// I'm not sure this is a bug. Marked 'pending' for feedback.
TiXmlDocument xml;
xml.Parse( "<title><p>text</p\n><title>" );
//xml.Print();
//XmlTest( "Tag split by newline", xml.Error(), false );
}
#ifdef TIXML_USE_STL
{
// [ 1475201 ] TinyXML parses entities in comments
TiXmlDocument xml;
istringstream parse1( "<!-- declarations for <head> & <body> -->"
"<!-- far & away -->" );
parse1 >> xml;
TiXmlNode* e0 = xml.FirstChild();
TiXmlNode* e1 = e0->NextSibling();
TiXmlComment* c0 = e0->ToComment();
TiXmlComment* c1 = e1->ToComment();
XmlTest( "Comments ignore entities.", " declarations for <head> & <body> ", c0->Value(), true );
XmlTest( "Comments ignore entities.", " far & away ", c1->Value(), true );
}
#endif
{
// [ 1475201 ] TinyXML parses entities in comments
TiXmlDocument xml;
xml.Parse("<!-- declarations for <head> & <body> -->"
"<!-- far & away -->" );
TiXmlNode* e0 = xml.FirstChild();
TiXmlNode* e1 = e0->NextSibling();
TiXmlComment* c0 = e0->ToComment();
TiXmlComment* c1 = e1->ToComment();
XmlTest( "Comments ignore entities.", " declarations for <head> & <body> ", c0->Value(), true );
XmlTest( "Comments ignore entities.", " far & away ", c1->Value(), true );
}
{
TiXmlDocument xml;
xml.Parse( "<Parent>"
"<child1 att=''/>"
"<!-- With this comment, child2 will not be parsed! -->"
"<child2 att=''/>"
"</Parent>" );
int count = 0;
TiXmlNode* ele = 0;
while ( (ele = xml.FirstChildElement( "Parent" )->IterateChildren( ele ) ) != 0 ) {
++count;
}
XmlTest( "Comments iterate correctly.", 3, count );
}
{
// trying to repro ]1874301]. If it doesn't go into an infinite loop, all is well.
unsigned char buf[] = "<?xml version=\"1.0\" encoding=\"utf-8\"?><feed><![CDATA[Test XMLblablablalblbl";
buf[60] = 239;
buf[61] = 0;
TiXmlDocument doc;
doc.Parse( (const char*)buf);
}
{
// bug 1827248 Error while parsing a little bit malformed file
// Actually not malformed - should work.
TiXmlDocument xml;
xml.Parse( "<attributelist> </attributelist >" );
XmlTest( "Handle end tag whitespace", false, xml.Error() );
}
{
// This one must not result in an infinite loop
TiXmlDocument xml;
xml.Parse( "<infinite>loop" );
XmlTest( "Infinite loop test.", true, true );
}
{
// 1709904 - can not repro the crash
{
TiXmlDocument xml;
xml.Parse( "<tag>/</tag>" );
XmlTest( "Odd XML parsing.", xml.FirstChild()->Value(), "tag" );
}
/* Could not repro. {
TiXmlDocument xml;
xml.LoadFile( "EQUI_Inventory.xml" );
//XmlTest( "Odd XML parsing.", xml.FirstChildElement()->Value(), "XML" );
TiXmlPrinter printer;
xml.Accept( &printer );
fprintf( stdout, "%s", printer.CStr() );
}*/
}
/* 1417717 experiment
{
TiXmlDocument xml;
xml.Parse("<text>Dan & Tracie</text>");
xml.Print(stdout);
}
{
TiXmlDocument xml;
xml.Parse("<text>Dan &foo; Tracie</text>");
xml.Print(stdout);
}
*/
#if defined( WIN32 ) && defined( TUNE )
_CrtMemCheckpoint( &endMemState );
//_CrtMemDumpStatistics( &endMemState );
_CrtMemState diffMemState;
_CrtMemDifference( &diffMemState, &startMemState, &endMemState );
_CrtMemDumpStatistics( &diffMemState );
#endif
printf ("\nPass %d, Fail %d\n", gPass, gFail);
return gFail;
}
" 1158 TiXmlHandle aHandle = docHandle.
FirstChildElement(
"� );
TiXmlHandle tHandle = aHandle.Child( 0 );
assert( aHandle.Element() );
assert( tHandle.Text() );
XmlTest( "ISO-8859-1 Parsing.", "C�nt�nt�������", tHandle.Text()->Value() );
}
{
// Empty documents should return TIXML_ERROR_PARSING_EMPTY, bug 1070717
const char* str = " ";
TiXmlDocument doc;
doc.Parse( str );
XmlTest( "Empty document error TIXML_ERROR_DOCUMENT_EMPTY", TiXmlBase::TIXML_ERROR_DOCUMENT_EMPTY, doc.ErrorId() );
}
#ifndef TIXML_USE_STL
{
// String equality. [ 1006409 ] string operator==/!= no worky in all cases
TiXmlString temp;
XmlTest( "Empty tinyxml string compare equal", ( temp == "" ), true );
TiXmlString foo;
TiXmlString bar( "" );
XmlTest( "Empty tinyxml string compare equal", ( foo == bar ), true );
}
#endif
{
// Bug [ 1195696 ] from marlonism
TiXmlBase::SetCondenseWhiteSpace(false);
TiXmlDocument xml;
xml.Parse("<text><break/>This hangs</text>");
XmlTest( "Test safe error return.", xml.Error(), false );
}
{
// Bug [ 1243992 ] - another infinite loop
TiXmlDocument doc;
doc.SetCondenseWhiteSpace(false);
doc.Parse("<p><pb></pb>test</p>");
}
{
// Low entities
TiXmlDocument xml;
xml.Parse( "<test></test>" );
const char result[] = { 0x0e, 0 };
XmlTest( "Low entities.", xml.FirstChildElement()->GetText(), result );
xml.Print();
}
{
// Bug [ 1451649 ] Attribute values with trailing quotes not handled correctly
TiXmlDocument xml;
xml.Parse( "<foo attribute=bar\" />" );
XmlTest( "Throw error with bad end quotes.", xml.Error(), true );
}
#ifdef TIXML_USE_STL
{
// Bug [ 1449463 ] Consider generic query
TiXmlDocument xml;
xml.Parse( "<foo bar='3' barStr='a string'/>" );
TiXmlElement* ele = xml.FirstChildElement();
double d;
int i;
float f;
bool b;
std::string str;
XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "bar", &d ), TIXML_SUCCESS );
XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "bar", &i ), TIXML_SUCCESS );
XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "bar", &f ), TIXML_SUCCESS );
XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "bar", &b ), TIXML_WRONG_TYPE );
XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "nobar", &b ), TIXML_NO_ATTRIBUTE );
XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "barStr", &str ), TIXML_SUCCESS );
XmlTest( "QueryValueAttribute", (d==3.0), true );
XmlTest( "QueryValueAttribute", (i==3), true );
XmlTest( "QueryValueAttribute", (f==3.0f), true );
XmlTest( "QueryValueAttribute", (str==std::string( "a string" )), true );
}
#endif
#ifdef TIXML_USE_STL
{
// [ 1505267 ] redundant malloc in TiXmlElement::Attribute
TiXmlDocument xml;
xml.Parse( "<foo bar='3' />" );
TiXmlElement* ele = xml.FirstChildElement();
double d;
int i;
std::string bar = "bar";
const std::string* atrrib = ele->Attribute( bar );
ele->Attribute( bar, &d );
ele->Attribute( bar, &i );
XmlTest( "Attribute", atrrib->empty(), false );
XmlTest( "Attribute", (d==3.0), true );
XmlTest( "Attribute", (i==3), true );
}
#endif
{
// [ 1356059 ] Allow TiXMLDocument to only be at the top level
TiXmlDocument xml, xml2;
xml.InsertEndChild( xml2 );
XmlTest( "Document only at top level.", xml.Error(), true );
XmlTest( "Document only at top level.", xml.ErrorId(), TiXmlBase::TIXML_ERROR_DOCUMENT_TOP_ONLY );
}
{
// [ 1663758 ] Failure to report error on bad XML
TiXmlDocument xml;
xml.Parse("<x>");
XmlTest("Missing end tag at end of input", xml.Error(), true);
xml.Parse("<x> ");
XmlTest("Missing end tag with trailing whitespace", xml.Error(), true);
}
{
// [ 1635701 ] fail to parse files with a tag separated into two lines
// I'm not sure this is a bug. Marked 'pending' for feedback.
TiXmlDocument xml;
xml.Parse( "<title><p>text</p\n><title>" );
//xml.Print();
//XmlTest( "Tag split by newline", xml.Error(), false );
}
#ifdef TIXML_USE_STL
{
// [ 1475201 ] TinyXML parses entities in comments
TiXmlDocument xml;
istringstream parse1( "<!-- declarations for <head> & <body> -->"
"<!-- far & away -->" );
parse1 >> xml;
TiXmlNode* e0 = xml.FirstChild();
TiXmlNode* e1 = e0->NextSibling();
TiXmlComment* c0 = e0->ToComment();
TiXmlComment* c1 = e1->ToComment();
XmlTest( "Comments ignore entities.", " declarations for <head> & <body> ", c0->Value(), true );
XmlTest( "Comments ignore entities.", " far & away ", c1->Value(), true );
}
#endif
{
// [ 1475201 ] TinyXML parses entities in comments
TiXmlDocument xml;
xml.Parse("<!-- declarations for <head> & <body> -->"
"<!-- far & away -->" );
TiXmlNode* e0 = xml.FirstChild();
TiXmlNode* e1 = e0->NextSibling();
TiXmlComment* c0 = e0->ToComment();
TiXmlComment* c1 = e1->ToComment();
XmlTest( "Comments ignore entities.", " declarations for <head> & <body> ", c0->Value(), true );
XmlTest( "Comments ignore entities.", " far & away ", c1->Value(), true );
}
{
TiXmlDocument xml;
xml.Parse( "<Parent>"
"<child1 att=''/>"
"<!-- With this comment, child2 will not be parsed! -->"
"<child2 att=''/>"
"</Parent>" );
int count = 0;
TiXmlNode* ele = 0;
while ( (ele = xml.FirstChildElement( "Parent" )->IterateChildren( ele ) ) != 0 ) {
++count;
}
XmlTest( "Comments iterate correctly.", 3, count );
}
{
// trying to repro ]1874301]. If it doesn't go into an infinite loop, all is well.
unsigned char buf[] = "<?xml version=\"1.0\" encoding=\"utf-8\"?><feed><![CDATA[Test XMLblablablalblbl";
buf[60] = 239;
buf[61] = 0;
TiXmlDocument doc;
doc.Parse( (const char*)buf);
}
{
// bug 1827248 Error while parsing a little bit malformed file
// Actually not malformed - should work.
TiXmlDocument xml;
xml.Parse( "<attributelist> </attributelist >" );
XmlTest( "Handle end tag whitespace", false, xml.Error() );
}
{
// This one must not result in an infinite loop
TiXmlDocument xml;
xml.Parse( "<infinite>loop" );
XmlTest( "Infinite loop test.", true, true );
}
{
// 1709904 - can not repro the crash
{
TiXmlDocument xml;
xml.Parse( "<tag>/</tag>" );
XmlTest( "Odd XML parsing.", xml.FirstChild()->Value(), "tag" );
}
/* Could not repro. {
TiXmlDocument xml;
xml.LoadFile( "EQUI_Inventory.xml" );
//XmlTest( "Odd XML parsing.", xml.FirstChildElement()->Value(), "XML" );
TiXmlPrinter printer;
xml.Accept( &printer );
fprintf( stdout, "%s", printer.CStr() );
}*/
}
/* 1417717 experiment
{
TiXmlDocument xml;
xml.Parse("<text>Dan & Tracie</text>");
xml.Print(stdout);
}
{
TiXmlDocument xml;
xml.Parse("<text>Dan &foo; Tracie</text>");
xml.Print(stdout);
}
*/
#if defined( WIN32 ) && defined( TUNE )
_CrtMemCheckpoint( &endMemState );
//_CrtMemDumpStatistics( &endMemState );
_CrtMemState diffMemState;
_CrtMemDifference( &diffMemState, &startMemState, &endMemState );
_CrtMemDumpStatistics( &diffMemState );
#endif
printf ("\nPass %d, Fail %d\n", gPass, gFail);
return gFail;
}
" );
1161 assert( tHandle.
Text() );
1162 XmlTest(
"ISO-8859-1 Parsing.",
"C�nt�nt�������, tHandle.Text()->Value() );
}
{
// Empty documents should return TIXML_ERROR_PARSING_EMPTY, bug 1070717
const char* str = " ";
TiXmlDocument doc;
doc.Parse( str );
XmlTest( "Empty document error TIXML_ERROR_DOCUMENT_EMPTY", TiXmlBase::TIXML_ERROR_DOCUMENT_EMPTY, doc.ErrorId() );
}
#ifndef TIXML_USE_STL
{
// String equality. [ 1006409 ] string operator==/!= no worky in all cases
TiXmlString temp;
XmlTest( "Empty tinyxml string compare equal", ( temp == "" ), true );
TiXmlString foo;
TiXmlString bar( "" );
XmlTest( "Empty tinyxml string compare equal", ( foo == bar ), true );
}
#endif
{
// Bug [ 1195696 ] from marlonism
TiXmlBase::SetCondenseWhiteSpace(false);
TiXmlDocument xml;
xml.Parse("<text><break/>This hangs</text>");
XmlTest( "Test safe error return.", xml.Error(), false );
}
{
// Bug [ 1243992 ] - another infinite loop
TiXmlDocument doc;
doc.SetCondenseWhiteSpace(false);
doc.Parse("<p><pb></pb>test</p>");
}
{
// Low entities
TiXmlDocument xml;
xml.Parse( "<test></test>" );
const char result[] = { 0x0e, 0 };
XmlTest( "Low entities.", xml.FirstChildElement()->GetText(), result );
xml.Print();
}
{
// Bug [ 1451649 ] Attribute values with trailing quotes not handled correctly
TiXmlDocument xml;
xml.Parse( "<foo attribute=bar\" />" );
XmlTest( "Throw error with bad end quotes.", xml.Error(), true );
}
#ifdef TIXML_USE_STL
{
// Bug [ 1449463 ] Consider generic query
TiXmlDocument xml;
xml.Parse( "<foo bar='3' barStr='a string'/>" );
TiXmlElement* ele = xml.FirstChildElement();
double d;
int i;
float f;
bool b;
std::string str;
XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "bar", &d ), TIXML_SUCCESS );
XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "bar", &i ), TIXML_SUCCESS );
XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "bar", &f ), TIXML_SUCCESS );
XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "bar", &b ), TIXML_WRONG_TYPE );
XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "nobar", &b ), TIXML_NO_ATTRIBUTE );
XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "barStr", &str ), TIXML_SUCCESS );
XmlTest( "QueryValueAttribute", (d==3.0), true );
XmlTest( "QueryValueAttribute", (i==3), true );
XmlTest( "QueryValueAttribute", (f==3.0f), true );
XmlTest( "QueryValueAttribute", (str==std::string( "a string" )), true );
}
#endif
#ifdef TIXML_USE_STL
{
// [ 1505267 ] redundant malloc in TiXmlElement::Attribute
TiXmlDocument xml;
xml.Parse( "<foo bar='3' />" );
TiXmlElement* ele = xml.FirstChildElement();
double d;
int i;
std::string bar = "bar";
const std::string* atrrib = ele->Attribute( bar );
ele->Attribute( bar, &d );
ele->Attribute( bar, &i );
XmlTest( "Attribute", atrrib->empty(), false );
XmlTest( "Attribute", (d==3.0), true );
XmlTest( "Attribute", (i==3), true );
}
#endif
{
// [ 1356059 ] Allow TiXMLDocument to only be at the top level
TiXmlDocument xml, xml2;
xml.InsertEndChild( xml2 );
XmlTest( "Document only at top level.", xml.Error(), true );
XmlTest( "Document only at top level.", xml.ErrorId(), TiXmlBase::TIXML_ERROR_DOCUMENT_TOP_ONLY );
}
{
// [ 1663758 ] Failure to report error on bad XML
TiXmlDocument xml;
xml.Parse("<x>");
XmlTest("Missing end tag at end of input", xml.Error(), true);
xml.Parse("<x> ");
XmlTest("Missing end tag with trailing whitespace", xml.Error(), true);
}
{
// [ 1635701 ] fail to parse files with a tag separated into two lines
// I'm not sure this is a bug. Marked 'pending' for feedback.
TiXmlDocument xml;
xml.Parse( "<title><p>text</p\n><title>" );
//xml.Print();
//XmlTest( "Tag split by newline", xml.Error(), false );
}
#ifdef TIXML_USE_STL
{
// [ 1475201 ] TinyXML parses entities in comments
TiXmlDocument xml;
istringstream parse1( "<!-- declarations for <head> & <body> -->"
"<!-- far & away -->" );
parse1 >> xml;
TiXmlNode* e0 = xml.FirstChild();
TiXmlNode* e1 = e0->NextSibling();
TiXmlComment* c0 = e0->ToComment();
TiXmlComment* c1 = e1->ToComment();
XmlTest( "Comments ignore entities.", " declarations for <head> & <body> ", c0->Value(), true );
XmlTest( "Comments ignore entities.", " far & away ", c1->Value(), true );
}
#endif
{
// [ 1475201 ] TinyXML parses entities in comments
TiXmlDocument xml;
xml.Parse("<!-- declarations for <head> & <body> -->"
"<!-- far & away -->" );
TiXmlNode* e0 = xml.FirstChild();
TiXmlNode* e1 = e0->NextSibling();
TiXmlComment* c0 = e0->ToComment();
TiXmlComment* c1 = e1->ToComment();
XmlTest( "Comments ignore entities.", " declarations for <head> & <body> ", c0->Value(), true );
XmlTest( "Comments ignore entities.", " far & away ", c1->Value(), true );
}
{
TiXmlDocument xml;
xml.Parse( "<Parent>"
"<child1 att=''/>"
"<!-- With this comment, child2 will not be parsed! -->"
"<child2 att=''/>"
"</Parent>" );
int count = 0;
TiXmlNode* ele = 0;
while ( (ele = xml.FirstChildElement( "Parent" )->IterateChildren( ele ) ) != 0 ) {
++count;
}
XmlTest( "Comments iterate correctly.", 3, count );
}
{
// trying to repro ]1874301]. If it doesn't go into an infinite loop, all is well.
unsigned char buf[] = "<?xml version=\"1.0\" encoding=\"utf-8\"?><feed><![CDATA[Test XMLblablablalblbl";
buf[60] = 239;
buf[61] = 0;
TiXmlDocument doc;
doc.Parse( (const char*)buf);
}
{
// bug 1827248 Error while parsing a little bit malformed file
// Actually not malformed - should work.
TiXmlDocument xml;
xml.Parse( "<attributelist> </attributelist >" );
XmlTest( "Handle end tag whitespace", false, xml.Error() );
}
{
// This one must not result in an infinite loop
TiXmlDocument xml;
xml.Parse( "<infinite>loop" );
XmlTest( "Infinite loop test.", true, true );
}
{
// 1709904 - can not repro the crash
{
TiXmlDocument xml;
xml.Parse( "<tag>/</tag>" );
XmlTest( "Odd XML parsing.", xml.FirstChild()->Value(), "tag" );
}
/* Could not repro. {
TiXmlDocument xml;
xml.LoadFile( "EQUI_Inventory.xml" );
//XmlTest( "Odd XML parsing.", xml.FirstChildElement()->Value(), "XML" );
TiXmlPrinter printer;
xml.Accept( &printer );
fprintf( stdout, "%s", printer.CStr() );
}*/
}
/* 1417717 experiment
{
TiXmlDocument xml;
xml.Parse("<text>Dan & Tracie</text>");
xml.Print(stdout);
}
{
TiXmlDocument xml;
xml.Parse("<text>Dan &foo; Tracie</text>");
xml.Print(stdout);
}
*/
#if defined( WIN32 ) && defined( TUNE )
_CrtMemCheckpoint( &endMemState );
//_CrtMemDumpStatistics( &endMemState );
_CrtMemState diffMemState;
_CrtMemDifference( &diffMemState, &startMemState, &endMemState );
_CrtMemDumpStatistics( &diffMemState );
#endif
printf ("\nPass %d, Fail %d\n", gPass, gFail);
return gFail;
}
", tHandle.
Text()->
Value() );
1167 const char* str =
" ";
1172 #ifndef TIXML_USE_STL 1176 XmlTest(
"Empty tinyxml string compare equal", ( temp ==
"" ),
true );
1180 XmlTest(
"Empty tinyxml string compare equal", ( foo == bar ),
true );
1188 xml.
Parse(
"<text><break/>This hangs</text>");
1189 XmlTest(
"Test safe error return.", xml.
Error(), false );
1196 doc.
Parse(
"<p><pb></pb>test</p>");
1201 xml.
Parse(
"<test></test>" );
1202 const char result[] = { 0x0e, 0 };
1209 xml.
Parse(
"<foo attribute=bar\" />" );
1210 XmlTest(
"Throw error with bad end quotes.", xml.
Error(), true );
1212 #ifdef TIXML_USE_STL 1216 xml.
Parse(
"<foo bar='3' barStr='a string'/>" );
1232 XmlTest(
"QueryValueAttribute", (d==3.0),
true );
1233 XmlTest(
"QueryValueAttribute", (i==3),
true );
1234 XmlTest(
"QueryValueAttribute", (f==3.0f),
true );
1235 XmlTest(
"QueryValueAttribute", (str==std::string(
"a string" )),
true );
1239 #ifdef TIXML_USE_STL 1243 xml.
Parse(
"<foo bar='3' />" );
1248 std::string bar =
"bar";
1250 const std::string* atrrib = ele->
Attribute( bar );
1254 XmlTest(
"Attribute", atrrib->empty(), false );
1255 XmlTest(
"Attribute", (d==3.0),
true );
1256 XmlTest(
"Attribute", (i==3),
true );
1264 XmlTest(
"Document only at top level.", xml.
Error(), true );
1272 XmlTest(
"Missing end tag at end of input", xml.
Error(),
true);
1274 XmlTest(
"Missing end tag with trailing whitespace", xml.
Error(),
true);
1281 xml.
Parse(
"<title><p>text</p\n><title>" );
1286 #ifdef TIXML_USE_STL 1290 istringstream parse1(
"<!-- declarations for <head> & <body> -->" 1291 "<!-- far & away -->" );
1299 XmlTest(
"Comments ignore entities.",
" declarations for <head> & <body> ", c0->
Value(), true );
1300 XmlTest(
"Comments ignore entities.",
" far & away ", c1->
Value(), true );
1307 xml.
Parse(
"<!-- declarations for <head> & <body> -->" 1308 "<!-- far & away -->" );
1315 XmlTest(
"Comments ignore entities.",
" declarations for <head> & <body> ", c0->
Value(), true );
1316 XmlTest(
"Comments ignore entities.",
" far & away ", c1->
Value(), true );
1321 xml.
Parse(
"<Parent>" 1323 "<!-- With this comment, child2 will not be parsed! -->" 1332 XmlTest(
"Comments iterate correctly.", 3, count );
1337 unsigned char buf[] =
"<?xml version=\"1.0\" encoding=\"utf-8\"?><feed><![CDATA[Test XMLblablablalblbl";
1342 doc.
Parse( (
const char*)buf);
1350 xml.
Parse(
"<attributelist> </attributelist >" );
1351 XmlTest(
"Handle end tag whitespace",
false, xml.
Error() );
1357 xml.
Parse(
"<infinite>loop" );
1358 XmlTest(
"Infinite loop test.",
true,
true );
1365 xml.
Parse(
"<tag>/</tag>" );
1391 #if defined( WIN32 ) && defined( TUNE ) 1392 _CrtMemCheckpoint( &endMemState );
1395 _CrtMemState diffMemState;
1396 _CrtMemDifference( &diffMemState, &startMemState, &endMemState );
1397 _CrtMemDumpStatistics( &diffMemState );
1400 printf (
"\nPass %d, Fail %d\n", gPass, gFail);
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
TiXmlUnknown * Unknown() const
const TiXmlElement * RootElement() const
TiXmlHandle FirstChild() const
Return a handle to the first child node.
void SetDoubleAttribute(const char *name, double value)
void SetTabSize(int _tabsize)
virtual const TiXmlComment * ToComment() const
Cast to a more defined type. Will return null if not of the requested type.
virtual void Print(FILE *cfile, int depth) const
bool LoadFile(TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
int ErrorCol() const
The column where the error occured. See ErrorRow()
TiXmlNode * InsertEndChild(const TiXmlNode &addThis)
TiXmlNode * InsertBeforeChild(TiXmlNode *beforeThis, const TiXmlNode &addThis)
virtual const TiXmlDeclaration * ToDeclaration() const
Cast to a more defined type. Will return null if not of the requested type.
TiXmlHandle FirstChildElement() const
Return a handle to the first child element.
const char * Encoding() const
Encoding. Will return an empty string if none was found.
const TiXmlNode * LastChild() const
TiXmlHandle ChildElement(const char *value, int index) const
int Column() const
See Row()
const TiXmlNode * FirstChild() const
The first child of this node. Will be null if there are no children.
const char * ErrorDesc() const
Contains a textual (english) description of the error if one occurs.
void SetAttribute(const char *name, const char *_value)
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
bool SaveFile() const
Save a file using the current document value. Returns true if successful.
const TiXmlElement * FirstChildElement() const
Convenience function to get through elements.
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
const char * c_str() const
const TiXmlNode * PreviousSibling() const
Navigate to a sibling node.
TiXmlNode * InsertAfterChild(TiXmlNode *afterThis, const TiXmlNode &addThis)
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null if not of the requested type.
TiXmlHandle Child(const char *value, int index) const
static void SetCondenseWhiteSpace(bool condense)
const TiXmlElement * NextSiblingElement() const
void NullLineEndings(char *p)
virtual const char * Parse(const char *p, TiXmlParsingData *data=0, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
int QueryIntAttribute(const char *name, int *_value) const
TiXmlElement * Element() const
virtual bool Accept(TiXmlVisitor *content) const
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null if not of the requested type.
bool XmlTest(const char *testString, const char *expected, const char *found, bool noEcho=false)
int QueryDoubleAttribute(const char *name, double *_value) const
QueryDoubleAttribute examines the attribute - see QueryIntAttribute().
const TiXmlNode * IterateChildren(const TiXmlNode *previous) const
const char * Value() const
const TiXmlAttribute * FirstAttribute() const
Access the first attribute in this element.
bool RemoveChild(TiXmlNode *removeThis)
Delete a child of this node.
const char * GetText() const
void Clear()
Delete all the children of this node. Does not affect 'this'.
const TiXmlNode * NextSibling() const
Navigate to a sibling node.
const char * Attribute(const char *name) const
const char * CStr()
Return the result.