blob: 88f8ac428ca529693107a75aa86a7438170a573b [file] [log] [blame]
U-Lama\Leee13c3e62011-12-28 14:36:55 -08001#include "tinyxml2.h"
2
3#include <stdio.h>
4#include <stdlib.h>
5
Lee Thomasone9ecdab2012-02-13 18:11:20 -08006#if defined( WIN32 )
7 #include <crtdbg.h>
8 _CrtMemState startMemState;
9 _CrtMemState endMemState;
10#endif
11
U-Lama\Leee13c3e62011-12-28 14:36:55 -080012using namespace tinyxml2;
13
14int main( int argc, const char* argv )
15{
Lee Thomasone9ecdab2012-02-13 18:11:20 -080016 #if defined( WIN32 )
17 _CrtMemCheckpoint( &startMemState );
18 #endif
19
20#if 0
U-Lama\Lee4cee6112011-12-31 14:58:18 -080021 {
Lee Thomasonfde6a752012-01-14 18:08:12 -080022 static const char* test = "<!--hello world\n"
Lee Thomason8a5dfee2012-01-18 17:43:40 -080023 " line 2\r"
24 " line 3\r\n"
25 " line 4\n\r"
26 " line 5\r-->";
27
28 XMLDocument doc;
29 doc.Parse( test );
Lee Thomason50adb4c2012-02-13 15:07:09 -080030 doc.Print();
Lee Thomason8a5dfee2012-01-18 17:43:40 -080031 }
32#endif
Lee Thomason50adb4c2012-02-13 15:07:09 -080033#if 0
Lee Thomason8a5dfee2012-01-18 17:43:40 -080034 {
Lee Thomason43f59302012-02-06 18:18:11 -080035 static const char* test[] = { "<element />",
36 "<element></element>",
37 "<element><subelement/></element>",
38 "<element><subelement></subelement></element>",
39 "<element><subelement><subsub/></subelement></element>",
40 "<!--comment beside elements--><element><subelement></subelement></element>",
41 "<!--comment beside elements, this time with spaces--> \n <element> <subelement> \n </subelement> </element>",
42 "<element attrib1='foo' attrib2=\"bar\" ></element>",
43 "<element attrib1='foo' attrib2=\"bar\" ><subelement attrib3='yeehaa' /></element>",
44 "<element>Text inside element.</element>",
45 "<element><b></b></element>",
46 "<element>Text inside and <b>bolded</b> in the element.</element>",
47 "<outer><element>Text inside and <b>bolded</b> in the element.</element></outer>",
Lee Thomason8ee79892012-01-25 17:44:30 -080048 "<element>This &amp; That.</element>",
Lee Thomason18d68bd2012-01-26 18:17:26 -080049 "<element attrib='This&lt;That' />",
Lee Thomasondadcdfa2012-01-18 17:55:48 -080050 0
51 };
Lee Thomason6ee99fc2012-01-21 18:45:16 -080052 for( int i=0; test[i]; ++i ) {
Lee Thomasondadcdfa2012-01-18 17:55:48 -080053 XMLDocument doc;
Lee Thomason6ee99fc2012-01-21 18:45:16 -080054 doc.Parse( test[i] );
Lee Thomason5cae8972012-01-24 18:03:07 -080055 doc.Print();
Lee Thomasonec975ce2012-01-23 11:42:06 -080056 printf( "----------------------------------------------\n" );
Lee Thomasondadcdfa2012-01-18 17:55:48 -080057 }
U-Lama\Lee4cee6112011-12-31 14:58:18 -080058 }
Lee Thomason50adb4c2012-02-13 15:07:09 -080059#endif
Lee Thomasone9ecdab2012-02-13 18:11:20 -080060#if 0
Lee Thomason2c85a712012-01-31 08:24:24 -080061 {
62 static const char* test = "<element>Text before.</element>";
63 XMLDocument doc;
64 doc.Parse( test );
65 XMLElement* root = doc.FirstChildElement();
66 XMLElement* newElement = doc.NewElement( "Subelement" );
67 root->InsertEndChild( newElement );
68 doc.Print();
69 }
Lee Thomasond1983222012-02-06 08:41:24 -080070 {
71 XMLDocument* doc = new XMLDocument();
72 static const char* test = "<element><sub/></element>";
73 doc->Parse( test );
74 delete doc;
75 }
Lee Thomason56bdd022012-02-09 18:16:58 -080076#endif
Lee Thomasone9ecdab2012-02-13 18:11:20 -080077 {
78 XMLDocument* doc = new XMLDocument();
79 doc->InsertEndChild( doc->NewElement( "element" ) );
80 doc->Print();
81 delete doc;
82 }
83 #if defined( WIN32 )
84 _CrtMemCheckpoint( &endMemState );
85 //_CrtMemDumpStatistics( &endMemState );
86
87 _CrtMemState diffMemState;
88 _CrtMemDifference( &diffMemState, &startMemState, &endMemState );
89 _CrtMemDumpStatistics( &diffMemState );
90 #endif
U-Lama\Leee13c3e62011-12-28 14:36:55 -080091 return 0;
92}