2011-12-28 22:36:55 +00:00
|
|
|
#include "tinyxml2.h"
|
|
|
|
|
2012-03-20 18:26:57 +00:00
|
|
|
#include <cstdlib>
|
|
|
|
#include <cstring>
|
|
|
|
#include <ctime>
|
2011-12-28 22:36:55 +00:00
|
|
|
|
2012-02-25 01:37:53 +00:00
|
|
|
#if defined( _MSC_VER )
|
2012-02-15 02:18:16 +00:00
|
|
|
#include <crtdbg.h>
|
2012-03-02 20:59:39 +00:00
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
#include <windows.h>
|
2012-02-15 02:18:16 +00:00
|
|
|
_CrtMemState startMemState;
|
|
|
|
_CrtMemState endMemState;
|
|
|
|
#endif
|
2012-02-14 02:11:20 +00:00
|
|
|
|
2011-12-28 22:36:55 +00:00
|
|
|
using namespace tinyxml2;
|
2012-02-14 02:16:52 +00:00
|
|
|
int gPass = 0;
|
|
|
|
int gFail = 0;
|
|
|
|
|
2012-02-21 04:14:33 +00:00
|
|
|
|
2012-02-17 16:31:16 +00:00
|
|
|
bool XMLTest (const char* testString, const char* expected, const char* found, bool echo=true )
|
2012-02-15 02:18:16 +00:00
|
|
|
{
|
|
|
|
bool pass = !strcmp( expected, found );
|
|
|
|
if ( pass )
|
|
|
|
printf ("[pass]");
|
|
|
|
else
|
|
|
|
printf ("[fail]");
|
|
|
|
|
2012-02-17 16:31:16 +00:00
|
|
|
if ( !echo )
|
2012-02-15 02:18:16 +00:00
|
|
|
printf (" %s\n", testString);
|
|
|
|
else
|
|
|
|
printf (" %s [%s][%s]\n", testString, expected, found);
|
|
|
|
|
|
|
|
if ( pass )
|
|
|
|
++gPass;
|
|
|
|
else
|
|
|
|
++gFail;
|
|
|
|
return pass;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-17 16:31:16 +00:00
|
|
|
bool XMLTest( const char* testString, int expected, int found, bool echo=true )
|
2012-02-15 02:18:16 +00:00
|
|
|
{
|
|
|
|
bool pass = ( expected == found );
|
|
|
|
if ( pass )
|
|
|
|
printf ("[pass]");
|
|
|
|
else
|
|
|
|
printf ("[fail]");
|
|
|
|
|
2012-02-17 16:31:16 +00:00
|
|
|
if ( !echo )
|
2012-02-15 02:18:16 +00:00
|
|
|
printf (" %s\n", testString);
|
|
|
|
else
|
|
|
|
printf (" %s [%d][%d]\n", testString, expected, found);
|
|
|
|
|
|
|
|
if ( pass )
|
|
|
|
++gPass;
|
|
|
|
else
|
|
|
|
++gFail;
|
|
|
|
return pass;
|
|
|
|
}
|
2012-02-14 02:16:52 +00:00
|
|
|
|
2011-12-28 22:36:55 +00:00
|
|
|
|
2012-02-21 17:08:12 +00:00
|
|
|
void NullLineEndings( char* p )
|
|
|
|
{
|
|
|
|
while( p && *p ) {
|
|
|
|
if ( *p == '\n' || *p == '\r' ) {
|
|
|
|
*p = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
++p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-04-04 19:39:05 +00:00
|
|
|
// Comments in the header. (Don't know how to get Doxygen to read comments in this file.)
|
|
|
|
int example_1()
|
|
|
|
{
|
|
|
|
XMLDocument doc;
|
|
|
|
doc.LoadFile( "dream.xml" );
|
|
|
|
|
|
|
|
return doc.ErrorID();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Comments in the header. (Don't know how to get Doxygen to read comments in this file.)
|
|
|
|
int example_2()
|
|
|
|
{
|
|
|
|
static const char* xml = "<element/>";
|
|
|
|
XMLDocument doc;
|
|
|
|
doc.Parse( xml );
|
|
|
|
|
|
|
|
return doc.ErrorID();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int example_3()
|
|
|
|
{
|
2012-04-07 04:24:29 +00:00
|
|
|
static const char* xml =
|
|
|
|
"<?xml version=\"1.0\"?>"
|
|
|
|
"<!DOCTYPE PLAY SYSTEM \"play.dtd\">"
|
|
|
|
"<PLAY>"
|
|
|
|
"<TITLE>A Midsummer Night's Dream</TITLE>"
|
|
|
|
"</PLAY>";
|
2012-04-04 19:39:05 +00:00
|
|
|
|
|
|
|
XMLDocument doc;
|
|
|
|
doc.Parse( xml );
|
|
|
|
|
|
|
|
XMLElement* titleElement = doc.FirstChildElement( "PLAY" )->FirstChildElement( "TITLE" );
|
|
|
|
const char* title = titleElement->GetText();
|
|
|
|
printf( "Name of play (1): %s\n", title );
|
|
|
|
|
|
|
|
XMLText* textNode = titleElement->FirstChild()->ToText();
|
|
|
|
title = textNode->Value();
|
|
|
|
printf( "Name of play (2): %s\n", title );
|
|
|
|
|
|
|
|
return doc.ErrorID();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-20 18:26:57 +00:00
|
|
|
int main( int /*argc*/, const char ** /*argv*/ )
|
2011-12-28 22:36:55 +00:00
|
|
|
{
|
2012-02-28 04:50:52 +00:00
|
|
|
#if defined( _MSC_VER ) && defined( DEBUG )
|
2012-02-15 02:18:16 +00:00
|
|
|
_CrtMemCheckpoint( &startMemState );
|
|
|
|
#endif
|
2012-01-19 01:43:40 +00:00
|
|
|
|
2012-03-24 19:49:03 +00:00
|
|
|
#if defined(_MSC_VER)
|
|
|
|
#pragma warning ( push )
|
|
|
|
#pragma warning ( disable : 4996 ) // Fail to see a compelling reason why this should be deprecated.
|
|
|
|
#endif
|
|
|
|
|
|
|
|
FILE* fp = fopen( "dream.xml", "r" );
|
|
|
|
if ( !fp ) {
|
|
|
|
printf( "Error opening test file 'dream.xml'.\n"
|
|
|
|
"Is your working directory the same as where \n"
|
|
|
|
"the xmltest.cpp and dream.xml file are?\n\n"
|
|
|
|
#if defined( _MSC_VER )
|
|
|
|
"In windows Visual Studio you may need to set\n"
|
|
|
|
"Properties->Debugging->Working Directory to '..'\n"
|
|
|
|
#endif
|
|
|
|
);
|
|
|
|
exit( 1 );
|
|
|
|
}
|
|
|
|
fclose( fp );
|
|
|
|
|
|
|
|
#if defined(_MSC_VER)
|
|
|
|
#pragma warning ( pop )
|
|
|
|
#endif
|
|
|
|
|
2012-04-04 19:39:05 +00:00
|
|
|
XMLTest( "Example-1", 0, example_1() );
|
|
|
|
XMLTest( "Example-2", 0, example_2() );
|
|
|
|
XMLTest( "Example-3", 0, example_3() );
|
2012-03-20 18:55:29 +00:00
|
|
|
|
2012-04-04 19:39:05 +00:00
|
|
|
/* ------ Example 2: Lookup information. ---- */
|
2012-03-20 18:55:29 +00:00
|
|
|
|
2012-01-19 01:43:40 +00:00
|
|
|
{
|
2012-02-07 02:18:11 +00:00
|
|
|
static const char* test[] = { "<element />",
|
|
|
|
"<element></element>",
|
|
|
|
"<element><subelement/></element>",
|
|
|
|
"<element><subelement></subelement></element>",
|
|
|
|
"<element><subelement><subsub/></subelement></element>",
|
|
|
|
"<!--comment beside elements--><element><subelement></subelement></element>",
|
|
|
|
"<!--comment beside elements, this time with spaces--> \n <element> <subelement> \n </subelement> </element>",
|
|
|
|
"<element attrib1='foo' attrib2=\"bar\" ></element>",
|
|
|
|
"<element attrib1='foo' attrib2=\"bar\" ><subelement attrib3='yeehaa' /></element>",
|
|
|
|
"<element>Text inside element.</element>",
|
|
|
|
"<element><b></b></element>",
|
|
|
|
"<element>Text inside and <b>bolded</b> in the element.</element>",
|
|
|
|
"<outer><element>Text inside and <b>bolded</b> in the element.</element></outer>",
|
2012-01-26 01:44:30 +00:00
|
|
|
"<element>This & That.</element>",
|
2012-01-27 02:17:26 +00:00
|
|
|
"<element attrib='This<That' />",
|
2012-01-19 01:55:48 +00:00
|
|
|
0
|
|
|
|
};
|
2012-01-22 02:45:16 +00:00
|
|
|
for( int i=0; test[i]; ++i ) {
|
2012-01-19 01:55:48 +00:00
|
|
|
XMLDocument doc;
|
2012-01-22 02:45:16 +00:00
|
|
|
doc.Parse( test[i] );
|
2012-01-25 02:03:07 +00:00
|
|
|
doc.Print();
|
2012-01-23 19:42:06 +00:00
|
|
|
printf( "----------------------------------------------\n" );
|
2012-01-19 01:55:48 +00:00
|
|
|
}
|
2011-12-31 22:58:18 +00:00
|
|
|
}
|
2012-02-24 06:27:28 +00:00
|
|
|
#if 1
|
2012-02-23 00:00:12 +00:00
|
|
|
{
|
|
|
|
static const char* test = "<!--hello world\n"
|
|
|
|
" line 2\r"
|
|
|
|
" line 3\r\n"
|
|
|
|
" line 4\n\r"
|
|
|
|
" line 5\r-->";
|
|
|
|
|
|
|
|
XMLDocument doc;
|
|
|
|
doc.Parse( test );
|
|
|
|
doc.Print();
|
|
|
|
}
|
|
|
|
|
2012-01-31 16:24:24 +00:00
|
|
|
{
|
|
|
|
static const char* test = "<element>Text before.</element>";
|
|
|
|
XMLDocument doc;
|
|
|
|
doc.Parse( test );
|
|
|
|
XMLElement* root = doc.FirstChildElement();
|
|
|
|
XMLElement* newElement = doc.NewElement( "Subelement" );
|
|
|
|
root->InsertEndChild( newElement );
|
|
|
|
doc.Print();
|
|
|
|
}
|
2012-02-06 16:41:24 +00:00
|
|
|
{
|
|
|
|
XMLDocument* doc = new XMLDocument();
|
|
|
|
static const char* test = "<element><sub/></element>";
|
|
|
|
doc->Parse( test );
|
|
|
|
delete doc;
|
|
|
|
}
|
2012-02-14 02:11:20 +00:00
|
|
|
{
|
2012-02-15 02:18:16 +00:00
|
|
|
// Test: Programmatic DOM
|
2012-02-14 02:16:52 +00:00
|
|
|
// Build:
|
|
|
|
// <element>
|
|
|
|
// <!--comment-->
|
|
|
|
// <sub attrib="1" />
|
|
|
|
// <sub attrib="2" />
|
2012-02-17 16:31:16 +00:00
|
|
|
// <sub attrib="3" >& Text!</sub>
|
2012-02-14 02:16:52 +00:00
|
|
|
// <element>
|
|
|
|
|
2012-02-14 02:11:20 +00:00
|
|
|
XMLDocument* doc = new XMLDocument();
|
2012-02-15 02:18:16 +00:00
|
|
|
XMLNode* element = doc->InsertEndChild( doc->NewElement( "element" ) );
|
|
|
|
|
|
|
|
XMLElement* sub[3] = { doc->NewElement( "sub" ), doc->NewElement( "sub" ), doc->NewElement( "sub" ) };
|
|
|
|
for( int i=0; i<3; ++i ) {
|
|
|
|
sub[i]->SetAttribute( "attrib", i );
|
|
|
|
}
|
|
|
|
element->InsertEndChild( sub[2] );
|
|
|
|
XMLNode* comment = element->InsertFirstChild( doc->NewComment( "comment" ) );
|
|
|
|
element->InsertAfterChild( comment, sub[0] );
|
|
|
|
element->InsertAfterChild( sub[0], sub[1] );
|
2012-02-17 16:31:16 +00:00
|
|
|
sub[2]->InsertFirstChild( doc->NewText( "& Text!" ));
|
2012-02-14 02:11:20 +00:00
|
|
|
doc->Print();
|
2012-02-17 16:31:16 +00:00
|
|
|
XMLTest( "Programmatic DOM", "comment", doc->FirstChildElement( "element" )->FirstChild()->Value() );
|
|
|
|
XMLTest( "Programmatic DOM", "0", doc->FirstChildElement( "element" )->FirstChildElement()->Attribute( "attrib" ) );
|
|
|
|
XMLTest( "Programmatic DOM", 2, doc->FirstChildElement()->LastChildElement( "sub" )->IntAttribute( "attrib" ) );
|
|
|
|
XMLTest( "Programmatic DOM", "& Text!",
|
|
|
|
doc->FirstChildElement()->LastChildElement( "sub" )->FirstChild()->ToText()->Value() );
|
2012-02-18 01:48:16 +00:00
|
|
|
|
|
|
|
// And now deletion:
|
|
|
|
element->DeleteChild( sub[2] );
|
|
|
|
doc->DeleteNode( comment );
|
|
|
|
|
|
|
|
element->FirstChildElement()->SetAttribute( "attrib", true );
|
|
|
|
element->LastChildElement()->DeleteAttribute( "attrib" );
|
|
|
|
|
|
|
|
XMLTest( "Programmatic DOM", true, doc->FirstChildElement()->FirstChildElement()->BoolAttribute( "attrib" ) );
|
|
|
|
int value = 10;
|
|
|
|
int result = doc->FirstChildElement()->LastChildElement()->QueryIntAttribute( "attrib", &value );
|
2012-03-20 18:26:57 +00:00
|
|
|
XMLTest( "Programmatic DOM", result, XML_NO_ATTRIBUTE );
|
2012-02-18 01:48:16 +00:00
|
|
|
XMLTest( "Programmatic DOM", value, 10 );
|
|
|
|
|
|
|
|
doc->Print();
|
|
|
|
|
2012-02-25 01:37:53 +00:00
|
|
|
XMLPrinter streamer;
|
2012-02-18 01:48:16 +00:00
|
|
|
doc->Print( &streamer );
|
|
|
|
printf( "%s", streamer.CStr() );
|
|
|
|
|
2012-02-14 02:11:20 +00:00
|
|
|
delete doc;
|
|
|
|
}
|
2012-02-21 04:14:33 +00:00
|
|
|
{
|
|
|
|
// Test: Dream
|
|
|
|
// XML1 : 1,187,569 bytes in 31,209 allocations
|
|
|
|
// XML2 : 469,073 bytes in 323 allocations
|
|
|
|
//int newStart = gNew;
|
|
|
|
XMLDocument doc;
|
2012-02-21 17:08:12 +00:00
|
|
|
doc.LoadFile( "dream.xml" );
|
2012-02-21 04:14:33 +00:00
|
|
|
|
2012-02-21 17:08:12 +00:00
|
|
|
doc.SaveFile( "dreamout.xml" );
|
2012-02-21 04:14:33 +00:00
|
|
|
doc.PrintError();
|
|
|
|
|
|
|
|
XMLTest( "Dream", "xml version=\"1.0\"",
|
|
|
|
doc.FirstChild()->ToDeclaration()->Value() );
|
|
|
|
XMLTest( "Dream", true, doc.FirstChild()->NextSibling()->ToUnknown() ? true : false );
|
|
|
|
XMLTest( "Dream", "DOCTYPE PLAY SYSTEM \"play.dtd\"",
|
|
|
|
doc.FirstChild()->NextSibling()->ToUnknown()->Value() );
|
|
|
|
XMLTest( "Dream", "And Robin shall restore amends.",
|
|
|
|
doc.LastChild()->LastChild()->LastChild()->LastChild()->LastChildElement()->GetText() );
|
|
|
|
XMLTest( "Dream", "And Robin shall restore amends.",
|
|
|
|
doc.LastChild()->LastChild()->LastChild()->LastChild()->LastChildElement()->GetText() );
|
|
|
|
|
|
|
|
XMLDocument doc2;
|
2012-02-21 17:08:12 +00:00
|
|
|
doc2.LoadFile( "dreamout.xml" );
|
2012-02-21 04:14:33 +00:00
|
|
|
XMLTest( "Dream-out", "xml version=\"1.0\"",
|
|
|
|
doc2.FirstChild()->ToDeclaration()->Value() );
|
|
|
|
XMLTest( "Dream-out", true, doc2.FirstChild()->NextSibling()->ToUnknown() ? true : false );
|
|
|
|
XMLTest( "Dream-out", "DOCTYPE PLAY SYSTEM \"play.dtd\"",
|
|
|
|
doc2.FirstChild()->NextSibling()->ToUnknown()->Value() );
|
|
|
|
XMLTest( "Dream-out", "And Robin shall restore amends.",
|
|
|
|
doc2.LastChild()->LastChild()->LastChild()->LastChild()->LastChildElement()->GetText() );
|
|
|
|
|
|
|
|
//gNewTotal = gNew - newStart;
|
|
|
|
}
|
2012-03-02 20:59:39 +00:00
|
|
|
|
|
|
|
|
2012-02-21 17:08:12 +00:00
|
|
|
{
|
|
|
|
const char* error = "<?xml version=\"1.0\" standalone=\"no\" ?>\n"
|
|
|
|
"<passages count=\"006\" formatversion=\"20020620\">\n"
|
|
|
|
" <wrong error>\n"
|
|
|
|
"</passages>";
|
|
|
|
|
|
|
|
XMLDocument doc;
|
|
|
|
doc.Parse( error );
|
2012-03-20 18:26:57 +00:00
|
|
|
XMLTest( "Bad XML", doc.ErrorID(), XML_ERROR_PARSING_ATTRIBUTE );
|
2012-02-21 17:08:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
const char* str = "<doc attr0='1' attr1='2.0' attr2='foo' />";
|
|
|
|
|
|
|
|
XMLDocument doc;
|
|
|
|
doc.Parse( str );
|
|
|
|
|
|
|
|
XMLElement* ele = doc.FirstChildElement();
|
|
|
|
|
|
|
|
int iVal, result;
|
|
|
|
double dVal;
|
|
|
|
|
|
|
|
result = ele->QueryDoubleAttribute( "attr0", &dVal );
|
|
|
|
XMLTest( "Query attribute: int as double", result, XML_NO_ERROR );
|
|
|
|
XMLTest( "Query attribute: int as double", (int)dVal, 1 );
|
|
|
|
result = ele->QueryDoubleAttribute( "attr1", &dVal );
|
|
|
|
XMLTest( "Query attribute: double as double", (int)dVal, 2 );
|
|
|
|
result = ele->QueryIntAttribute( "attr1", &iVal );
|
|
|
|
XMLTest( "Query attribute: double as int", result, XML_NO_ERROR );
|
|
|
|
XMLTest( "Query attribute: double as int", iVal, 2 );
|
|
|
|
result = ele->QueryIntAttribute( "attr2", &iVal );
|
2012-03-20 18:26:57 +00:00
|
|
|
XMLTest( "Query attribute: not a number", result, XML_WRONG_ATTRIBUTE_TYPE );
|
2012-02-21 17:08:12 +00:00
|
|
|
result = ele->QueryIntAttribute( "bar", &iVal );
|
2012-03-20 18:26:57 +00:00
|
|
|
XMLTest( "Query attribute: does not exist", result, XML_NO_ATTRIBUTE );
|
2012-02-21 17:08:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
const char* str = "<doc/>";
|
|
|
|
|
|
|
|
XMLDocument doc;
|
|
|
|
doc.Parse( str );
|
|
|
|
|
|
|
|
XMLElement* ele = doc.FirstChildElement();
|
|
|
|
|
|
|
|
int iVal;
|
|
|
|
double dVal;
|
|
|
|
|
|
|
|
ele->SetAttribute( "str", "strValue" );
|
|
|
|
ele->SetAttribute( "int", 1 );
|
|
|
|
ele->SetAttribute( "double", -1.0 );
|
|
|
|
|
|
|
|
const char* cStr = ele->Attribute( "str" );
|
|
|
|
ele->QueryIntAttribute( "int", &iVal );
|
|
|
|
ele->QueryDoubleAttribute( "double", &dVal );
|
|
|
|
|
2012-03-24 20:04:04 +00:00
|
|
|
XMLTest( "Attribute match test", ele->Attribute( "str", "strValue" ), "strValue" );
|
2012-02-21 17:08:12 +00:00
|
|
|
XMLTest( "Attribute round trip. c-string.", "strValue", cStr );
|
|
|
|
XMLTest( "Attribute round trip. int.", 1, iVal );
|
|
|
|
XMLTest( "Attribute round trip. double.", -1, (int)dVal );
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
XMLDocument doc;
|
|
|
|
doc.LoadFile( "utf8test.xml" );
|
|
|
|
|
|
|
|
// Get the attribute "value" from the "Russian" element and check it.
|
|
|
|
XMLElement* element = doc.FirstChildElement( "document" )->FirstChildElement( "Russian" );
|
|
|
|
const unsigned char correctValue[] = { 0xd1U, 0x86U, 0xd0U, 0xb5U, 0xd0U, 0xbdU, 0xd0U, 0xbdU,
|
|
|
|
0xd0U, 0xbeU, 0xd1U, 0x81U, 0xd1U, 0x82U, 0xd1U, 0x8cU, 0 };
|
|
|
|
|
|
|
|
XMLTest( "UTF-8: Russian value.", (const char*)correctValue, element->Attribute( "value" ) );
|
|
|
|
|
|
|
|
const unsigned char russianElementName[] = { 0xd0U, 0xa0U, 0xd1U, 0x83U,
|
|
|
|
0xd1U, 0x81U, 0xd1U, 0x81U,
|
|
|
|
0xd0U, 0xbaU, 0xd0U, 0xb8U,
|
|
|
|
0xd0U, 0xb9U, 0 };
|
|
|
|
const char russianText[] = "<\xD0\xB8\xD0\xBC\xD0\xB5\xD0\xB5\xD1\x82>";
|
|
|
|
|
|
|
|
XMLText* text = doc.FirstChildElement( "document" )->FirstChildElement( (const char*) russianElementName )->FirstChild()->ToText();
|
|
|
|
XMLTest( "UTF-8: Browsing russian element name.",
|
|
|
|
russianText,
|
|
|
|
text->Value() );
|
|
|
|
|
|
|
|
// Now try for a round trip.
|
|
|
|
doc.SaveFile( "utf8testout.xml" );
|
|
|
|
|
|
|
|
// Check the round trip.
|
|
|
|
char savedBuf[256];
|
|
|
|
char verifyBuf[256];
|
|
|
|
int okay = 0;
|
|
|
|
|
2012-02-27 05:14:23 +00:00
|
|
|
|
2012-02-28 01:54:22 +00:00
|
|
|
#if defined(_MSC_VER)
|
2012-02-27 05:14:23 +00:00
|
|
|
#pragma warning ( push )
|
|
|
|
#pragma warning ( disable : 4996 ) // Fail to see a compelling reason why this should be deprecated.
|
2012-02-28 01:54:22 +00:00
|
|
|
#endif
|
2012-02-21 17:08:12 +00:00
|
|
|
FILE* saved = fopen( "utf8testout.xml", "r" );
|
|
|
|
FILE* verify = fopen( "utf8testverify.xml", "r" );
|
2012-02-28 01:54:22 +00:00
|
|
|
#if defined(_MSC_VER)
|
2012-02-27 05:14:23 +00:00
|
|
|
#pragma warning ( pop )
|
2012-02-28 01:54:22 +00:00
|
|
|
#endif
|
2012-02-21 17:08:12 +00:00
|
|
|
|
|
|
|
if ( saved && verify )
|
|
|
|
{
|
|
|
|
okay = 1;
|
|
|
|
while ( fgets( verifyBuf, 256, verify ) )
|
|
|
|
{
|
|
|
|
fgets( savedBuf, 256, saved );
|
|
|
|
NullLineEndings( verifyBuf );
|
|
|
|
NullLineEndings( savedBuf );
|
|
|
|
|
|
|
|
if ( strcmp( verifyBuf, savedBuf ) )
|
|
|
|
{
|
|
|
|
printf( "verify:%s<\n", verifyBuf );
|
|
|
|
printf( "saved :%s<\n", savedBuf );
|
|
|
|
okay = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( saved )
|
|
|
|
fclose( saved );
|
|
|
|
if ( verify )
|
|
|
|
fclose( verify );
|
|
|
|
XMLTest( "UTF-8: Verified multi-language round trip.", 1, okay );
|
|
|
|
}
|
|
|
|
|
2012-02-24 06:27:28 +00:00
|
|
|
// --------GetText()-----------
|
|
|
|
{
|
|
|
|
const char* str = "<foo>This is text</foo>";
|
|
|
|
XMLDocument doc;
|
|
|
|
doc.Parse( str );
|
|
|
|
const XMLElement* element = doc.RootElement();
|
|
|
|
|
|
|
|
XMLTest( "GetText() normal use.", "This is text", element->GetText() );
|
|
|
|
|
|
|
|
str = "<foo><b>This is text</b></foo>";
|
|
|
|
doc.Parse( str );
|
|
|
|
element = doc.RootElement();
|
|
|
|
|
|
|
|
XMLTest( "GetText() contained element.", element->GetText() == 0, true );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ---------- CDATA ---------------
|
|
|
|
{
|
|
|
|
const char* str = "<xmlElement>"
|
|
|
|
"<![CDATA["
|
|
|
|
"I am > the rules!\n"
|
|
|
|
"...since I make symbolic puns"
|
|
|
|
"]]>"
|
|
|
|
"</xmlElement>";
|
|
|
|
XMLDocument doc;
|
|
|
|
doc.Parse( str );
|
|
|
|
doc.Print();
|
|
|
|
|
|
|
|
XMLTest( "CDATA parse.", doc.FirstChildElement()->FirstChild()->Value(),
|
|
|
|
"I am > the rules!\n...since I make symbolic puns",
|
2012-02-23 00:00:12 +00:00
|
|
|
false );
|
|
|
|
}
|
2012-02-21 17:08:12 +00:00
|
|
|
|
2012-02-24 06:27:28 +00:00
|
|
|
// ----------- CDATA -------------
|
|
|
|
{
|
|
|
|
const char* str = "<xmlElement>"
|
|
|
|
"<![CDATA["
|
|
|
|
"<b>I am > the rules!</b>\n"
|
|
|
|
"...since I make symbolic puns"
|
|
|
|
"]]>"
|
|
|
|
"</xmlElement>";
|
|
|
|
XMLDocument doc;
|
|
|
|
doc.Parse( str );
|
|
|
|
doc.Print();
|
|
|
|
|
|
|
|
XMLTest( "CDATA parse. [ tixml1:1480107 ]", doc.FirstChildElement()->FirstChild()->Value(),
|
|
|
|
"<b>I am > the rules!</b>\n...since I make symbolic puns",
|
|
|
|
false );
|
|
|
|
}
|
2012-02-23 00:00:12 +00:00
|
|
|
|
2012-02-24 06:27:28 +00:00
|
|
|
// InsertAfterChild causes crash.
|
2012-02-23 00:00:12 +00:00
|
|
|
{
|
2012-02-24 06:27:28 +00:00
|
|
|
// InsertBeforeChild and InsertAfterChild causes crash.
|
|
|
|
XMLDocument doc;
|
|
|
|
XMLElement* parent = doc.NewElement( "Parent" );
|
|
|
|
doc.InsertFirstChild( parent );
|
|
|
|
|
|
|
|
XMLElement* childText0 = doc.NewElement( "childText0" );
|
|
|
|
XMLElement* childText1 = doc.NewElement( "childText1" );
|
|
|
|
|
|
|
|
XMLNode* childNode0 = parent->InsertEndChild( childText0 );
|
|
|
|
XMLNode* childNode1 = parent->InsertAfterChild( childNode0, childText1 );
|
|
|
|
|
|
|
|
XMLTest( "Test InsertAfterChild on empty node. ", ( childNode1 == parent->LastChild() ), true );
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
// Entities not being written correctly.
|
|
|
|
// From Lynn Allen
|
|
|
|
|
|
|
|
const char* passages =
|
|
|
|
"<?xml version=\"1.0\" standalone=\"no\" ?>"
|
|
|
|
"<passages count=\"006\" formatversion=\"20020620\">"
|
|
|
|
"<psg context=\"Line 5 has "quotation marks" and 'apostrophe marks'."
|
|
|
|
" It also has <, >, and &, as well as a fake copyright ©.\"> </psg>"
|
|
|
|
"</passages>";
|
|
|
|
|
|
|
|
XMLDocument doc;
|
|
|
|
doc.Parse( passages );
|
|
|
|
XMLElement* psg = doc.RootElement()->FirstChildElement();
|
|
|
|
const char* context = psg->Attribute( "context" );
|
|
|
|
const char* expected = "Line 5 has \"quotation marks\" and 'apostrophe marks'. It also has <, >, and &, as well as a fake copyright \xC2\xA9.";
|
|
|
|
|
|
|
|
XMLTest( "Entity transformation: read. ", expected, context, true );
|
|
|
|
|
2012-02-28 01:54:22 +00:00
|
|
|
#if defined(_MSC_VER)
|
2012-02-27 05:14:23 +00:00
|
|
|
#pragma warning ( push )
|
|
|
|
#pragma warning ( disable : 4996 ) // Fail to see a compelling reason why this should be deprecated.
|
2012-02-28 01:54:22 +00:00
|
|
|
#endif
|
2012-02-24 06:27:28 +00:00
|
|
|
FILE* textfile = fopen( "textfile.txt", "w" );
|
2012-02-28 01:54:22 +00:00
|
|
|
#if defined(_MSC_VER)
|
2012-02-27 05:14:23 +00:00
|
|
|
#pragma warning ( pop )
|
2012-02-28 01:54:22 +00:00
|
|
|
#endif
|
2012-02-24 06:27:28 +00:00
|
|
|
if ( textfile )
|
|
|
|
{
|
2012-02-25 01:37:53 +00:00
|
|
|
XMLPrinter streamer( textfile );
|
2012-02-24 06:27:28 +00:00
|
|
|
psg->Accept( &streamer );
|
|
|
|
fclose( textfile );
|
|
|
|
}
|
2012-02-28 01:54:22 +00:00
|
|
|
#if defined(_MSC_VER)
|
2012-02-27 05:14:23 +00:00
|
|
|
#pragma warning ( push )
|
|
|
|
#pragma warning ( disable : 4996 ) // Fail to see a compelling reason why this should be deprecated.
|
2012-02-28 01:54:22 +00:00
|
|
|
#endif
|
2012-02-24 06:27:28 +00:00
|
|
|
textfile = fopen( "textfile.txt", "r" );
|
2012-02-28 01:54:22 +00:00
|
|
|
#if defined(_MSC_VER)
|
2012-02-27 05:14:23 +00:00
|
|
|
#pragma warning ( pop )
|
2012-02-28 01:54:22 +00:00
|
|
|
#endif
|
2012-02-24 06:27:28 +00:00
|
|
|
TIXMLASSERT( textfile );
|
|
|
|
if ( textfile )
|
|
|
|
{
|
|
|
|
char buf[ 1024 ];
|
|
|
|
fgets( buf, 1024, textfile );
|
|
|
|
XMLTest( "Entity transformation: write. ",
|
|
|
|
"<psg context=\"Line 5 has "quotation marks" and 'apostrophe marks'."
|
|
|
|
" It also has <, >, and &, as well as a fake copyright \xC2\xA9.\"/>\n",
|
|
|
|
buf, false );
|
|
|
|
}
|
|
|
|
fclose( textfile );
|
|
|
|
}
|
|
|
|
|
2012-03-02 20:59:39 +00:00
|
|
|
{
|
|
|
|
// Suppress entities.
|
|
|
|
const char* passages =
|
|
|
|
"<?xml version=\"1.0\" standalone=\"no\" ?>"
|
|
|
|
"<passages count=\"006\" formatversion=\"20020620\">"
|
|
|
|
"<psg context=\"Line 5 has "quotation marks" and 'apostrophe marks'.\">Crazy &ttk;</psg>"
|
|
|
|
"</passages>";
|
|
|
|
|
|
|
|
XMLDocument doc( false );
|
|
|
|
doc.Parse( passages );
|
|
|
|
|
|
|
|
XMLTest( "No entity parsing.", doc.FirstChildElement()->FirstChildElement()->Attribute( "context" ),
|
|
|
|
"Line 5 has "quotation marks" and 'apostrophe marks'." );
|
|
|
|
XMLTest( "No entity parsing.", doc.FirstChildElement()->FirstChildElement()->FirstChild()->Value(),
|
|
|
|
"Crazy &ttk;" );
|
|
|
|
doc.Print();
|
|
|
|
}
|
|
|
|
|
2012-02-24 06:27:28 +00:00
|
|
|
{
|
|
|
|
const char* test = "<?xml version='1.0'?><a.elem xmi.version='2.0'/>";
|
|
|
|
|
|
|
|
XMLDocument doc;
|
|
|
|
doc.Parse( test );
|
|
|
|
XMLTest( "dot in names", doc.Error(), 0);
|
|
|
|
XMLTest( "dot in names", doc.FirstChildElement()->Name(), "a.elem" );
|
|
|
|
XMLTest( "dot in names", doc.FirstChildElement()->Attribute( "xmi.version" ), "2.0" );
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
const char* test = "<element><Name>1.1 Start easy ignore fin thickness
</Name></element>";
|
|
|
|
|
|
|
|
XMLDocument doc;
|
|
|
|
doc.Parse( test );
|
|
|
|
|
|
|
|
XMLText* text = doc.FirstChildElement()->FirstChildElement()->FirstChild()->ToText();
|
|
|
|
XMLTest( "Entity with one digit.",
|
|
|
|
text->Value(), "1.1 Start easy ignore fin thickness\n",
|
|
|
|
false );
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
// DOCTYPE not preserved (950171)
|
|
|
|
//
|
|
|
|
const char* doctype =
|
|
|
|
"<?xml version=\"1.0\" ?>"
|
|
|
|
"<!DOCTYPE PLAY SYSTEM 'play.dtd'>"
|
|
|
|
"<!ELEMENT title (#PCDATA)>"
|
|
|
|
"<!ELEMENT books (title,authors)>"
|
|
|
|
"<element />";
|
|
|
|
|
|
|
|
XMLDocument doc;
|
|
|
|
doc.Parse( doctype );
|
|
|
|
doc.SaveFile( "test7.xml" );
|
|
|
|
doc.DeleteChild( doc.RootElement() );
|
|
|
|
doc.LoadFile( "test7.xml" );
|
|
|
|
doc.Print();
|
|
|
|
|
|
|
|
const XMLUnknown* decl = doc.FirstChild()->NextSibling()->ToUnknown();
|
|
|
|
XMLTest( "Correct value of unknown.", "DOCTYPE PLAY SYSTEM 'play.dtd'", decl->Value() );
|
2012-02-23 00:00:12 +00:00
|
|
|
|
2012-02-24 06:27:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
// Comments do not stream out correctly.
|
|
|
|
const char* doctype =
|
|
|
|
"<!-- Somewhat<evil> -->";
|
|
|
|
XMLDocument doc;
|
|
|
|
doc.Parse( doctype );
|
|
|
|
|
|
|
|
XMLComment* comment = doc.FirstChild()->ToComment();
|
|
|
|
|
|
|
|
XMLTest( "Comment formatting.", " Somewhat<evil> ", comment->Value() );
|
|
|
|
}
|
|
|
|
{
|
|
|
|
// Double attributes
|
|
|
|
const char* doctype = "<element attr='red' attr='blue' />";
|
|
|
|
|
|
|
|
XMLDocument doc;
|
|
|
|
doc.Parse( doctype );
|
|
|
|
|
2012-03-20 18:26:57 +00:00
|
|
|
XMLTest( "Parsing repeated attributes.", XML_ERROR_PARSING_ATTRIBUTE, doc.ErrorID() ); // is an error to tinyxml (didn't use to be, but caused issues)
|
2012-02-28 04:50:52 +00:00
|
|
|
doc.PrintError();
|
2012-02-24 06:27:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
// Embedded null in stream.
|
|
|
|
const char* doctype = "<element att\0r='red' attr='blue' />";
|
|
|
|
|
|
|
|
XMLDocument doc;
|
|
|
|
doc.Parse( doctype );
|
|
|
|
XMLTest( "Embedded null throws error.", true, doc.Error() );
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2012-03-20 18:26:57 +00:00
|
|
|
// Empty documents should return TIXML_XML_ERROR_PARSING_EMPTY, bug 1070717
|
2012-02-24 06:27:28 +00:00
|
|
|
const char* str = " ";
|
|
|
|
XMLDocument doc;
|
|
|
|
doc.Parse( str );
|
2012-03-20 18:26:57 +00:00
|
|
|
XMLTest( "Empty document error", XML_ERROR_EMPTY_DOCUMENT, doc.ErrorID() );
|
2012-02-24 06:27:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
// Low entities
|
|
|
|
XMLDocument doc;
|
|
|
|
doc.Parse( "<test></test>" );
|
|
|
|
const char result[] = { 0x0e, 0 };
|
|
|
|
XMLTest( "Low entities.", doc.FirstChildElement()->GetText(), result );
|
|
|
|
doc.Print();
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
// Attribute values with trailing quotes not handled correctly
|
|
|
|
XMLDocument doc;
|
|
|
|
doc.Parse( "<foo attribute=bar\" />" );
|
|
|
|
XMLTest( "Throw error with bad end quotes.", doc.Error(), true );
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
// [ 1663758 ] Failure to report error on bad XML
|
|
|
|
XMLDocument xml;
|
|
|
|
xml.Parse("<x>");
|
|
|
|
XMLTest("Missing end tag at end of input", xml.Error(), true);
|
|
|
|
xml.Parse("<x> ");
|
|
|
|
XMLTest("Missing end tag with trailing whitespace", xml.Error(), true);
|
|
|
|
xml.Parse("<x></y>");
|
2012-03-20 18:26:57 +00:00
|
|
|
XMLTest("Mismatched tags", xml.ErrorID(), XML_ERROR_MISMATCHED_ELEMENT);
|
2012-02-24 06:27:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
// [ 1475201 ] TinyXML parses entities in comments
|
|
|
|
XMLDocument xml;
|
|
|
|
xml.Parse("<!-- declarations for <head> & <body> -->"
|
|
|
|
"<!-- far & away -->" );
|
|
|
|
|
|
|
|
XMLNode* e0 = xml.FirstChild();
|
|
|
|
XMLNode* e1 = e0->NextSibling();
|
|
|
|
XMLComment* c0 = e0->ToComment();
|
|
|
|
XMLComment* c1 = e1->ToComment();
|
|
|
|
|
|
|
|
XMLTest( "Comments ignore entities.", " declarations for <head> & <body> ", c0->Value(), true );
|
|
|
|
XMLTest( "Comments ignore entities.", " far & away ", c1->Value(), true );
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
XMLDocument xml;
|
|
|
|
xml.Parse( "<Parent>"
|
|
|
|
"<child1 att=''/>"
|
|
|
|
"<!-- With this comment, child2 will not be parsed! -->"
|
|
|
|
"<child2 att=''/>"
|
|
|
|
"</Parent>" );
|
|
|
|
xml.Print();
|
|
|
|
|
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
for( XMLNode* ele = xml.FirstChildElement( "Parent" )->FirstChild();
|
|
|
|
ele;
|
|
|
|
ele = ele->NextSibling() )
|
|
|
|
{
|
|
|
|
++count;
|
|
|
|
}
|
|
|
|
|
|
|
|
XMLTest( "Comments iterate correctly.", 3, count );
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
// trying to repro ]1874301]. If it doesn't go into an infinite loop, all is well.
|
|
|
|
unsigned char buf[] = "<?xml version=\"1.0\" encoding=\"utf-8\"?><feed><![CDATA[Test XMLblablablalblbl";
|
|
|
|
buf[60] = 239;
|
|
|
|
buf[61] = 0;
|
|
|
|
|
|
|
|
XMLDocument doc;
|
|
|
|
doc.Parse( (const char*)buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
// bug 1827248 Error while parsing a little bit malformed file
|
|
|
|
// Actually not malformed - should work.
|
|
|
|
XMLDocument xml;
|
|
|
|
xml.Parse( "<attributelist> </attributelist >" );
|
|
|
|
XMLTest( "Handle end tag whitespace", false, xml.Error() );
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
// This one must not result in an infinite loop
|
|
|
|
XMLDocument xml;
|
|
|
|
xml.Parse( "<infinite>loop" );
|
|
|
|
XMLTest( "Infinite loop test.", true, true );
|
|
|
|
}
|
|
|
|
#endif
|
2012-02-28 01:54:22 +00:00
|
|
|
{
|
|
|
|
const char* pub = "<?xml version='1.0'?> <element><sub/></element> <!--comment--> <!DOCTYPE>";
|
|
|
|
XMLDocument doc;
|
|
|
|
doc.Parse( pub );
|
|
|
|
|
|
|
|
XMLDocument clone;
|
|
|
|
for( const XMLNode* node=doc.FirstChild(); node; node=node->NextSibling() ) {
|
|
|
|
XMLNode* copy = node->ShallowClone( &clone );
|
|
|
|
clone.InsertEndChild( copy );
|
|
|
|
}
|
|
|
|
|
|
|
|
clone.Print();
|
|
|
|
|
|
|
|
int count=0;
|
|
|
|
const XMLNode* a=clone.FirstChild();
|
|
|
|
const XMLNode* b=doc.FirstChild();
|
|
|
|
for( ; a && b; a=a->NextSibling(), b=b->NextSibling() ) {
|
|
|
|
++count;
|
|
|
|
XMLTest( "Clone and Equal", true, a->ShallowEqual( b ));
|
|
|
|
}
|
|
|
|
XMLTest( "Clone and Equal", 4, count );
|
|
|
|
}
|
2012-02-25 01:37:53 +00:00
|
|
|
|
2012-04-07 04:24:29 +00:00
|
|
|
{
|
|
|
|
// This shouldn't crash.
|
|
|
|
XMLDocument doc;
|
|
|
|
if(XML_NO_ERROR != doc.LoadFile( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ))
|
|
|
|
{
|
|
|
|
doc.PrintError();
|
|
|
|
}
|
|
|
|
XMLTest( "Error in snprinf handling.", true, doc.Error() );
|
|
|
|
}
|
|
|
|
|
2012-03-29 00:46:41 +00:00
|
|
|
// -------- Handles ------------
|
|
|
|
{
|
|
|
|
static const char* xml = "<element attrib='bar'><sub>Text</sub></element>";
|
|
|
|
XMLDocument doc;
|
|
|
|
doc.Parse( xml );
|
|
|
|
|
|
|
|
XMLElement* ele = XMLHandle( doc ).FirstChildElement( "element" ).FirstChild().ToElement();
|
|
|
|
XMLTest( "Handle, success, mutable", ele->Value(), "sub" );
|
|
|
|
|
2012-04-05 05:00:07 +00:00
|
|
|
XMLHandle docH( doc );
|
|
|
|
ele = docH.FirstChildElement( "none" ).FirstChildElement( "element" ).ToElement();
|
|
|
|
XMLTest( "Handle, dne, mutable", 0, (int)ele );
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
static const char* xml = "<element attrib='bar'><sub>Text</sub></element>";
|
|
|
|
XMLDocument doc;
|
|
|
|
doc.Parse( xml );
|
|
|
|
XMLConstHandle docH( doc );
|
2012-03-29 00:46:41 +00:00
|
|
|
|
2012-04-05 05:00:07 +00:00
|
|
|
const XMLElement* ele = docH.FirstChildElement( "element" ).FirstChild().ToElement();
|
|
|
|
XMLTest( "Handle, success, const", ele->Value(), "sub" );
|
|
|
|
|
|
|
|
ele = docH.FirstChildElement( "none" ).FirstChildElement( "element" ).ToElement();
|
|
|
|
XMLTest( "Handle, dne, const", 0, (int)ele );
|
2012-03-29 00:46:41 +00:00
|
|
|
}
|
2012-04-05 05:00:07 +00:00
|
|
|
|
2012-03-29 00:46:41 +00:00
|
|
|
|
2012-03-02 20:59:39 +00:00
|
|
|
// ----------- Performance tracking --------------
|
|
|
|
{
|
|
|
|
#if defined( _MSC_VER )
|
|
|
|
__int64 start, end, freq;
|
|
|
|
QueryPerformanceFrequency( (LARGE_INTEGER*) &freq );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(_MSC_VER)
|
|
|
|
#pragma warning ( push )
|
|
|
|
#pragma warning ( disable : 4996 ) // Fail to see a compelling reason why this should be deprecated.
|
|
|
|
#endif
|
|
|
|
FILE* fp = fopen( "dream.xml", "r" );
|
|
|
|
#if defined(_MSC_VER)
|
|
|
|
#pragma warning ( pop )
|
|
|
|
#endif
|
|
|
|
fseek( fp, 0, SEEK_END );
|
|
|
|
long size = ftell( fp );
|
|
|
|
fseek( fp, 0, SEEK_SET );
|
|
|
|
|
|
|
|
char* mem = new char[size+1];
|
|
|
|
fread( mem, size, 1, fp );
|
|
|
|
fclose( fp );
|
|
|
|
mem[size] = 0;
|
|
|
|
|
|
|
|
#if defined( _MSC_VER )
|
|
|
|
QueryPerformanceCounter( (LARGE_INTEGER*) &start );
|
|
|
|
#else
|
|
|
|
clock_t cstart = clock();
|
|
|
|
#endif
|
|
|
|
static const int COUNT = 10;
|
|
|
|
for( int i=0; i<COUNT; ++i ) {
|
|
|
|
XMLDocument doc;
|
|
|
|
doc.Parse( mem );
|
|
|
|
}
|
|
|
|
#if defined( _MSC_VER )
|
|
|
|
QueryPerformanceCounter( (LARGE_INTEGER*) &end );
|
|
|
|
#else
|
|
|
|
clock_t cend = clock();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
delete [] mem;
|
|
|
|
|
|
|
|
static const char* note =
|
|
|
|
#ifdef DEBUG
|
|
|
|
"DEBUG";
|
|
|
|
#else
|
|
|
|
"Release";
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined( _MSC_VER )
|
|
|
|
printf( "\nParsing %s of dream.xml: %.3f milli-seconds\n", note, 1000.0 * (double)(end-start) / ( (double)freq * (double)COUNT) );
|
|
|
|
#else
|
|
|
|
printf( "\nParsing %s of dream.xml: %.3f milli-seconds\n", note, (double)(cend - cstart)/(double)COUNT );
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2012-03-08 05:54:57 +00:00
|
|
|
#if defined( _MSC_VER ) && defined( DEBUG )
|
2012-02-15 02:18:16 +00:00
|
|
|
_CrtMemCheckpoint( &endMemState );
|
|
|
|
//_CrtMemDumpStatistics( &endMemState );
|
|
|
|
|
|
|
|
_CrtMemState diffMemState;
|
|
|
|
_CrtMemDifference( &diffMemState, &startMemState, &endMemState );
|
|
|
|
_CrtMemDumpStatistics( &diffMemState );
|
2012-02-21 04:14:33 +00:00
|
|
|
//printf( "new total=%d\n", gNewTotal );
|
2012-02-15 02:18:16 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
printf ("\nPass %d, Fail %d\n", gPass, gFail);
|
2011-12-28 22:36:55 +00:00
|
|
|
return 0;
|
2012-02-26 05:30:18 +00:00
|
|
|
}
|