testing infrastructur

This commit is contained in:
Lee Thomason 2012-02-13 18:16:52 -08:00
parent e9ecdabf94
commit ec5a7b4d18
2 changed files with 57 additions and 1 deletions

View File

@ -648,7 +648,7 @@ XMLDocument::~XMLDocument()
ClearChildren(); ClearChildren();
delete [] charBuffer; delete [] charBuffer;
#if 1 #if 0
textPool.Trace( "text" ); textPool.Trace( "text" );
elementPool.Trace( "element" ); elementPool.Trace( "element" );
commentPool.Trace( "comment" ); commentPool.Trace( "comment" );

View File

@ -2,6 +2,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#if defined( WIN32 ) #if defined( WIN32 )
#include <crtdbg.h> #include <crtdbg.h>
@ -10,6 +11,50 @@
#endif #endif
using namespace tinyxml2; using namespace tinyxml2;
int gPass = 0;
int gFail = 0;
bool XmlTest (const char* testString, const char* expected, const char* found, bool noEcho )
{
bool pass = !strcmp( expected, found );
if ( pass )
printf ("[pass]");
else
printf ("[fail]");
if ( noEcho )
printf (" %s\n", testString);
else
printf (" %s [%s][%s]\n", testString, expected, found);
if ( pass )
++gPass;
else
++gFail;
return pass;
}
bool XmlTest( const char* testString, int expected, int found, bool noEcho )
{
bool pass = ( expected == found );
if ( pass )
printf ("[pass]");
else
printf ("[fail]");
if ( noEcho )
printf (" %s\n", testString);
else
printf (" %s [%d][%d]\n", testString, expected, found);
if ( pass )
++gPass;
else
++gFail;
return pass;
}
int main( int argc, const char* argv ) int main( int argc, const char* argv )
{ {
@ -75,11 +120,20 @@ int main( int argc, const char* argv )
} }
#endif #endif
{ {
// Build:
// <element>
// <!--comment-->
// <sub attrib="1" />
// <sub attrib="2" />
// <sub attrib="3" />
// <element>
XMLDocument* doc = new XMLDocument(); XMLDocument* doc = new XMLDocument();
doc->InsertEndChild( doc->NewElement( "element" ) ); doc->InsertEndChild( doc->NewElement( "element" ) );
doc->Print(); doc->Print();
delete doc; delete doc;
} }
#if defined( WIN32 ) #if defined( WIN32 )
_CrtMemCheckpoint( &endMemState ); _CrtMemCheckpoint( &endMemState );
//_CrtMemDumpStatistics( &endMemState ); //_CrtMemDumpStatistics( &endMemState );
@ -88,5 +142,7 @@ int main( int argc, const char* argv )
_CrtMemDifference( &diffMemState, &startMemState, &endMemState ); _CrtMemDifference( &diffMemState, &startMemState, &endMemState );
_CrtMemDumpStatistics( &diffMemState ); _CrtMemDumpStatistics( &diffMemState );
#endif #endif
printf ("\nPass %d, Fail %d\n", gPass, gFail);
return 0; return 0;
} }