Bläddra i källkod

testing infrastructur

Lee Thomason 14 år sedan
förälder
incheckning
ec5a7b4d18
2 ändrade filer med 57 tillägg och 1 borttagningar
  1. 1 1
      tinyxml2.cpp
  2. 56 0
      xmltest.cpp

+ 1 - 1
tinyxml2.cpp

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

+ 56 - 0
xmltest.cpp

@@ -2,6 +2,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
 #if defined( WIN32 )
 	#include <crtdbg.h>
@@ -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:
+		//		<element>
+		//			<!--comment-->
+		//			<sub attrib="1" />
+		//			<sub attrib="2" />
+		//			<sub attrib="3" />
+		//		<element>
+
 		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;
 }