U-Lama\Lee | e13c3e6 | 2011-12-28 14:36:55 -0800 | [diff] [blame] | 1 | #include "tinyxml2.h"
|
| 2 |
|
Arkadiy Shapkin | ef1c69c | 2012-07-25 22:10:39 +0400 | [diff] [blame^] | 3 | #include <direct.h>
|
Guillermo A. Amaral | 2eb7003 | 2012-03-20 11:26:57 -0700 | [diff] [blame] | 4 | #include <cstdlib>
|
| 5 | #include <cstring>
|
| 6 | #include <ctime>
|
U-Lama\Lee | e13c3e6 | 2011-12-28 14:36:55 -0800 | [diff] [blame] | 7 |
|
Lee Thomason (grinliz) | 2a1cd27 | 2012-02-24 17:37:53 -0800 | [diff] [blame] | 8 | #if defined( _MSC_VER )
|
Lee Thomason | 1ff38e0 | 2012-02-14 18:18:16 -0800 | [diff] [blame] | 9 | #include <crtdbg.h>
|
Lee Thomason | 6f381b7 | 2012-03-02 12:59:39 -0800 | [diff] [blame] | 10 | #define WIN32_LEAN_AND_MEAN
|
| 11 | #include <windows.h>
|
Lee Thomason | 1ff38e0 | 2012-02-14 18:18:16 -0800 | [diff] [blame] | 12 | _CrtMemState startMemState;
|
| 13 | _CrtMemState endMemState;
|
| 14 | #endif
|
Lee Thomason | e9ecdab | 2012-02-13 18:11:20 -0800 | [diff] [blame] | 15 |
|
U-Lama\Lee | e13c3e6 | 2011-12-28 14:36:55 -0800 | [diff] [blame] | 16 | using namespace tinyxml2;
|
Lee Thomason | ec5a7b4 | 2012-02-13 18:16:52 -0800 | [diff] [blame] | 17 | int gPass = 0;
|
| 18 | int gFail = 0;
|
| 19 |
|
Lee Thomason (grinliz) | bd0a8ac | 2012-02-20 20:14:33 -0800 | [diff] [blame] | 20 |
|
U-Stream\Lee | 09a11c5 | 2012-02-17 08:31:16 -0800 | [diff] [blame] | 21 | bool XMLTest (const char* testString, const char* expected, const char* found, bool echo=true )
|
Lee Thomason | 1ff38e0 | 2012-02-14 18:18:16 -0800 | [diff] [blame] | 22 | {
|
| 23 | bool pass = !strcmp( expected, found );
|
| 24 | if ( pass )
|
| 25 | printf ("[pass]");
|
| 26 | else
|
| 27 | printf ("[fail]");
|
| 28 |
|
U-Stream\Lee | 09a11c5 | 2012-02-17 08:31:16 -0800 | [diff] [blame] | 29 | if ( !echo )
|
Lee Thomason | 1ff38e0 | 2012-02-14 18:18:16 -0800 | [diff] [blame] | 30 | printf (" %s\n", testString);
|
| 31 | else
|
| 32 | printf (" %s [%s][%s]\n", testString, expected, found);
|
| 33 |
|
| 34 | if ( pass )
|
| 35 | ++gPass;
|
| 36 | else
|
| 37 | ++gFail;
|
| 38 | return pass;
|
| 39 | }
|
| 40 |
|
| 41 |
|
Lee Thomason | 21be882 | 2012-07-15 17:27:22 -0700 | [diff] [blame] | 42 | template< class T > bool XMLTest( const char* testString, T expected, T found, bool echo=true )
|
Lee Thomason | 1ff38e0 | 2012-02-14 18:18:16 -0800 | [diff] [blame] | 43 | {
|
| 44 | bool pass = ( expected == found );
|
| 45 | if ( pass )
|
| 46 | printf ("[pass]");
|
| 47 | else
|
| 48 | printf ("[fail]");
|
| 49 |
|
U-Stream\Lee | 09a11c5 | 2012-02-17 08:31:16 -0800 | [diff] [blame] | 50 | if ( !echo )
|
Lee Thomason | 1ff38e0 | 2012-02-14 18:18:16 -0800 | [diff] [blame] | 51 | printf (" %s\n", testString);
|
| 52 | else
|
Lee Thomason | c831279 | 2012-07-16 12:44:41 -0700 | [diff] [blame] | 53 | printf (" %s [%d][%d]\n", testString, static_cast<int>(expected), static_cast<int>(found) );
|
Lee Thomason | 1ff38e0 | 2012-02-14 18:18:16 -0800 | [diff] [blame] | 54 |
|
| 55 | if ( pass )
|
| 56 | ++gPass;
|
| 57 | else
|
| 58 | ++gFail;
|
| 59 | return pass;
|
| 60 | }
|
Lee Thomason | ec5a7b4 | 2012-02-13 18:16:52 -0800 | [diff] [blame] | 61 |
|
U-Lama\Lee | e13c3e6 | 2011-12-28 14:36:55 -0800 | [diff] [blame] | 62 |
|
Lee Thomason (grinliz) | 68db57e | 2012-02-21 09:08:12 -0800 | [diff] [blame] | 63 | void NullLineEndings( char* p )
|
| 64 | {
|
| 65 | while( p && *p ) {
|
| 66 | if ( *p == '\n' || *p == '\r' ) {
|
| 67 | *p = 0;
|
| 68 | return;
|
| 69 | }
|
| 70 | ++p;
|
| 71 | }
|
| 72 | }
|
| 73 |
|
| 74 |
|
Lee Thomason (grinliz) | 6a22be2 | 2012-04-04 12:39:05 -0700 | [diff] [blame] | 75 | // Comments in the header. (Don't know how to get Doxygen to read comments in this file.)
|
| 76 | int example_1()
|
| 77 | {
|
| 78 | XMLDocument doc;
|
Bruno Dias | a2d4e6e | 2012-05-07 04:58:11 -0300 | [diff] [blame] | 79 | doc.LoadFile( "resources/dream.xml" );
|
Lee Thomason (grinliz) | 6a22be2 | 2012-04-04 12:39:05 -0700 | [diff] [blame] | 80 |
|
| 81 | return doc.ErrorID();
|
| 82 | }
|
| 83 |
|
| 84 |
|
| 85 | // Comments in the header. (Don't know how to get Doxygen to read comments in this file.)
|
| 86 | int example_2()
|
| 87 | {
|
| 88 | static const char* xml = "<element/>";
|
| 89 | XMLDocument doc;
|
| 90 | doc.Parse( xml );
|
| 91 |
|
| 92 | return doc.ErrorID();
|
| 93 | }
|
| 94 |
|
| 95 |
|
| 96 | int example_3()
|
| 97 | {
|
Lee Thomason (grinliz) | a4a36ba | 2012-04-06 21:24:29 -0700 | [diff] [blame] | 98 | static const char* xml =
|
| 99 | "<?xml version=\"1.0\"?>"
|
| 100 | "<!DOCTYPE PLAY SYSTEM \"play.dtd\">"
|
| 101 | "<PLAY>"
|
| 102 | "<TITLE>A Midsummer Night's Dream</TITLE>"
|
| 103 | "</PLAY>";
|
Lee Thomason (grinliz) | 6a22be2 | 2012-04-04 12:39:05 -0700 | [diff] [blame] | 104 |
|
| 105 | XMLDocument doc;
|
| 106 | doc.Parse( xml );
|
| 107 |
|
| 108 | XMLElement* titleElement = doc.FirstChildElement( "PLAY" )->FirstChildElement( "TITLE" );
|
| 109 | const char* title = titleElement->GetText();
|
| 110 | printf( "Name of play (1): %s\n", title );
|
| 111 |
|
| 112 | XMLText* textNode = titleElement->FirstChild()->ToText();
|
| 113 | title = textNode->Value();
|
| 114 | printf( "Name of play (2): %s\n", title );
|
| 115 |
|
| 116 | return doc.ErrorID();
|
| 117 | }
|
| 118 |
|
| 119 |
|
Lee Thomason | 21be882 | 2012-07-15 17:27:22 -0700 | [diff] [blame] | 120 | bool example_4()
|
| 121 | {
|
| 122 | static const char* xml =
|
| 123 | "<information>"
|
| 124 | " <attributeApproach v='2' />"
|
| 125 | " <textApproach>"
|
| 126 | " <v>2</v>"
|
| 127 | " </textApproach>"
|
| 128 | "</information>";
|
| 129 |
|
| 130 | XMLDocument doc;
|
| 131 | doc.Parse( xml );
|
| 132 |
|
| 133 | int v0 = 0;
|
| 134 | int v1 = 0;
|
| 135 |
|
| 136 | XMLElement* attributeApproachElement = doc.FirstChildElement()->FirstChildElement( "attributeApproach" );
|
| 137 | attributeApproachElement->QueryIntAttribute( "v", &v0 );
|
| 138 |
|
| 139 | XMLElement* textApproachElement = doc.FirstChildElement()->FirstChildElement( "textApproach" );
|
| 140 | textApproachElement->FirstChildElement( "v" )->QueryIntText( &v1 );
|
| 141 |
|
| 142 | printf( "Both values are the same: %d and %d\n", v0, v1 );
|
| 143 |
|
| 144 | return !doc.Error() && ( v0 == v1 );
|
| 145 | }
|
| 146 |
|
| 147 |
|
Guillermo A. Amaral | 2eb7003 | 2012-03-20 11:26:57 -0700 | [diff] [blame] | 148 | int main( int /*argc*/, const char ** /*argv*/ )
|
U-Lama\Lee | e13c3e6 | 2011-12-28 14:36:55 -0800 | [diff] [blame] | 149 | {
|
Lee Thomason (grinliz) | 0a4df40 | 2012-02-27 20:50:52 -0800 | [diff] [blame] | 150 | #if defined( _MSC_VER ) && defined( DEBUG )
|
Lee Thomason | 1ff38e0 | 2012-02-14 18:18:16 -0800 | [diff] [blame] | 151 | _CrtMemCheckpoint( &startMemState );
|
| 152 | #endif
|
Lee Thomason | 8a5dfee | 2012-01-18 17:43:40 -0800 | [diff] [blame] | 153 |
|
Lee Thomason | 7f7b162 | 2012-03-24 12:49:03 -0700 | [diff] [blame] | 154 | #if defined(_MSC_VER)
|
| 155 | #pragma warning ( push )
|
| 156 | #pragma warning ( disable : 4996 ) // Fail to see a compelling reason why this should be deprecated.
|
| 157 | #endif
|
| 158 |
|
Arkadiy Shapkin | ef1c69c | 2012-07-25 22:10:39 +0400 | [diff] [blame^] | 159 | mkdir( "resources/out/" );
|
Arkadiy Shapkin | ff72d1f | 2012-07-24 00:24:07 +0400 | [diff] [blame] | 160 |
|
Bruno Dias | a2d4e6e | 2012-05-07 04:58:11 -0300 | [diff] [blame] | 161 | FILE* fp = fopen( "resources/dream.xml", "r" );
|
Lee Thomason | 7f7b162 | 2012-03-24 12:49:03 -0700 | [diff] [blame] | 162 | if ( !fp ) {
|
| 163 | printf( "Error opening test file 'dream.xml'.\n"
|
| 164 | "Is your working directory the same as where \n"
|
| 165 | "the xmltest.cpp and dream.xml file are?\n\n"
|
| 166 | #if defined( _MSC_VER )
|
| 167 | "In windows Visual Studio you may need to set\n"
|
| 168 | "Properties->Debugging->Working Directory to '..'\n"
|
| 169 | #endif
|
| 170 | );
|
| 171 | exit( 1 );
|
| 172 | }
|
| 173 | fclose( fp );
|
| 174 |
|
| 175 | #if defined(_MSC_VER)
|
| 176 | #pragma warning ( pop )
|
| 177 | #endif
|
| 178 |
|
Lee Thomason (grinliz) | 6a22be2 | 2012-04-04 12:39:05 -0700 | [diff] [blame] | 179 | XMLTest( "Example-1", 0, example_1() );
|
| 180 | XMLTest( "Example-2", 0, example_2() );
|
| 181 | XMLTest( "Example-3", 0, example_3() );
|
Lee Thomason | 21be882 | 2012-07-15 17:27:22 -0700 | [diff] [blame] | 182 | XMLTest( "Example-4", true, example_4() );
|
Lee Thomason | 87e475a | 2012-03-20 11:55:29 -0700 | [diff] [blame] | 183 |
|
Lee Thomason (grinliz) | 6a22be2 | 2012-04-04 12:39:05 -0700 | [diff] [blame] | 184 | /* ------ Example 2: Lookup information. ---- */
|
Lee Thomason | 87e475a | 2012-03-20 11:55:29 -0700 | [diff] [blame] | 185 |
|
Lee Thomason | 8a5dfee | 2012-01-18 17:43:40 -0800 | [diff] [blame] | 186 | {
|
Lee Thomason | 43f5930 | 2012-02-06 18:18:11 -0800 | [diff] [blame] | 187 | static const char* test[] = { "<element />",
|
Arkadiy Shapkin | ef1c69c | 2012-07-25 22:10:39 +0400 | [diff] [blame^] | 188 | "<element></element>",
|
Lee Thomason | 43f5930 | 2012-02-06 18:18:11 -0800 | [diff] [blame] | 189 | "<element><subelement/></element>",
|
Arkadiy Shapkin | ef1c69c | 2012-07-25 22:10:39 +0400 | [diff] [blame^] | 190 | "<element><subelement></subelement></element>",
|
| 191 | "<element><subelement><subsub/></subelement></element>",
|
| 192 | "<!--comment beside elements--><element><subelement></subelement></element>",
|
| 193 | "<!--comment beside elements, this time with spaces--> \n <element> <subelement> \n </subelement> </element>",
|
| 194 | "<element attrib1='foo' attrib2=\"bar\" ></element>",
|
| 195 | "<element attrib1='foo' attrib2=\"bar\" ><subelement attrib3='yeehaa' /></element>",
|
Lee Thomason | 43f5930 | 2012-02-06 18:18:11 -0800 | [diff] [blame] | 196 | "<element>Text inside element.</element>",
|
| 197 | "<element><b></b></element>",
|
| 198 | "<element>Text inside and <b>bolded</b> in the element.</element>",
|
| 199 | "<outer><element>Text inside and <b>bolded</b> in the element.</element></outer>",
|
Lee Thomason | 8ee7989 | 2012-01-25 17:44:30 -0800 | [diff] [blame] | 200 | "<element>This & That.</element>",
|
Lee Thomason | 18d68bd | 2012-01-26 18:17:26 -0800 | [diff] [blame] | 201 | "<element attrib='This<That' />",
|
Lee Thomason | dadcdfa | 2012-01-18 17:55:48 -0800 | [diff] [blame] | 202 | 0
|
| 203 | };
|
Lee Thomason | 6ee99fc | 2012-01-21 18:45:16 -0800 | [diff] [blame] | 204 | for( int i=0; test[i]; ++i ) {
|
Lee Thomason | dadcdfa | 2012-01-18 17:55:48 -0800 | [diff] [blame] | 205 | XMLDocument doc;
|
Lee Thomason | 6ee99fc | 2012-01-21 18:45:16 -0800 | [diff] [blame] | 206 | doc.Parse( test[i] );
|
Lee Thomason | 5cae897 | 2012-01-24 18:03:07 -0800 | [diff] [blame] | 207 | doc.Print();
|
Lee Thomason | ec975ce | 2012-01-23 11:42:06 -0800 | [diff] [blame] | 208 | printf( "----------------------------------------------\n" );
|
Lee Thomason | dadcdfa | 2012-01-18 17:55:48 -0800 | [diff] [blame] | 209 | }
|
U-Lama\Lee | 4cee611 | 2011-12-31 14:58:18 -0800 | [diff] [blame] | 210 | }
|
Lee Thomason (grinliz) | 46a14cf | 2012-02-23 22:27:28 -0800 | [diff] [blame] | 211 | #if 1
|
Lee Thomason | d627776 | 2012-02-22 16:00:12 -0800 | [diff] [blame] | 212 | {
|
| 213 | static const char* test = "<!--hello world\n"
|
Arkadiy Shapkin | ef1c69c | 2012-07-25 22:10:39 +0400 | [diff] [blame^] | 214 | " line 2\r"
|
| 215 | " line 3\r\n"
|
| 216 | " line 4\n\r"
|
| 217 | " line 5\r-->";
|
Lee Thomason | d627776 | 2012-02-22 16:00:12 -0800 | [diff] [blame] | 218 |
|
| 219 | XMLDocument doc;
|
| 220 | doc.Parse( test );
|
| 221 | doc.Print();
|
| 222 | }
|
| 223 |
|
Lee Thomason | 2c85a71 | 2012-01-31 08:24:24 -0800 | [diff] [blame] | 224 | {
|
| 225 | static const char* test = "<element>Text before.</element>";
|
| 226 | XMLDocument doc;
|
| 227 | doc.Parse( test );
|
| 228 | XMLElement* root = doc.FirstChildElement();
|
| 229 | XMLElement* newElement = doc.NewElement( "Subelement" );
|
| 230 | root->InsertEndChild( newElement );
|
| 231 | doc.Print();
|
| 232 | }
|
Lee Thomason | d198322 | 2012-02-06 08:41:24 -0800 | [diff] [blame] | 233 | {
|
| 234 | XMLDocument* doc = new XMLDocument();
|
| 235 | static const char* test = "<element><sub/></element>";
|
| 236 | doc->Parse( test );
|
| 237 | delete doc;
|
| 238 | }
|
Lee Thomason | e9ecdab | 2012-02-13 18:11:20 -0800 | [diff] [blame] | 239 | {
|
Lee Thomason | 1ff38e0 | 2012-02-14 18:18:16 -0800 | [diff] [blame] | 240 | // Test: Programmatic DOM
|
Lee Thomason | ec5a7b4 | 2012-02-13 18:16:52 -0800 | [diff] [blame] | 241 | // Build:
|
| 242 | // <element>
|
| 243 | // <!--comment-->
|
| 244 | // <sub attrib="1" />
|
| 245 | // <sub attrib="2" />
|
U-Stream\Lee | 09a11c5 | 2012-02-17 08:31:16 -0800 | [diff] [blame] | 246 | // <sub attrib="3" >& Text!</sub>
|
Lee Thomason | ec5a7b4 | 2012-02-13 18:16:52 -0800 | [diff] [blame] | 247 | // <element>
|
| 248 |
|
Lee Thomason | e9ecdab | 2012-02-13 18:11:20 -0800 | [diff] [blame] | 249 | XMLDocument* doc = new XMLDocument();
|
Lee Thomason | 1ff38e0 | 2012-02-14 18:18:16 -0800 | [diff] [blame] | 250 | XMLNode* element = doc->InsertEndChild( doc->NewElement( "element" ) );
|
| 251 |
|
| 252 | XMLElement* sub[3] = { doc->NewElement( "sub" ), doc->NewElement( "sub" ), doc->NewElement( "sub" ) };
|
| 253 | for( int i=0; i<3; ++i ) {
|
| 254 | sub[i]->SetAttribute( "attrib", i );
|
| 255 | }
|
| 256 | element->InsertEndChild( sub[2] );
|
| 257 | XMLNode* comment = element->InsertFirstChild( doc->NewComment( "comment" ) );
|
| 258 | element->InsertAfterChild( comment, sub[0] );
|
| 259 | element->InsertAfterChild( sub[0], sub[1] );
|
U-Stream\Lee | 09a11c5 | 2012-02-17 08:31:16 -0800 | [diff] [blame] | 260 | sub[2]->InsertFirstChild( doc->NewText( "& Text!" ));
|
Lee Thomason | e9ecdab | 2012-02-13 18:11:20 -0800 | [diff] [blame] | 261 | doc->Print();
|
U-Stream\Lee | 09a11c5 | 2012-02-17 08:31:16 -0800 | [diff] [blame] | 262 | XMLTest( "Programmatic DOM", "comment", doc->FirstChildElement( "element" )->FirstChild()->Value() );
|
| 263 | XMLTest( "Programmatic DOM", "0", doc->FirstChildElement( "element" )->FirstChildElement()->Attribute( "attrib" ) );
|
| 264 | XMLTest( "Programmatic DOM", 2, doc->FirstChildElement()->LastChildElement( "sub" )->IntAttribute( "attrib" ) );
|
| 265 | XMLTest( "Programmatic DOM", "& Text!",
|
| 266 | doc->FirstChildElement()->LastChildElement( "sub" )->FirstChild()->ToText()->Value() );
|
U-Stream\Lee | ae25a44 | 2012-02-17 17:48:16 -0800 | [diff] [blame] | 267 |
|
| 268 | // And now deletion:
|
| 269 | element->DeleteChild( sub[2] );
|
| 270 | doc->DeleteNode( comment );
|
| 271 |
|
| 272 | element->FirstChildElement()->SetAttribute( "attrib", true );
|
| 273 | element->LastChildElement()->DeleteAttribute( "attrib" );
|
| 274 |
|
| 275 | XMLTest( "Programmatic DOM", true, doc->FirstChildElement()->FirstChildElement()->BoolAttribute( "attrib" ) );
|
| 276 | int value = 10;
|
| 277 | int result = doc->FirstChildElement()->LastChildElement()->QueryIntAttribute( "attrib", &value );
|
Lee Thomason | 21be882 | 2012-07-15 17:27:22 -0700 | [diff] [blame] | 278 | XMLTest( "Programmatic DOM", result, (int)XML_NO_ATTRIBUTE );
|
U-Stream\Lee | ae25a44 | 2012-02-17 17:48:16 -0800 | [diff] [blame] | 279 | XMLTest( "Programmatic DOM", value, 10 );
|
| 280 |
|
| 281 | doc->Print();
|
| 282 |
|
Lee Thomason | 7b1b86a | 2012-06-04 17:01:38 -0700 | [diff] [blame] | 283 | {
|
| 284 | XMLPrinter streamer;
|
| 285 | doc->Print( &streamer );
|
| 286 | printf( "%s", streamer.CStr() );
|
| 287 | }
|
| 288 | {
|
| 289 | XMLPrinter streamer( 0, true );
|
| 290 | doc->Print( &streamer );
|
| 291 | XMLTest( "Compact mode", "<element><sub attrib=\"1\"/><sub/></element>", streamer.CStr(), false );
|
| 292 | }
|
Lee Thomason | e9ecdab | 2012-02-13 18:11:20 -0800 | [diff] [blame] | 293 | delete doc;
|
| 294 | }
|
Lee Thomason (grinliz) | bd0a8ac | 2012-02-20 20:14:33 -0800 | [diff] [blame] | 295 | {
|
| 296 | // Test: Dream
|
| 297 | // XML1 : 1,187,569 bytes in 31,209 allocations
|
| 298 | // XML2 : 469,073 bytes in 323 allocations
|
| 299 | //int newStart = gNew;
|
| 300 | XMLDocument doc;
|
Bruno Dias | a2d4e6e | 2012-05-07 04:58:11 -0300 | [diff] [blame] | 301 | doc.LoadFile( "resources/dream.xml" );
|
Lee Thomason (grinliz) | bd0a8ac | 2012-02-20 20:14:33 -0800 | [diff] [blame] | 302 |
|
Arkadiy Shapkin | ff72d1f | 2012-07-24 00:24:07 +0400 | [diff] [blame] | 303 | doc.SaveFile( "resources/out/dreamout.xml" );
|
Lee Thomason (grinliz) | bd0a8ac | 2012-02-20 20:14:33 -0800 | [diff] [blame] | 304 | doc.PrintError();
|
| 305 |
|
| 306 | XMLTest( "Dream", "xml version=\"1.0\"",
|
Arkadiy Shapkin | ef1c69c | 2012-07-25 22:10:39 +0400 | [diff] [blame^] | 307 | doc.FirstChild()->ToDeclaration()->Value() );
|
Lee Thomason (grinliz) | bd0a8ac | 2012-02-20 20:14:33 -0800 | [diff] [blame] | 308 | XMLTest( "Dream", true, doc.FirstChild()->NextSibling()->ToUnknown() ? true : false );
|
| 309 | XMLTest( "Dream", "DOCTYPE PLAY SYSTEM \"play.dtd\"",
|
| 310 | doc.FirstChild()->NextSibling()->ToUnknown()->Value() );
|
| 311 | XMLTest( "Dream", "And Robin shall restore amends.",
|
Arkadiy Shapkin | ef1c69c | 2012-07-25 22:10:39 +0400 | [diff] [blame^] | 312 | doc.LastChild()->LastChild()->LastChild()->LastChild()->LastChildElement()->GetText() );
|
Lee Thomason (grinliz) | bd0a8ac | 2012-02-20 20:14:33 -0800 | [diff] [blame] | 313 | XMLTest( "Dream", "And Robin shall restore amends.",
|
Arkadiy Shapkin | ef1c69c | 2012-07-25 22:10:39 +0400 | [diff] [blame^] | 314 | doc.LastChild()->LastChild()->LastChild()->LastChild()->LastChildElement()->GetText() );
|
Lee Thomason (grinliz) | bd0a8ac | 2012-02-20 20:14:33 -0800 | [diff] [blame] | 315 |
|
| 316 | XMLDocument doc2;
|
Arkadiy Shapkin | ff72d1f | 2012-07-24 00:24:07 +0400 | [diff] [blame] | 317 | doc2.LoadFile( "resources/out/dreamout.xml" );
|
Lee Thomason (grinliz) | bd0a8ac | 2012-02-20 20:14:33 -0800 | [diff] [blame] | 318 | XMLTest( "Dream-out", "xml version=\"1.0\"",
|
Arkadiy Shapkin | ef1c69c | 2012-07-25 22:10:39 +0400 | [diff] [blame^] | 319 | doc2.FirstChild()->ToDeclaration()->Value() );
|
Lee Thomason (grinliz) | bd0a8ac | 2012-02-20 20:14:33 -0800 | [diff] [blame] | 320 | XMLTest( "Dream-out", true, doc2.FirstChild()->NextSibling()->ToUnknown() ? true : false );
|
| 321 | XMLTest( "Dream-out", "DOCTYPE PLAY SYSTEM \"play.dtd\"",
|
| 322 | doc2.FirstChild()->NextSibling()->ToUnknown()->Value() );
|
| 323 | XMLTest( "Dream-out", "And Robin shall restore amends.",
|
Arkadiy Shapkin | ef1c69c | 2012-07-25 22:10:39 +0400 | [diff] [blame^] | 324 | doc2.LastChild()->LastChild()->LastChild()->LastChild()->LastChildElement()->GetText() );
|
Lee Thomason (grinliz) | bd0a8ac | 2012-02-20 20:14:33 -0800 | [diff] [blame] | 325 |
|
| 326 | //gNewTotal = gNew - newStart;
|
| 327 | }
|
Lee Thomason | 6f381b7 | 2012-03-02 12:59:39 -0800 | [diff] [blame] | 328 |
|
| 329 |
|
Lee Thomason (grinliz) | 68db57e | 2012-02-21 09:08:12 -0800 | [diff] [blame] | 330 | {
|
| 331 | const char* error = "<?xml version=\"1.0\" standalone=\"no\" ?>\n"
|
| 332 | "<passages count=\"006\" formatversion=\"20020620\">\n"
|
| 333 | " <wrong error>\n"
|
| 334 | "</passages>";
|
| 335 |
|
| 336 | XMLDocument doc;
|
| 337 | doc.Parse( error );
|
Lee Thomason | 21be882 | 2012-07-15 17:27:22 -0700 | [diff] [blame] | 338 | XMLTest( "Bad XML", doc.ErrorID(), (int)XML_ERROR_PARSING_ATTRIBUTE );
|
Lee Thomason (grinliz) | 68db57e | 2012-02-21 09:08:12 -0800 | [diff] [blame] | 339 | }
|
| 340 |
|
| 341 | {
|
| 342 | const char* str = "<doc attr0='1' attr1='2.0' attr2='foo' />";
|
| 343 |
|
| 344 | XMLDocument doc;
|
| 345 | doc.Parse( str );
|
| 346 |
|
| 347 | XMLElement* ele = doc.FirstChildElement();
|
| 348 |
|
| 349 | int iVal, result;
|
| 350 | double dVal;
|
| 351 |
|
| 352 | result = ele->QueryDoubleAttribute( "attr0", &dVal );
|
Lee Thomason | 21be882 | 2012-07-15 17:27:22 -0700 | [diff] [blame] | 353 | XMLTest( "Query attribute: int as double", result, (int)XML_NO_ERROR );
|
Lee Thomason (grinliz) | 68db57e | 2012-02-21 09:08:12 -0800 | [diff] [blame] | 354 | XMLTest( "Query attribute: int as double", (int)dVal, 1 );
|
| 355 | result = ele->QueryDoubleAttribute( "attr1", &dVal );
|
| 356 | XMLTest( "Query attribute: double as double", (int)dVal, 2 );
|
| 357 | result = ele->QueryIntAttribute( "attr1", &iVal );
|
Lee Thomason | 21be882 | 2012-07-15 17:27:22 -0700 | [diff] [blame] | 358 | XMLTest( "Query attribute: double as int", result, (int)XML_NO_ERROR );
|
Lee Thomason (grinliz) | 68db57e | 2012-02-21 09:08:12 -0800 | [diff] [blame] | 359 | XMLTest( "Query attribute: double as int", iVal, 2 );
|
| 360 | result = ele->QueryIntAttribute( "attr2", &iVal );
|
Lee Thomason | 21be882 | 2012-07-15 17:27:22 -0700 | [diff] [blame] | 361 | XMLTest( "Query attribute: not a number", result, (int)XML_WRONG_ATTRIBUTE_TYPE );
|
Lee Thomason (grinliz) | 68db57e | 2012-02-21 09:08:12 -0800 | [diff] [blame] | 362 | result = ele->QueryIntAttribute( "bar", &iVal );
|
Lee Thomason | 21be882 | 2012-07-15 17:27:22 -0700 | [diff] [blame] | 363 | XMLTest( "Query attribute: does not exist", result, (int)XML_NO_ATTRIBUTE );
|
Lee Thomason (grinliz) | 68db57e | 2012-02-21 09:08:12 -0800 | [diff] [blame] | 364 | }
|
| 365 |
|
| 366 | {
|
| 367 | const char* str = "<doc/>";
|
| 368 |
|
| 369 | XMLDocument doc;
|
| 370 | doc.Parse( str );
|
| 371 |
|
| 372 | XMLElement* ele = doc.FirstChildElement();
|
| 373 |
|
| 374 | int iVal;
|
| 375 | double dVal;
|
| 376 |
|
| 377 | ele->SetAttribute( "str", "strValue" );
|
| 378 | ele->SetAttribute( "int", 1 );
|
| 379 | ele->SetAttribute( "double", -1.0 );
|
| 380 |
|
| 381 | const char* cStr = ele->Attribute( "str" );
|
| 382 | ele->QueryIntAttribute( "int", &iVal );
|
| 383 | ele->QueryDoubleAttribute( "double", &dVal );
|
| 384 |
|
Lee Thomason | 8ba7f7d | 2012-03-24 13:04:04 -0700 | [diff] [blame] | 385 | XMLTest( "Attribute match test", ele->Attribute( "str", "strValue" ), "strValue" );
|
Lee Thomason (grinliz) | 68db57e | 2012-02-21 09:08:12 -0800 | [diff] [blame] | 386 | XMLTest( "Attribute round trip. c-string.", "strValue", cStr );
|
| 387 | XMLTest( "Attribute round trip. int.", 1, iVal );
|
| 388 | XMLTest( "Attribute round trip. double.", -1, (int)dVal );
|
| 389 | }
|
| 390 |
|
Lee Thomason (grinliz) | 68db57e | 2012-02-21 09:08:12 -0800 | [diff] [blame] | 391 | {
|
| 392 | XMLDocument doc;
|
Bruno Dias | a2d4e6e | 2012-05-07 04:58:11 -0300 | [diff] [blame] | 393 | doc.LoadFile( "resources/utf8test.xml" );
|
Lee Thomason (grinliz) | 68db57e | 2012-02-21 09:08:12 -0800 | [diff] [blame] | 394 |
|
| 395 | // Get the attribute "value" from the "Russian" element and check it.
|
| 396 | XMLElement* element = doc.FirstChildElement( "document" )->FirstChildElement( "Russian" );
|
| 397 | const unsigned char correctValue[] = { 0xd1U, 0x86U, 0xd0U, 0xb5U, 0xd0U, 0xbdU, 0xd0U, 0xbdU,
|
| 398 | 0xd0U, 0xbeU, 0xd1U, 0x81U, 0xd1U, 0x82U, 0xd1U, 0x8cU, 0 };
|
| 399 |
|
| 400 | XMLTest( "UTF-8: Russian value.", (const char*)correctValue, element->Attribute( "value" ) );
|
| 401 |
|
| 402 | const unsigned char russianElementName[] = { 0xd0U, 0xa0U, 0xd1U, 0x83U,
|
| 403 | 0xd1U, 0x81U, 0xd1U, 0x81U,
|
| 404 | 0xd0U, 0xbaU, 0xd0U, 0xb8U,
|
| 405 | 0xd0U, 0xb9U, 0 };
|
| 406 | const char russianText[] = "<\xD0\xB8\xD0\xBC\xD0\xB5\xD0\xB5\xD1\x82>";
|
| 407 |
|
| 408 | XMLText* text = doc.FirstChildElement( "document" )->FirstChildElement( (const char*) russianElementName )->FirstChild()->ToText();
|
| 409 | XMLTest( "UTF-8: Browsing russian element name.",
|
| 410 | russianText,
|
| 411 | text->Value() );
|
| 412 |
|
| 413 | // Now try for a round trip.
|
Arkadiy Shapkin | ff72d1f | 2012-07-24 00:24:07 +0400 | [diff] [blame] | 414 | doc.SaveFile( "resources/out/utf8testout.xml" );
|
Lee Thomason (grinliz) | 68db57e | 2012-02-21 09:08:12 -0800 | [diff] [blame] | 415 |
|
| 416 | // Check the round trip.
|
Lee Thomason (grinliz) | 68db57e | 2012-02-21 09:08:12 -0800 | [diff] [blame] | 417 | int okay = 0;
|
| 418 |
|
Lee Thomason (grinliz) | 5ce4d97 | 2012-02-26 21:14:23 -0800 | [diff] [blame] | 419 |
|
Lee Thomason | 7d00b9a | 2012-02-27 17:54:22 -0800 | [diff] [blame] | 420 | #if defined(_MSC_VER)
|
Lee Thomason (grinliz) | 5ce4d97 | 2012-02-26 21:14:23 -0800 | [diff] [blame] | 421 | #pragma warning ( push )
|
| 422 | #pragma warning ( disable : 4996 ) // Fail to see a compelling reason why this should be deprecated.
|
Lee Thomason | 7d00b9a | 2012-02-27 17:54:22 -0800 | [diff] [blame] | 423 | #endif
|
Bruno Dias | a2d4e6e | 2012-05-07 04:58:11 -0300 | [diff] [blame] | 424 | FILE* saved = fopen( "resources/utf8testout.xml", "r" );
|
| 425 | FILE* verify = fopen( "resources/utf8testverify.xml", "r" );
|
Lee Thomason | 7d00b9a | 2012-02-27 17:54:22 -0800 | [diff] [blame] | 426 | #if defined(_MSC_VER)
|
Lee Thomason (grinliz) | 5ce4d97 | 2012-02-26 21:14:23 -0800 | [diff] [blame] | 427 | #pragma warning ( pop )
|
Lee Thomason | 7d00b9a | 2012-02-27 17:54:22 -0800 | [diff] [blame] | 428 | #endif
|
Lee Thomason (grinliz) | 68db57e | 2012-02-21 09:08:12 -0800 | [diff] [blame] | 429 |
|
| 430 | if ( saved && verify )
|
| 431 | {
|
| 432 | okay = 1;
|
PKEuS | c28ba3a | 2012-07-16 03:08:47 -0700 | [diff] [blame] | 433 | char verifyBuf[256];
|
Lee Thomason (grinliz) | 68db57e | 2012-02-21 09:08:12 -0800 | [diff] [blame] | 434 | while ( fgets( verifyBuf, 256, verify ) )
|
| 435 | {
|
PKEuS | c28ba3a | 2012-07-16 03:08:47 -0700 | [diff] [blame] | 436 | char savedBuf[256];
|
Lee Thomason (grinliz) | 68db57e | 2012-02-21 09:08:12 -0800 | [diff] [blame] | 437 | fgets( savedBuf, 256, saved );
|
| 438 | NullLineEndings( verifyBuf );
|
| 439 | NullLineEndings( savedBuf );
|
| 440 |
|
| 441 | if ( strcmp( verifyBuf, savedBuf ) )
|
| 442 | {
|
| 443 | printf( "verify:%s<\n", verifyBuf );
|
| 444 | printf( "saved :%s<\n", savedBuf );
|
| 445 | okay = 0;
|
| 446 | break;
|
| 447 | }
|
| 448 | }
|
| 449 | }
|
| 450 | if ( saved )
|
| 451 | fclose( saved );
|
| 452 | if ( verify )
|
| 453 | fclose( verify );
|
| 454 | XMLTest( "UTF-8: Verified multi-language round trip.", 1, okay );
|
| 455 | }
|
| 456 |
|
Lee Thomason (grinliz) | 46a14cf | 2012-02-23 22:27:28 -0800 | [diff] [blame] | 457 | // --------GetText()-----------
|
| 458 | {
|
| 459 | const char* str = "<foo>This is text</foo>";
|
| 460 | XMLDocument doc;
|
| 461 | doc.Parse( str );
|
| 462 | const XMLElement* element = doc.RootElement();
|
| 463 |
|
| 464 | XMLTest( "GetText() normal use.", "This is text", element->GetText() );
|
| 465 |
|
| 466 | str = "<foo><b>This is text</b></foo>";
|
| 467 | doc.Parse( str );
|
| 468 | element = doc.RootElement();
|
| 469 |
|
| 470 | XMLTest( "GetText() contained element.", element->GetText() == 0, true );
|
| 471 | }
|
Lee Thomason (grinliz) | 68db57e | 2012-02-21 09:08:12 -0800 | [diff] [blame] | 472 |
|
Lee Thomason | d627776 | 2012-02-22 16:00:12 -0800 | [diff] [blame] | 473 |
|
Lee Thomason (grinliz) | 46a14cf | 2012-02-23 22:27:28 -0800 | [diff] [blame] | 474 | // ---------- CDATA ---------------
|
| 475 | {
|
| 476 | const char* str = "<xmlElement>"
|
| 477 | "<![CDATA["
|
| 478 | "I am > the rules!\n"
|
| 479 | "...since I make symbolic puns"
|
| 480 | "]]>"
|
| 481 | "</xmlElement>";
|
| 482 | XMLDocument doc;
|
| 483 | doc.Parse( str );
|
| 484 | doc.Print();
|
Lee Thomason | d627776 | 2012-02-22 16:00:12 -0800 | [diff] [blame] | 485 |
|
Lee Thomason (grinliz) | 46a14cf | 2012-02-23 22:27:28 -0800 | [diff] [blame] | 486 | XMLTest( "CDATA parse.", doc.FirstChildElement()->FirstChild()->Value(),
|
| 487 | "I am > the rules!\n...since I make symbolic puns",
|
Lee Thomason | d627776 | 2012-02-22 16:00:12 -0800 | [diff] [blame] | 488 | false );
|
| 489 | }
|
| 490 |
|
Lee Thomason (grinliz) | 46a14cf | 2012-02-23 22:27:28 -0800 | [diff] [blame] | 491 | // ----------- CDATA -------------
|
| 492 | {
|
| 493 | const char* str = "<xmlElement>"
|
| 494 | "<![CDATA["
|
| 495 | "<b>I am > the rules!</b>\n"
|
| 496 | "...since I make symbolic puns"
|
| 497 | "]]>"
|
| 498 | "</xmlElement>";
|
| 499 | XMLDocument doc;
|
| 500 | doc.Parse( str );
|
| 501 | doc.Print();
|
| 502 |
|
| 503 | XMLTest( "CDATA parse. [ tixml1:1480107 ]", doc.FirstChildElement()->FirstChild()->Value(),
|
| 504 | "<b>I am > the rules!</b>\n...since I make symbolic puns",
|
| 505 | false );
|
| 506 | }
|
| 507 |
|
| 508 | // InsertAfterChild causes crash.
|
| 509 | {
|
| 510 | // InsertBeforeChild and InsertAfterChild causes crash.
|
| 511 | XMLDocument doc;
|
| 512 | XMLElement* parent = doc.NewElement( "Parent" );
|
| 513 | doc.InsertFirstChild( parent );
|
| 514 |
|
| 515 | XMLElement* childText0 = doc.NewElement( "childText0" );
|
| 516 | XMLElement* childText1 = doc.NewElement( "childText1" );
|
| 517 |
|
| 518 | XMLNode* childNode0 = parent->InsertEndChild( childText0 );
|
| 519 | XMLNode* childNode1 = parent->InsertAfterChild( childNode0, childText1 );
|
| 520 |
|
| 521 | XMLTest( "Test InsertAfterChild on empty node. ", ( childNode1 == parent->LastChild() ), true );
|
| 522 | }
|
Lee Thomason | d627776 | 2012-02-22 16:00:12 -0800 | [diff] [blame] | 523 |
|
| 524 | {
|
Lee Thomason (grinliz) | 46a14cf | 2012-02-23 22:27:28 -0800 | [diff] [blame] | 525 | // Entities not being written correctly.
|
| 526 | // From Lynn Allen
|
Lee Thomason | d627776 | 2012-02-22 16:00:12 -0800 | [diff] [blame] | 527 |
|
Lee Thomason (grinliz) | 46a14cf | 2012-02-23 22:27:28 -0800 | [diff] [blame] | 528 | const char* passages =
|
| 529 | "<?xml version=\"1.0\" standalone=\"no\" ?>"
|
| 530 | "<passages count=\"006\" formatversion=\"20020620\">"
|
| 531 | "<psg context=\"Line 5 has "quotation marks" and 'apostrophe marks'."
|
| 532 | " It also has <, >, and &, as well as a fake copyright ©.\"> </psg>"
|
| 533 | "</passages>";
|
Lee Thomason | d627776 | 2012-02-22 16:00:12 -0800 | [diff] [blame] | 534 |
|
Lee Thomason (grinliz) | 46a14cf | 2012-02-23 22:27:28 -0800 | [diff] [blame] | 535 | XMLDocument doc;
|
| 536 | doc.Parse( passages );
|
| 537 | XMLElement* psg = doc.RootElement()->FirstChildElement();
|
| 538 | const char* context = psg->Attribute( "context" );
|
| 539 | const char* expected = "Line 5 has \"quotation marks\" and 'apostrophe marks'. It also has <, >, and &, as well as a fake copyright \xC2\xA9.";
|
Lee Thomason | d627776 | 2012-02-22 16:00:12 -0800 | [diff] [blame] | 540 |
|
Lee Thomason (grinliz) | 46a14cf | 2012-02-23 22:27:28 -0800 | [diff] [blame] | 541 | XMLTest( "Entity transformation: read. ", expected, context, true );
|
Lee Thomason | d627776 | 2012-02-22 16:00:12 -0800 | [diff] [blame] | 542 |
|
Lee Thomason | 7d00b9a | 2012-02-27 17:54:22 -0800 | [diff] [blame] | 543 | #if defined(_MSC_VER)
|
Lee Thomason (grinliz) | 5ce4d97 | 2012-02-26 21:14:23 -0800 | [diff] [blame] | 544 | #pragma warning ( push )
|
| 545 | #pragma warning ( disable : 4996 ) // Fail to see a compelling reason why this should be deprecated.
|
Lee Thomason | 7d00b9a | 2012-02-27 17:54:22 -0800 | [diff] [blame] | 546 | #endif
|
Arkadiy Shapkin | ff72d1f | 2012-07-24 00:24:07 +0400 | [diff] [blame] | 547 | FILE* textfile = fopen( "resources/out/textfile.txt", "w" );
|
Lee Thomason | 7d00b9a | 2012-02-27 17:54:22 -0800 | [diff] [blame] | 548 | #if defined(_MSC_VER)
|
Lee Thomason (grinliz) | 5ce4d97 | 2012-02-26 21:14:23 -0800 | [diff] [blame] | 549 | #pragma warning ( pop )
|
Lee Thomason | 7d00b9a | 2012-02-27 17:54:22 -0800 | [diff] [blame] | 550 | #endif
|
Lee Thomason (grinliz) | 46a14cf | 2012-02-23 22:27:28 -0800 | [diff] [blame] | 551 | if ( textfile )
|
| 552 | {
|
Lee Thomason (grinliz) | 2a1cd27 | 2012-02-24 17:37:53 -0800 | [diff] [blame] | 553 | XMLPrinter streamer( textfile );
|
Lee Thomason (grinliz) | 46a14cf | 2012-02-23 22:27:28 -0800 | [diff] [blame] | 554 | psg->Accept( &streamer );
|
| 555 | fclose( textfile );
|
| 556 | }
|
Lee Thomason | 7d00b9a | 2012-02-27 17:54:22 -0800 | [diff] [blame] | 557 | #if defined(_MSC_VER)
|
Lee Thomason (grinliz) | 5ce4d97 | 2012-02-26 21:14:23 -0800 | [diff] [blame] | 558 | #pragma warning ( push )
|
| 559 | #pragma warning ( disable : 4996 ) // Fail to see a compelling reason why this should be deprecated.
|
Lee Thomason | 7d00b9a | 2012-02-27 17:54:22 -0800 | [diff] [blame] | 560 | #endif
|
Arkadiy Shapkin | ff72d1f | 2012-07-24 00:24:07 +0400 | [diff] [blame] | 561 | textfile = fopen( "resources/out/textfile.txt", "r" );
|
Lee Thomason | 7d00b9a | 2012-02-27 17:54:22 -0800 | [diff] [blame] | 562 | #if defined(_MSC_VER)
|
Lee Thomason (grinliz) | 5ce4d97 | 2012-02-26 21:14:23 -0800 | [diff] [blame] | 563 | #pragma warning ( pop )
|
Lee Thomason | 7d00b9a | 2012-02-27 17:54:22 -0800 | [diff] [blame] | 564 | #endif
|
Lee Thomason (grinliz) | 46a14cf | 2012-02-23 22:27:28 -0800 | [diff] [blame] | 565 | TIXMLASSERT( textfile );
|
| 566 | if ( textfile )
|
| 567 | {
|
| 568 | char buf[ 1024 ];
|
| 569 | fgets( buf, 1024, textfile );
|
| 570 | XMLTest( "Entity transformation: write. ",
|
| 571 | "<psg context=\"Line 5 has "quotation marks" and 'apostrophe marks'."
|
| 572 | " It also has <, >, and &, as well as a fake copyright \xC2\xA9.\"/>\n",
|
| 573 | buf, false );
|
PKEuS | c28ba3a | 2012-07-16 03:08:47 -0700 | [diff] [blame] | 574 | fclose( textfile );
|
Lee Thomason (grinliz) | 46a14cf | 2012-02-23 22:27:28 -0800 | [diff] [blame] | 575 | }
|
Lee Thomason (grinliz) | 46a14cf | 2012-02-23 22:27:28 -0800 | [diff] [blame] | 576 | }
|
| 577 |
|
| 578 | {
|
Lee Thomason | 6f381b7 | 2012-03-02 12:59:39 -0800 | [diff] [blame] | 579 | // Suppress entities.
|
| 580 | const char* passages =
|
| 581 | "<?xml version=\"1.0\" standalone=\"no\" ?>"
|
| 582 | "<passages count=\"006\" formatversion=\"20020620\">"
|
| 583 | "<psg context=\"Line 5 has "quotation marks" and 'apostrophe marks'.\">Crazy &ttk;</psg>"
|
| 584 | "</passages>";
|
| 585 |
|
| 586 | XMLDocument doc( false );
|
| 587 | doc.Parse( passages );
|
| 588 |
|
| 589 | XMLTest( "No entity parsing.", doc.FirstChildElement()->FirstChildElement()->Attribute( "context" ),
|
| 590 | "Line 5 has "quotation marks" and 'apostrophe marks'." );
|
| 591 | XMLTest( "No entity parsing.", doc.FirstChildElement()->FirstChildElement()->FirstChild()->Value(),
|
| 592 | "Crazy &ttk;" );
|
| 593 | doc.Print();
|
| 594 | }
|
| 595 |
|
| 596 | {
|
Arkadiy Shapkin | ef1c69c | 2012-07-25 22:10:39 +0400 | [diff] [blame^] | 597 | const char* test = "<?xml version='1.0'?><a.elem xmi.version='2.0'/>";
|
Lee Thomason (grinliz) | 46a14cf | 2012-02-23 22:27:28 -0800 | [diff] [blame] | 598 |
|
| 599 | XMLDocument doc;
|
Arkadiy Shapkin | ef1c69c | 2012-07-25 22:10:39 +0400 | [diff] [blame^] | 600 | doc.Parse( test );
|
| 601 | XMLTest( "dot in names", doc.Error(), false );
|
| 602 | XMLTest( "dot in names", doc.FirstChildElement()->Name(), "a.elem" );
|
| 603 | XMLTest( "dot in names", doc.FirstChildElement()->Attribute( "xmi.version" ), "2.0" );
|
Lee Thomason (grinliz) | 46a14cf | 2012-02-23 22:27:28 -0800 | [diff] [blame] | 604 | }
|
| 605 |
|
| 606 | {
|
Arkadiy Shapkin | ef1c69c | 2012-07-25 22:10:39 +0400 | [diff] [blame^] | 607 | const char* test = "<element><Name>1.1 Start easy ignore fin thickness
</Name></element>";
|
Lee Thomason (grinliz) | 46a14cf | 2012-02-23 22:27:28 -0800 | [diff] [blame] | 608 |
|
Arkadiy Shapkin | ef1c69c | 2012-07-25 22:10:39 +0400 | [diff] [blame^] | 609 | XMLDocument doc;
|
Lee Thomason (grinliz) | 46a14cf | 2012-02-23 22:27:28 -0800 | [diff] [blame] | 610 | doc.Parse( test );
|
| 611 |
|
| 612 | XMLText* text = doc.FirstChildElement()->FirstChildElement()->FirstChild()->ToText();
|
| 613 | XMLTest( "Entity with one digit.",
|
| 614 | text->Value(), "1.1 Start easy ignore fin thickness\n",
|
| 615 | false );
|
Arkadiy Shapkin | ef1c69c | 2012-07-25 22:10:39 +0400 | [diff] [blame^] | 616 | }
|
Lee Thomason (grinliz) | 46a14cf | 2012-02-23 22:27:28 -0800 | [diff] [blame] | 617 |
|
| 618 | {
|
| 619 | // DOCTYPE not preserved (950171)
|
| 620 | //
|
| 621 | const char* doctype =
|
| 622 | "<?xml version=\"1.0\" ?>"
|
| 623 | "<!DOCTYPE PLAY SYSTEM 'play.dtd'>"
|
| 624 | "<!ELEMENT title (#PCDATA)>"
|
| 625 | "<!ELEMENT books (title,authors)>"
|
| 626 | "<element />";
|
| 627 |
|
| 628 | XMLDocument doc;
|
| 629 | doc.Parse( doctype );
|
Arkadiy Shapkin | ff72d1f | 2012-07-24 00:24:07 +0400 | [diff] [blame] | 630 | doc.SaveFile( "resources/out/test7.xml" );
|
Lee Thomason (grinliz) | 46a14cf | 2012-02-23 22:27:28 -0800 | [diff] [blame] | 631 | doc.DeleteChild( doc.RootElement() );
|
Arkadiy Shapkin | ff72d1f | 2012-07-24 00:24:07 +0400 | [diff] [blame] | 632 | doc.LoadFile( "resources/out/test7.xml" );
|
Lee Thomason (grinliz) | 46a14cf | 2012-02-23 22:27:28 -0800 | [diff] [blame] | 633 | doc.Print();
|
| 634 |
|
| 635 | const XMLUnknown* decl = doc.FirstChild()->NextSibling()->ToUnknown();
|
| 636 | XMLTest( "Correct value of unknown.", "DOCTYPE PLAY SYSTEM 'play.dtd'", decl->Value() );
|
| 637 |
|
| 638 | }
|
| 639 |
|
| 640 | {
|
| 641 | // Comments do not stream out correctly.
|
| 642 | const char* doctype =
|
| 643 | "<!-- Somewhat<evil> -->";
|
| 644 | XMLDocument doc;
|
| 645 | doc.Parse( doctype );
|
| 646 |
|
| 647 | XMLComment* comment = doc.FirstChild()->ToComment();
|
| 648 |
|
| 649 | XMLTest( "Comment formatting.", " Somewhat<evil> ", comment->Value() );
|
| 650 | }
|
| 651 | {
|
| 652 | // Double attributes
|
| 653 | const char* doctype = "<element attr='red' attr='blue' />";
|
| 654 |
|
| 655 | XMLDocument doc;
|
| 656 | doc.Parse( doctype );
|
| 657 |
|
Lee Thomason | 21be882 | 2012-07-15 17:27:22 -0700 | [diff] [blame] | 658 | XMLTest( "Parsing repeated attributes.", (int)XML_ERROR_PARSING_ATTRIBUTE, doc.ErrorID() ); // is an error to tinyxml (didn't use to be, but caused issues)
|
Lee Thomason (grinliz) | 0a4df40 | 2012-02-27 20:50:52 -0800 | [diff] [blame] | 659 | doc.PrintError();
|
Lee Thomason (grinliz) | 46a14cf | 2012-02-23 22:27:28 -0800 | [diff] [blame] | 660 | }
|
| 661 |
|
| 662 | {
|
| 663 | // Embedded null in stream.
|
| 664 | const char* doctype = "<element att\0r='red' attr='blue' />";
|
| 665 |
|
| 666 | XMLDocument doc;
|
| 667 | doc.Parse( doctype );
|
| 668 | XMLTest( "Embedded null throws error.", true, doc.Error() );
|
| 669 | }
|
| 670 |
|
| 671 | {
|
Guillermo A. Amaral | 2eb7003 | 2012-03-20 11:26:57 -0700 | [diff] [blame] | 672 | // Empty documents should return TIXML_XML_ERROR_PARSING_EMPTY, bug 1070717
|
Lee Thomason (grinliz) | 46a14cf | 2012-02-23 22:27:28 -0800 | [diff] [blame] | 673 | const char* str = " ";
|
| 674 | XMLDocument doc;
|
| 675 | doc.Parse( str );
|
Lee Thomason | 21be882 | 2012-07-15 17:27:22 -0700 | [diff] [blame] | 676 | XMLTest( "Empty document error", (int)XML_ERROR_EMPTY_DOCUMENT, doc.ErrorID() );
|
Lee Thomason (grinliz) | 46a14cf | 2012-02-23 22:27:28 -0800 | [diff] [blame] | 677 | }
|
| 678 |
|
| 679 | {
|
| 680 | // Low entities
|
| 681 | XMLDocument doc;
|
| 682 | doc.Parse( "<test></test>" );
|
| 683 | const char result[] = { 0x0e, 0 };
|
| 684 | XMLTest( "Low entities.", doc.FirstChildElement()->GetText(), result );
|
| 685 | doc.Print();
|
| 686 | }
|
| 687 |
|
| 688 | {
|
| 689 | // Attribute values with trailing quotes not handled correctly
|
| 690 | XMLDocument doc;
|
| 691 | doc.Parse( "<foo attribute=bar\" />" );
|
| 692 | XMLTest( "Throw error with bad end quotes.", doc.Error(), true );
|
| 693 | }
|
| 694 |
|
| 695 | {
|
| 696 | // [ 1663758 ] Failure to report error on bad XML
|
| 697 | XMLDocument xml;
|
| 698 | xml.Parse("<x>");
|
| 699 | XMLTest("Missing end tag at end of input", xml.Error(), true);
|
| 700 | xml.Parse("<x> ");
|
| 701 | XMLTest("Missing end tag with trailing whitespace", xml.Error(), true);
|
| 702 | xml.Parse("<x></y>");
|
Lee Thomason | 21be882 | 2012-07-15 17:27:22 -0700 | [diff] [blame] | 703 | XMLTest("Mismatched tags", xml.ErrorID(), (int)XML_ERROR_MISMATCHED_ELEMENT);
|
Lee Thomason (grinliz) | 46a14cf | 2012-02-23 22:27:28 -0800 | [diff] [blame] | 704 | }
|
| 705 |
|
| 706 |
|
| 707 | {
|
| 708 | // [ 1475201 ] TinyXML parses entities in comments
|
| 709 | XMLDocument xml;
|
| 710 | xml.Parse("<!-- declarations for <head> & <body> -->"
|
| 711 | "<!-- far & away -->" );
|
| 712 |
|
| 713 | XMLNode* e0 = xml.FirstChild();
|
| 714 | XMLNode* e1 = e0->NextSibling();
|
| 715 | XMLComment* c0 = e0->ToComment();
|
| 716 | XMLComment* c1 = e1->ToComment();
|
| 717 |
|
| 718 | XMLTest( "Comments ignore entities.", " declarations for <head> & <body> ", c0->Value(), true );
|
| 719 | XMLTest( "Comments ignore entities.", " far & away ", c1->Value(), true );
|
| 720 | }
|
| 721 |
|
| 722 | {
|
| 723 | XMLDocument xml;
|
| 724 | xml.Parse( "<Parent>"
|
| 725 | "<child1 att=''/>"
|
| 726 | "<!-- With this comment, child2 will not be parsed! -->"
|
| 727 | "<child2 att=''/>"
|
| 728 | "</Parent>" );
|
| 729 | xml.Print();
|
| 730 |
|
| 731 | int count = 0;
|
| 732 |
|
| 733 | for( XMLNode* ele = xml.FirstChildElement( "Parent" )->FirstChild();
|
| 734 | ele;
|
| 735 | ele = ele->NextSibling() )
|
| 736 | {
|
| 737 | ++count;
|
| 738 | }
|
| 739 |
|
| 740 | XMLTest( "Comments iterate correctly.", 3, count );
|
| 741 | }
|
| 742 |
|
| 743 | {
|
| 744 | // trying to repro ]1874301]. If it doesn't go into an infinite loop, all is well.
|
| 745 | unsigned char buf[] = "<?xml version=\"1.0\" encoding=\"utf-8\"?><feed><![CDATA[Test XMLblablablalblbl";
|
| 746 | buf[60] = 239;
|
| 747 | buf[61] = 0;
|
| 748 |
|
| 749 | XMLDocument doc;
|
| 750 | doc.Parse( (const char*)buf);
|
| 751 | }
|
| 752 |
|
| 753 |
|
| 754 | {
|
| 755 | // bug 1827248 Error while parsing a little bit malformed file
|
| 756 | // Actually not malformed - should work.
|
| 757 | XMLDocument xml;
|
| 758 | xml.Parse( "<attributelist> </attributelist >" );
|
| 759 | XMLTest( "Handle end tag whitespace", false, xml.Error() );
|
| 760 | }
|
| 761 |
|
| 762 | {
|
| 763 | // This one must not result in an infinite loop
|
| 764 | XMLDocument xml;
|
| 765 | xml.Parse( "<infinite>loop" );
|
| 766 | XMLTest( "Infinite loop test.", true, true );
|
| 767 | }
|
| 768 | #endif
|
Lee Thomason | 7d00b9a | 2012-02-27 17:54:22 -0800 | [diff] [blame] | 769 | {
|
| 770 | const char* pub = "<?xml version='1.0'?> <element><sub/></element> <!--comment--> <!DOCTYPE>";
|
| 771 | XMLDocument doc;
|
| 772 | doc.Parse( pub );
|
| 773 |
|
| 774 | XMLDocument clone;
|
| 775 | for( const XMLNode* node=doc.FirstChild(); node; node=node->NextSibling() ) {
|
| 776 | XMLNode* copy = node->ShallowClone( &clone );
|
| 777 | clone.InsertEndChild( copy );
|
| 778 | }
|
| 779 |
|
| 780 | clone.Print();
|
| 781 |
|
| 782 | int count=0;
|
| 783 | const XMLNode* a=clone.FirstChild();
|
| 784 | const XMLNode* b=doc.FirstChild();
|
| 785 | for( ; a && b; a=a->NextSibling(), b=b->NextSibling() ) {
|
| 786 | ++count;
|
| 787 | XMLTest( "Clone and Equal", true, a->ShallowEqual( b ));
|
| 788 | }
|
| 789 | XMLTest( "Clone and Equal", 4, count );
|
| 790 | }
|
Lee Thomason (grinliz) | 2a1cd27 | 2012-02-24 17:37:53 -0800 | [diff] [blame] | 791 |
|
Lee Thomason (grinliz) | a4a36ba | 2012-04-06 21:24:29 -0700 | [diff] [blame] | 792 | {
|
| 793 | // This shouldn't crash.
|
| 794 | XMLDocument doc;
|
| 795 | if(XML_NO_ERROR != doc.LoadFile( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ))
|
| 796 | {
|
| 797 | doc.PrintError();
|
| 798 | }
|
| 799 | XMLTest( "Error in snprinf handling.", true, doc.Error() );
|
| 800 | }
|
Lee Thomason | 5e3803c | 2012-04-16 08:57:05 -0700 | [diff] [blame] | 801 |
|
| 802 | {
|
| 803 | // Attribute ordering.
|
| 804 | static const char* xml = "<element attrib1=\"1\" attrib2=\"2\" attrib3=\"3\" />";
|
| 805 | XMLDocument doc;
|
| 806 | doc.Parse( xml );
|
| 807 | XMLElement* ele = doc.FirstChildElement();
|
| 808 |
|
| 809 | const XMLAttribute* a = ele->FirstAttribute();
|
| 810 | XMLTest( "Attribute order", "1", a->Value() );
|
| 811 | a = a->Next();
|
| 812 | XMLTest( "Attribute order", "2", a->Value() );
|
| 813 | a = a->Next();
|
| 814 | XMLTest( "Attribute order", "3", a->Value() );
|
| 815 | XMLTest( "Attribute order", "attrib3", a->Name() );
|
| 816 |
|
| 817 | ele->DeleteAttribute( "attrib2" );
|
| 818 | a = ele->FirstAttribute();
|
| 819 | XMLTest( "Attribute order", "1", a->Value() );
|
| 820 | a = a->Next();
|
| 821 | XMLTest( "Attribute order", "3", a->Value() );
|
| 822 |
|
| 823 | ele->DeleteAttribute( "attrib1" );
|
| 824 | ele->DeleteAttribute( "attrib3" );
|
| 825 | XMLTest( "Attribute order (empty)", false, ele->FirstAttribute() ? true : false );
|
| 826 | }
|
Lee Thomason (grinliz) | a4a36ba | 2012-04-06 21:24:29 -0700 | [diff] [blame] | 827 |
|
Lee Thomason (grinliz) | 390e978 | 2012-07-01 21:22:53 -0700 | [diff] [blame] | 828 | {
|
| 829 | // Make sure an attribute with a space in it succeeds.
|
Lee Thomason | 78a773d | 2012-07-02 10:10:19 -0700 | [diff] [blame] | 830 | static const char* xml0 = "<element attribute1= \"Test Attribute\"/>";
|
| 831 | static const char* xml1 = "<element attribute1 =\"Test Attribute\"/>";
|
| 832 | static const char* xml2 = "<element attribute1 = \"Test Attribute\"/>";
|
| 833 | XMLDocument doc0;
|
| 834 | doc0.Parse( xml0 );
|
| 835 | XMLDocument doc1;
|
| 836 | doc1.Parse( xml1 );
|
| 837 | XMLDocument doc2;
|
| 838 | doc2.Parse( xml2 );
|
Lee Thomason (grinliz) | 390e978 | 2012-07-01 21:22:53 -0700 | [diff] [blame] | 839 |
|
Lee Thomason | 78a773d | 2012-07-02 10:10:19 -0700 | [diff] [blame] | 840 | XMLElement* ele = 0;
|
| 841 | ele = doc0.FirstChildElement();
|
| 842 | XMLTest( "Attribute with space #1", "Test Attribute", ele->Attribute( "attribute1" ) );
|
| 843 | ele = doc1.FirstChildElement();
|
| 844 | XMLTest( "Attribute with space #2", "Test Attribute", ele->Attribute( "attribute1" ) );
|
| 845 | ele = doc2.FirstChildElement();
|
| 846 | XMLTest( "Attribute with space #3", "Test Attribute", ele->Attribute( "attribute1" ) );
|
Lee Thomason (grinliz) | 390e978 | 2012-07-01 21:22:53 -0700 | [diff] [blame] | 847 | }
|
| 848 |
|
| 849 | {
|
| 850 | // Make sure we don't go into an infinite loop.
|
| 851 | static const char* xml = "<doc><element attribute='attribute'/><element attribute='attribute'/></doc>";
|
| 852 | XMLDocument doc;
|
| 853 | doc.Parse( xml );
|
| 854 | XMLElement* ele0 = doc.FirstChildElement()->FirstChildElement();
|
| 855 | XMLElement* ele1 = ele0->NextSiblingElement();
|
| 856 | bool equal = ele0->ShallowEqual( ele1 );
|
| 857 |
|
| 858 | XMLTest( "Infinite loop in shallow equal.", true, equal );
|
| 859 | }
|
| 860 |
|
Lee Thomason | 5708f81 | 2012-03-28 17:46:41 -0700 | [diff] [blame] | 861 | // -------- Handles ------------
|
| 862 | {
|
| 863 | static const char* xml = "<element attrib='bar'><sub>Text</sub></element>";
|
| 864 | XMLDocument doc;
|
| 865 | doc.Parse( xml );
|
Lee Thomason | 5708f81 | 2012-03-28 17:46:41 -0700 | [diff] [blame] | 866 |
|
| 867 | XMLElement* ele = XMLHandle( doc ).FirstChildElement( "element" ).FirstChild().ToElement();
|
| 868 | XMLTest( "Handle, success, mutable", ele->Value(), "sub" );
|
| 869 |
|
Lee Thomason (grinliz) | ae209f6 | 2012-04-04 22:00:07 -0700 | [diff] [blame] | 870 | XMLHandle docH( doc );
|
| 871 | ele = docH.FirstChildElement( "none" ).FirstChildElement( "element" ).ToElement();
|
Lee Thomason | d0b19df | 2012-04-12 08:41:37 -0700 | [diff] [blame] | 872 | XMLTest( "Handle, dne, mutable", false, ele != 0 );
|
Lee Thomason | 5708f81 | 2012-03-28 17:46:41 -0700 | [diff] [blame] | 873 | }
|
| 874 |
|
Lee Thomason (grinliz) | ae209f6 | 2012-04-04 22:00:07 -0700 | [diff] [blame] | 875 | {
|
| 876 | static const char* xml = "<element attrib='bar'><sub>Text</sub></element>";
|
| 877 | XMLDocument doc;
|
| 878 | doc.Parse( xml );
|
| 879 | XMLConstHandle docH( doc );
|
| 880 |
|
| 881 | const XMLElement* ele = docH.FirstChildElement( "element" ).FirstChild().ToElement();
|
| 882 | XMLTest( "Handle, success, const", ele->Value(), "sub" );
|
| 883 |
|
| 884 | ele = docH.FirstChildElement( "none" ).FirstChildElement( "element" ).ToElement();
|
Lee Thomason | d0b19df | 2012-04-12 08:41:37 -0700 | [diff] [blame] | 885 | XMLTest( "Handle, dne, const", false, ele != 0 );
|
Lee Thomason (grinliz) | ae209f6 | 2012-04-04 22:00:07 -0700 | [diff] [blame] | 886 | }
|
Lee Thomason | f68c438 | 2012-04-28 14:37:11 -0700 | [diff] [blame] | 887 | {
|
| 888 | // Default Declaration & BOM
|
| 889 | XMLDocument doc;
|
| 890 | doc.InsertEndChild( doc.NewDeclaration() );
|
| 891 | doc.SetBOM( true );
|
| 892 |
|
| 893 | XMLPrinter printer;
|
| 894 | doc.Print( &printer );
|
| 895 |
|
| 896 | static const char* result = "\xef\xbb\xbf<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
|
| 897 | XMLTest( "BOM and default declaration", printer.CStr(), result, false );
|
Lee Thomason (grinliz) | 48ea0bc | 2012-05-26 14:41:14 -0700 | [diff] [blame] | 898 | XMLTest( "CStrSize", printer.CStrSize(), 42, false );
|
Lee Thomason | f68c438 | 2012-04-28 14:37:11 -0700 | [diff] [blame] | 899 | }
|
Lee Thomason | 21be882 | 2012-07-15 17:27:22 -0700 | [diff] [blame] | 900 | {
|
| 901 | const char* xml = "<ipxml ws='1'><info bla=' /></ipxml>";
|
| 902 | XMLDocument doc;
|
| 903 | doc.Parse( xml );
|
| 904 | XMLTest( "Ill formed XML", true, doc.Error() );
|
| 905 | }
|
| 906 |
|
| 907 | // QueryXYZText
|
| 908 | {
|
| 909 | const char* xml = "<point> <x>1.2</x> <y>1</y> <z>38</z> <valid>true</valid> </point>";
|
| 910 | XMLDocument doc;
|
| 911 | doc.Parse( xml );
|
| 912 |
|
| 913 | const XMLElement* pointElement = doc.RootElement();
|
| 914 |
|
| 915 | int intValue = 0;
|
| 916 | unsigned unsignedValue = 0;
|
| 917 | float floatValue = 0;
|
| 918 | double doubleValue = 0;
|
| 919 | bool boolValue = false;
|
| 920 |
|
| 921 | pointElement->FirstChildElement( "y" )->QueryIntText( &intValue );
|
| 922 | pointElement->FirstChildElement( "y" )->QueryUnsignedText( &unsignedValue );
|
| 923 | pointElement->FirstChildElement( "x" )->QueryFloatText( &floatValue );
|
| 924 | pointElement->FirstChildElement( "x" )->QueryDoubleText( &doubleValue );
|
| 925 | pointElement->FirstChildElement( "valid" )->QueryBoolText( &boolValue );
|
| 926 |
|
| 927 |
|
| 928 | XMLTest( "QueryIntText", intValue, 1, false );
|
| 929 | XMLTest( "QueryUnsignedText", unsignedValue, (unsigned)1, false );
|
| 930 | XMLTest( "QueryFloatText", floatValue, 1.2f, false );
|
| 931 | XMLTest( "QueryDoubleText", doubleValue, 1.2, false );
|
| 932 | XMLTest( "QueryBoolText", boolValue, true, false );
|
| 933 | }
|
Lee Thomason (grinliz) | ae209f6 | 2012-04-04 22:00:07 -0700 | [diff] [blame] | 934 |
|
| 935 |
|
Lee Thomason | 6f381b7 | 2012-03-02 12:59:39 -0800 | [diff] [blame] | 936 | // ----------- Performance tracking --------------
|
| 937 | {
|
| 938 | #if defined( _MSC_VER )
|
| 939 | __int64 start, end, freq;
|
| 940 | QueryPerformanceFrequency( (LARGE_INTEGER*) &freq );
|
| 941 | #endif
|
| 942 |
|
| 943 | #if defined(_MSC_VER)
|
| 944 | #pragma warning ( push )
|
| 945 | #pragma warning ( disable : 4996 ) // Fail to see a compelling reason why this should be deprecated.
|
| 946 | #endif
|
Bruno Dias | a2d4e6e | 2012-05-07 04:58:11 -0300 | [diff] [blame] | 947 | FILE* fp = fopen( "resources/dream.xml", "r" );
|
Lee Thomason | 6f381b7 | 2012-03-02 12:59:39 -0800 | [diff] [blame] | 948 | #if defined(_MSC_VER)
|
| 949 | #pragma warning ( pop )
|
| 950 | #endif
|
| 951 | fseek( fp, 0, SEEK_END );
|
| 952 | long size = ftell( fp );
|
| 953 | fseek( fp, 0, SEEK_SET );
|
| 954 |
|
| 955 | char* mem = new char[size+1];
|
| 956 | fread( mem, size, 1, fp );
|
| 957 | fclose( fp );
|
| 958 | mem[size] = 0;
|
| 959 |
|
| 960 | #if defined( _MSC_VER )
|
| 961 | QueryPerformanceCounter( (LARGE_INTEGER*) &start );
|
| 962 | #else
|
| 963 | clock_t cstart = clock();
|
| 964 | #endif
|
| 965 | static const int COUNT = 10;
|
| 966 | for( int i=0; i<COUNT; ++i ) {
|
| 967 | XMLDocument doc;
|
| 968 | doc.Parse( mem );
|
| 969 | }
|
| 970 | #if defined( _MSC_VER )
|
| 971 | QueryPerformanceCounter( (LARGE_INTEGER*) &end );
|
| 972 | #else
|
| 973 | clock_t cend = clock();
|
| 974 | #endif
|
| 975 |
|
| 976 | delete [] mem;
|
| 977 |
|
| 978 | static const char* note =
|
| 979 | #ifdef DEBUG
|
| 980 | "DEBUG";
|
| 981 | #else
|
| 982 | "Release";
|
| 983 | #endif
|
| 984 |
|
| 985 | #if defined( _MSC_VER )
|
| 986 | printf( "\nParsing %s of dream.xml: %.3f milli-seconds\n", note, 1000.0 * (double)(end-start) / ( (double)freq * (double)COUNT) );
|
| 987 | #else
|
| 988 | printf( "\nParsing %s of dream.xml: %.3f milli-seconds\n", note, (double)(cend - cstart)/(double)COUNT );
|
| 989 | #endif
|
| 990 | }
|
| 991 |
|
Lee Thomason (grinliz) | 7ca5558 | 2012-03-07 21:54:57 -0800 | [diff] [blame] | 992 | #if defined( _MSC_VER ) && defined( DEBUG )
|
Lee Thomason | 1ff38e0 | 2012-02-14 18:18:16 -0800 | [diff] [blame] | 993 | _CrtMemCheckpoint( &endMemState );
|
| 994 | //_CrtMemDumpStatistics( &endMemState );
|
| 995 |
|
| 996 | _CrtMemState diffMemState;
|
| 997 | _CrtMemDifference( &diffMemState, &startMemState, &endMemState );
|
| 998 | _CrtMemDumpStatistics( &diffMemState );
|
Lee Thomason (grinliz) | bd0a8ac | 2012-02-20 20:14:33 -0800 | [diff] [blame] | 999 | //printf( "new total=%d\n", gNewTotal );
|
Lee Thomason | 1ff38e0 | 2012-02-14 18:18:16 -0800 | [diff] [blame] | 1000 | #endif
|
| 1001 |
|
| 1002 | printf ("\nPass %d, Fail %d\n", gPass, gFail);
|
U-Lama\Lee | e13c3e6 | 2011-12-28 14:36:55 -0800 | [diff] [blame] | 1003 | return 0;
|
Lee Thomason (grinliz) | 9b093cc | 2012-02-25 21:30:18 -0800 | [diff] [blame] | 1004 | }
|