xmltest.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. #include "tinyxml2.h"
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #if defined( _MSC_VER )
  6. #include <crtdbg.h>
  7. _CrtMemState startMemState;
  8. _CrtMemState endMemState;
  9. #endif
  10. using namespace tinyxml2;
  11. int gPass = 0;
  12. int gFail = 0;
  13. bool XMLTest (const char* testString, const char* expected, const char* found, bool echo=true )
  14. {
  15. bool pass = !strcmp( expected, found );
  16. if ( pass )
  17. printf ("[pass]");
  18. else
  19. printf ("[fail]");
  20. if ( !echo )
  21. printf (" %s\n", testString);
  22. else
  23. printf (" %s [%s][%s]\n", testString, expected, found);
  24. if ( pass )
  25. ++gPass;
  26. else
  27. ++gFail;
  28. return pass;
  29. }
  30. bool XMLTest( const char* testString, int expected, int found, bool echo=true )
  31. {
  32. bool pass = ( expected == found );
  33. if ( pass )
  34. printf ("[pass]");
  35. else
  36. printf ("[fail]");
  37. if ( !echo )
  38. printf (" %s\n", testString);
  39. else
  40. printf (" %s [%d][%d]\n", testString, expected, found);
  41. if ( pass )
  42. ++gPass;
  43. else
  44. ++gFail;
  45. return pass;
  46. }
  47. void NullLineEndings( char* p )
  48. {
  49. while( p && *p ) {
  50. if ( *p == '\n' || *p == '\r' ) {
  51. *p = 0;
  52. return;
  53. }
  54. ++p;
  55. }
  56. }
  57. int main( int argc, const char* argv )
  58. {
  59. #if defined( _MSC_VER )
  60. _CrtMemCheckpoint( &startMemState );
  61. #endif
  62. {
  63. static const char* test[] = { "<element />",
  64. "<element></element>",
  65. "<element><subelement/></element>",
  66. "<element><subelement></subelement></element>",
  67. "<element><subelement><subsub/></subelement></element>",
  68. "<!--comment beside elements--><element><subelement></subelement></element>",
  69. "<!--comment beside elements, this time with spaces--> \n <element> <subelement> \n </subelement> </element>",
  70. "<element attrib1='foo' attrib2=\"bar\" ></element>",
  71. "<element attrib1='foo' attrib2=\"bar\" ><subelement attrib3='yeehaa' /></element>",
  72. "<element>Text inside element.</element>",
  73. "<element><b></b></element>",
  74. "<element>Text inside and <b>bolded</b> in the element.</element>",
  75. "<outer><element>Text inside and <b>bolded</b> in the element.</element></outer>",
  76. "<element>This &amp; That.</element>",
  77. "<element attrib='This&lt;That' />",
  78. 0
  79. };
  80. for( int i=0; test[i]; ++i ) {
  81. XMLDocument doc;
  82. doc.Parse( test[i] );
  83. doc.Print();
  84. printf( "----------------------------------------------\n" );
  85. }
  86. }
  87. #if 1
  88. {
  89. static const char* test = "<!--hello world\n"
  90. " line 2\r"
  91. " line 3\r\n"
  92. " line 4\n\r"
  93. " line 5\r-->";
  94. XMLDocument doc;
  95. doc.Parse( test );
  96. doc.Print();
  97. }
  98. {
  99. static const char* test = "<element>Text before.</element>";
  100. XMLDocument doc;
  101. doc.Parse( test );
  102. XMLElement* root = doc.FirstChildElement();
  103. XMLElement* newElement = doc.NewElement( "Subelement" );
  104. root->InsertEndChild( newElement );
  105. doc.Print();
  106. }
  107. {
  108. XMLDocument* doc = new XMLDocument();
  109. static const char* test = "<element><sub/></element>";
  110. doc->Parse( test );
  111. delete doc;
  112. }
  113. {
  114. // Test: Programmatic DOM
  115. // Build:
  116. // <element>
  117. // <!--comment-->
  118. // <sub attrib="1" />
  119. // <sub attrib="2" />
  120. // <sub attrib="3" >& Text!</sub>
  121. // <element>
  122. XMLDocument* doc = new XMLDocument();
  123. XMLNode* element = doc->InsertEndChild( doc->NewElement( "element" ) );
  124. XMLElement* sub[3] = { doc->NewElement( "sub" ), doc->NewElement( "sub" ), doc->NewElement( "sub" ) };
  125. for( int i=0; i<3; ++i ) {
  126. sub[i]->SetAttribute( "attrib", i );
  127. }
  128. element->InsertEndChild( sub[2] );
  129. XMLNode* comment = element->InsertFirstChild( doc->NewComment( "comment" ) );
  130. element->InsertAfterChild( comment, sub[0] );
  131. element->InsertAfterChild( sub[0], sub[1] );
  132. sub[2]->InsertFirstChild( doc->NewText( "& Text!" ));
  133. doc->Print();
  134. XMLTest( "Programmatic DOM", "comment", doc->FirstChildElement( "element" )->FirstChild()->Value() );
  135. XMLTest( "Programmatic DOM", "0", doc->FirstChildElement( "element" )->FirstChildElement()->Attribute( "attrib" ) );
  136. XMLTest( "Programmatic DOM", 2, doc->FirstChildElement()->LastChildElement( "sub" )->IntAttribute( "attrib" ) );
  137. XMLTest( "Programmatic DOM", "& Text!",
  138. doc->FirstChildElement()->LastChildElement( "sub" )->FirstChild()->ToText()->Value() );
  139. // And now deletion:
  140. element->DeleteChild( sub[2] );
  141. doc->DeleteNode( comment );
  142. element->FirstChildElement()->SetAttribute( "attrib", true );
  143. element->LastChildElement()->DeleteAttribute( "attrib" );
  144. XMLTest( "Programmatic DOM", true, doc->FirstChildElement()->FirstChildElement()->BoolAttribute( "attrib" ) );
  145. int value = 10;
  146. int result = doc->FirstChildElement()->LastChildElement()->QueryIntAttribute( "attrib", &value );
  147. XMLTest( "Programmatic DOM", result, NO_ATTRIBUTE );
  148. XMLTest( "Programmatic DOM", value, 10 );
  149. doc->Print();
  150. XMLPrinter streamer;
  151. doc->Print( &streamer );
  152. printf( "%s", streamer.CStr() );
  153. delete doc;
  154. }
  155. {
  156. // Test: Dream
  157. // XML1 : 1,187,569 bytes in 31,209 allocations
  158. // XML2 : 469,073 bytes in 323 allocations
  159. //int newStart = gNew;
  160. XMLDocument doc;
  161. doc.LoadFile( "dream.xml" );
  162. doc.SaveFile( "dreamout.xml" );
  163. doc.PrintError();
  164. XMLTest( "Dream", "xml version=\"1.0\"",
  165. doc.FirstChild()->ToDeclaration()->Value() );
  166. XMLTest( "Dream", true, doc.FirstChild()->NextSibling()->ToUnknown() ? true : false );
  167. XMLTest( "Dream", "DOCTYPE PLAY SYSTEM \"play.dtd\"",
  168. doc.FirstChild()->NextSibling()->ToUnknown()->Value() );
  169. XMLTest( "Dream", "And Robin shall restore amends.",
  170. doc.LastChild()->LastChild()->LastChild()->LastChild()->LastChildElement()->GetText() );
  171. XMLTest( "Dream", "And Robin shall restore amends.",
  172. doc.LastChild()->LastChild()->LastChild()->LastChild()->LastChildElement()->GetText() );
  173. XMLDocument doc2;
  174. doc2.LoadFile( "dreamout.xml" );
  175. XMLTest( "Dream-out", "xml version=\"1.0\"",
  176. doc2.FirstChild()->ToDeclaration()->Value() );
  177. XMLTest( "Dream-out", true, doc2.FirstChild()->NextSibling()->ToUnknown() ? true : false );
  178. XMLTest( "Dream-out", "DOCTYPE PLAY SYSTEM \"play.dtd\"",
  179. doc2.FirstChild()->NextSibling()->ToUnknown()->Value() );
  180. XMLTest( "Dream-out", "And Robin shall restore amends.",
  181. doc2.LastChild()->LastChild()->LastChild()->LastChild()->LastChildElement()->GetText() );
  182. //gNewTotal = gNew - newStart;
  183. }
  184. {
  185. const char* error = "<?xml version=\"1.0\" standalone=\"no\" ?>\n"
  186. "<passages count=\"006\" formatversion=\"20020620\">\n"
  187. " <wrong error>\n"
  188. "</passages>";
  189. XMLDocument doc;
  190. doc.Parse( error );
  191. XMLTest( "Bad XML", doc.ErrorID(), ERROR_PARSING_ATTRIBUTE );
  192. }
  193. {
  194. const char* str = "<doc attr0='1' attr1='2.0' attr2='foo' />";
  195. XMLDocument doc;
  196. doc.Parse( str );
  197. XMLElement* ele = doc.FirstChildElement();
  198. int iVal, result;
  199. double dVal;
  200. result = ele->QueryDoubleAttribute( "attr0", &dVal );
  201. XMLTest( "Query attribute: int as double", result, XML_NO_ERROR );
  202. XMLTest( "Query attribute: int as double", (int)dVal, 1 );
  203. result = ele->QueryDoubleAttribute( "attr1", &dVal );
  204. XMLTest( "Query attribute: double as double", (int)dVal, 2 );
  205. result = ele->QueryIntAttribute( "attr1", &iVal );
  206. XMLTest( "Query attribute: double as int", result, XML_NO_ERROR );
  207. XMLTest( "Query attribute: double as int", iVal, 2 );
  208. result = ele->QueryIntAttribute( "attr2", &iVal );
  209. XMLTest( "Query attribute: not a number", result, WRONG_ATTRIBUTE_TYPE );
  210. result = ele->QueryIntAttribute( "bar", &iVal );
  211. XMLTest( "Query attribute: does not exist", result, NO_ATTRIBUTE );
  212. }
  213. {
  214. const char* str = "<doc/>";
  215. XMLDocument doc;
  216. doc.Parse( str );
  217. XMLElement* ele = doc.FirstChildElement();
  218. int iVal;
  219. double dVal;
  220. ele->SetAttribute( "str", "strValue" );
  221. ele->SetAttribute( "int", 1 );
  222. ele->SetAttribute( "double", -1.0 );
  223. const char* cStr = ele->Attribute( "str" );
  224. ele->QueryIntAttribute( "int", &iVal );
  225. ele->QueryDoubleAttribute( "double", &dVal );
  226. XMLTest( "Attribute round trip. c-string.", "strValue", cStr );
  227. XMLTest( "Attribute round trip. int.", 1, iVal );
  228. XMLTest( "Attribute round trip. double.", -1, (int)dVal );
  229. }
  230. {
  231. XMLDocument doc;
  232. doc.LoadFile( "utf8test.xml" );
  233. // Get the attribute "value" from the "Russian" element and check it.
  234. XMLElement* element = doc.FirstChildElement( "document" )->FirstChildElement( "Russian" );
  235. const unsigned char correctValue[] = { 0xd1U, 0x86U, 0xd0U, 0xb5U, 0xd0U, 0xbdU, 0xd0U, 0xbdU,
  236. 0xd0U, 0xbeU, 0xd1U, 0x81U, 0xd1U, 0x82U, 0xd1U, 0x8cU, 0 };
  237. XMLTest( "UTF-8: Russian value.", (const char*)correctValue, element->Attribute( "value" ) );
  238. const unsigned char russianElementName[] = { 0xd0U, 0xa0U, 0xd1U, 0x83U,
  239. 0xd1U, 0x81U, 0xd1U, 0x81U,
  240. 0xd0U, 0xbaU, 0xd0U, 0xb8U,
  241. 0xd0U, 0xb9U, 0 };
  242. const char russianText[] = "<\xD0\xB8\xD0\xBC\xD0\xB5\xD0\xB5\xD1\x82>";
  243. XMLText* text = doc.FirstChildElement( "document" )->FirstChildElement( (const char*) russianElementName )->FirstChild()->ToText();
  244. XMLTest( "UTF-8: Browsing russian element name.",
  245. russianText,
  246. text->Value() );
  247. // Now try for a round trip.
  248. doc.SaveFile( "utf8testout.xml" );
  249. // Check the round trip.
  250. char savedBuf[256];
  251. char verifyBuf[256];
  252. int okay = 0;
  253. FILE* saved = fopen( "utf8testout.xml", "r" );
  254. FILE* verify = fopen( "utf8testverify.xml", "r" );
  255. if ( saved && verify )
  256. {
  257. okay = 1;
  258. while ( fgets( verifyBuf, 256, verify ) )
  259. {
  260. fgets( savedBuf, 256, saved );
  261. NullLineEndings( verifyBuf );
  262. NullLineEndings( savedBuf );
  263. if ( strcmp( verifyBuf, savedBuf ) )
  264. {
  265. printf( "verify:%s<\n", verifyBuf );
  266. printf( "saved :%s<\n", savedBuf );
  267. okay = 0;
  268. break;
  269. }
  270. }
  271. }
  272. if ( saved )
  273. fclose( saved );
  274. if ( verify )
  275. fclose( verify );
  276. XMLTest( "UTF-8: Verified multi-language round trip.", 1, okay );
  277. }
  278. // --------GetText()-----------
  279. {
  280. const char* str = "<foo>This is text</foo>";
  281. XMLDocument doc;
  282. doc.Parse( str );
  283. const XMLElement* element = doc.RootElement();
  284. XMLTest( "GetText() normal use.", "This is text", element->GetText() );
  285. str = "<foo><b>This is text</b></foo>";
  286. doc.Parse( str );
  287. element = doc.RootElement();
  288. XMLTest( "GetText() contained element.", element->GetText() == 0, true );
  289. }
  290. // ---------- CDATA ---------------
  291. {
  292. const char* str = "<xmlElement>"
  293. "<![CDATA["
  294. "I am > the rules!\n"
  295. "...since I make symbolic puns"
  296. "]]>"
  297. "</xmlElement>";
  298. XMLDocument doc;
  299. doc.Parse( str );
  300. doc.Print();
  301. XMLTest( "CDATA parse.", doc.FirstChildElement()->FirstChild()->Value(),
  302. "I am > the rules!\n...since I make symbolic puns",
  303. false );
  304. }
  305. // ----------- CDATA -------------
  306. {
  307. const char* str = "<xmlElement>"
  308. "<![CDATA["
  309. "<b>I am > the rules!</b>\n"
  310. "...since I make symbolic puns"
  311. "]]>"
  312. "</xmlElement>";
  313. XMLDocument doc;
  314. doc.Parse( str );
  315. doc.Print();
  316. XMLTest( "CDATA parse. [ tixml1:1480107 ]", doc.FirstChildElement()->FirstChild()->Value(),
  317. "<b>I am > the rules!</b>\n...since I make symbolic puns",
  318. false );
  319. }
  320. // InsertAfterChild causes crash.
  321. {
  322. // InsertBeforeChild and InsertAfterChild causes crash.
  323. XMLDocument doc;
  324. XMLElement* parent = doc.NewElement( "Parent" );
  325. doc.InsertFirstChild( parent );
  326. XMLElement* childText0 = doc.NewElement( "childText0" );
  327. XMLElement* childText1 = doc.NewElement( "childText1" );
  328. XMLNode* childNode0 = parent->InsertEndChild( childText0 );
  329. XMLNode* childNode1 = parent->InsertAfterChild( childNode0, childText1 );
  330. XMLTest( "Test InsertAfterChild on empty node. ", ( childNode1 == parent->LastChild() ), true );
  331. }
  332. {
  333. // Entities not being written correctly.
  334. // From Lynn Allen
  335. const char* passages =
  336. "<?xml version=\"1.0\" standalone=\"no\" ?>"
  337. "<passages count=\"006\" formatversion=\"20020620\">"
  338. "<psg context=\"Line 5 has &quot;quotation marks&quot; and &apos;apostrophe marks&apos;."
  339. " It also has &lt;, &gt;, and &amp;, as well as a fake copyright &#xA9;.\"> </psg>"
  340. "</passages>";
  341. XMLDocument doc;
  342. doc.Parse( passages );
  343. XMLElement* psg = doc.RootElement()->FirstChildElement();
  344. const char* context = psg->Attribute( "context" );
  345. const char* expected = "Line 5 has \"quotation marks\" and 'apostrophe marks'. It also has <, >, and &, as well as a fake copyright \xC2\xA9.";
  346. XMLTest( "Entity transformation: read. ", expected, context, true );
  347. FILE* textfile = fopen( "textfile.txt", "w" );
  348. if ( textfile )
  349. {
  350. XMLPrinter streamer( textfile );
  351. psg->Accept( &streamer );
  352. fclose( textfile );
  353. }
  354. textfile = fopen( "textfile.txt", "r" );
  355. TIXMLASSERT( textfile );
  356. if ( textfile )
  357. {
  358. char buf[ 1024 ];
  359. fgets( buf, 1024, textfile );
  360. XMLTest( "Entity transformation: write. ",
  361. "<psg context=\"Line 5 has &quot;quotation marks&quot; and &apos;apostrophe marks&apos;."
  362. " It also has &lt;, &gt;, and &amp;, as well as a fake copyright \xC2\xA9.\"/>\n",
  363. buf, false );
  364. }
  365. fclose( textfile );
  366. }
  367. {
  368. const char* test = "<?xml version='1.0'?><a.elem xmi.version='2.0'/>";
  369. XMLDocument doc;
  370. doc.Parse( test );
  371. XMLTest( "dot in names", doc.Error(), 0);
  372. XMLTest( "dot in names", doc.FirstChildElement()->Name(), "a.elem" );
  373. XMLTest( "dot in names", doc.FirstChildElement()->Attribute( "xmi.version" ), "2.0" );
  374. }
  375. {
  376. const char* test = "<element><Name>1.1 Start easy ignore fin thickness&#xA;</Name></element>";
  377. XMLDocument doc;
  378. doc.Parse( test );
  379. XMLText* text = doc.FirstChildElement()->FirstChildElement()->FirstChild()->ToText();
  380. XMLTest( "Entity with one digit.",
  381. text->Value(), "1.1 Start easy ignore fin thickness\n",
  382. false );
  383. }
  384. {
  385. // DOCTYPE not preserved (950171)
  386. //
  387. const char* doctype =
  388. "<?xml version=\"1.0\" ?>"
  389. "<!DOCTYPE PLAY SYSTEM 'play.dtd'>"
  390. "<!ELEMENT title (#PCDATA)>"
  391. "<!ELEMENT books (title,authors)>"
  392. "<element />";
  393. XMLDocument doc;
  394. doc.Parse( doctype );
  395. doc.SaveFile( "test7.xml" );
  396. doc.DeleteChild( doc.RootElement() );
  397. doc.LoadFile( "test7.xml" );
  398. doc.Print();
  399. const XMLUnknown* decl = doc.FirstChild()->NextSibling()->ToUnknown();
  400. XMLTest( "Correct value of unknown.", "DOCTYPE PLAY SYSTEM 'play.dtd'", decl->Value() );
  401. }
  402. {
  403. // Comments do not stream out correctly.
  404. const char* doctype =
  405. "<!-- Somewhat<evil> -->";
  406. XMLDocument doc;
  407. doc.Parse( doctype );
  408. XMLComment* comment = doc.FirstChild()->ToComment();
  409. XMLTest( "Comment formatting.", " Somewhat<evil> ", comment->Value() );
  410. }
  411. {
  412. // Double attributes
  413. const char* doctype = "<element attr='red' attr='blue' />";
  414. XMLDocument doc;
  415. doc.Parse( doctype );
  416. XMLTest( "Parsing repeated attributes.", ERROR_PARSING_ATTRIBUTE, doc.ErrorID() ); // is an error to tinyxml (didn't use to be, but caused issues)
  417. }
  418. {
  419. // Embedded null in stream.
  420. const char* doctype = "<element att\0r='red' attr='blue' />";
  421. XMLDocument doc;
  422. doc.Parse( doctype );
  423. XMLTest( "Embedded null throws error.", true, doc.Error() );
  424. }
  425. {
  426. // Empty documents should return TIXML_ERROR_PARSING_EMPTY, bug 1070717
  427. const char* str = " ";
  428. XMLDocument doc;
  429. doc.Parse( str );
  430. XMLTest( "Empty document error", ERROR_EMPTY_DOCUMENT, doc.ErrorID() );
  431. }
  432. {
  433. // Low entities
  434. XMLDocument doc;
  435. doc.Parse( "<test>&#x0e;</test>" );
  436. const char result[] = { 0x0e, 0 };
  437. XMLTest( "Low entities.", doc.FirstChildElement()->GetText(), result );
  438. doc.Print();
  439. }
  440. {
  441. // Attribute values with trailing quotes not handled correctly
  442. XMLDocument doc;
  443. doc.Parse( "<foo attribute=bar\" />" );
  444. XMLTest( "Throw error with bad end quotes.", doc.Error(), true );
  445. }
  446. {
  447. // [ 1663758 ] Failure to report error on bad XML
  448. XMLDocument xml;
  449. xml.Parse("<x>");
  450. XMLTest("Missing end tag at end of input", xml.Error(), true);
  451. xml.Parse("<x> ");
  452. XMLTest("Missing end tag with trailing whitespace", xml.Error(), true);
  453. xml.Parse("<x></y>");
  454. XMLTest("Mismatched tags", xml.ErrorID(), ERROR_MISMATCHED_ELEMENT);
  455. }
  456. {
  457. // [ 1475201 ] TinyXML parses entities in comments
  458. XMLDocument xml;
  459. xml.Parse("<!-- declarations for <head> & <body> -->"
  460. "<!-- far &amp; away -->" );
  461. XMLNode* e0 = xml.FirstChild();
  462. XMLNode* e1 = e0->NextSibling();
  463. XMLComment* c0 = e0->ToComment();
  464. XMLComment* c1 = e1->ToComment();
  465. XMLTest( "Comments ignore entities.", " declarations for <head> & <body> ", c0->Value(), true );
  466. XMLTest( "Comments ignore entities.", " far &amp; away ", c1->Value(), true );
  467. }
  468. {
  469. XMLDocument xml;
  470. xml.Parse( "<Parent>"
  471. "<child1 att=''/>"
  472. "<!-- With this comment, child2 will not be parsed! -->"
  473. "<child2 att=''/>"
  474. "</Parent>" );
  475. xml.Print();
  476. int count = 0;
  477. for( XMLNode* ele = xml.FirstChildElement( "Parent" )->FirstChild();
  478. ele;
  479. ele = ele->NextSibling() )
  480. {
  481. ++count;
  482. }
  483. XMLTest( "Comments iterate correctly.", 3, count );
  484. }
  485. {
  486. // trying to repro ]1874301]. If it doesn't go into an infinite loop, all is well.
  487. unsigned char buf[] = "<?xml version=\"1.0\" encoding=\"utf-8\"?><feed><![CDATA[Test XMLblablablalblbl";
  488. buf[60] = 239;
  489. buf[61] = 0;
  490. XMLDocument doc;
  491. doc.Parse( (const char*)buf);
  492. }
  493. {
  494. // bug 1827248 Error while parsing a little bit malformed file
  495. // Actually not malformed - should work.
  496. XMLDocument xml;
  497. xml.Parse( "<attributelist> </attributelist >" );
  498. XMLTest( "Handle end tag whitespace", false, xml.Error() );
  499. }
  500. {
  501. // This one must not result in an infinite loop
  502. XMLDocument xml;
  503. xml.Parse( "<infinite>loop" );
  504. XMLTest( "Infinite loop test.", true, true );
  505. }
  506. #endif
  507. #if defined( _MSC_VER )
  508. _CrtMemCheckpoint( &endMemState );
  509. //_CrtMemDumpStatistics( &endMemState );
  510. _CrtMemState diffMemState;
  511. _CrtMemDifference( &diffMemState, &startMemState, &endMemState );
  512. _CrtMemDumpStatistics( &diffMemState );
  513. //printf( "new total=%d\n", gNewTotal );
  514. #endif
  515. printf ("\nPass %d, Fail %d\n", gPass, gFail);
  516. return 0;
  517. }