xmltest.cpp 19 KB

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