From ec5a7b4d18a9dd2a48f617cb1e1fffe966efabba Mon Sep 17 00:00:00 2001 From: Lee Thomason Date: Mon, 13 Feb 2012 18:16:52 -0800 Subject: [PATCH] testing infrastructur --- tinyxml2.cpp | 2 +- xmltest.cpp | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/tinyxml2.cpp b/tinyxml2.cpp index c0711a6..f45ae74 100644 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp @@ -648,7 +648,7 @@ XMLDocument::~XMLDocument() ClearChildren(); delete [] charBuffer; -#if 1 +#if 0 textPool.Trace( "text" ); elementPool.Trace( "element" ); commentPool.Trace( "comment" ); diff --git a/xmltest.cpp b/xmltest.cpp index 88f8ac4..b2c2047 100644 --- a/xmltest.cpp +++ b/xmltest.cpp @@ -2,6 +2,7 @@ #include #include +#include #if defined( WIN32 ) #include @@ -10,6 +11,50 @@ #endif 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 ) { @@ -75,11 +120,20 @@ int main( int argc, const char* argv ) } #endif { + // Build: + // + // + // + // + // + // + XMLDocument* doc = new XMLDocument(); doc->InsertEndChild( doc->NewElement( "element" ) ); doc->Print(); delete doc; } + #if defined( WIN32 ) _CrtMemCheckpoint( &endMemState ); //_CrtMemDumpStatistics( &endMemState ); @@ -88,5 +142,7 @@ int main( int argc, const char* argv ) _CrtMemDifference( &diffMemState, &startMemState, &endMemState ); _CrtMemDumpStatistics( &diffMemState ); #endif + + printf ("\nPass %d, Fail %d\n", gPass, gFail); return 0; } \ No newline at end of file