summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-06-01 08:48:42 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-06-01 09:24:28 (GMT)
commit2812bddd81f8a1b804c7460f4e14cd0aa393d129 (patch)
treed46294f35150c4f0f43deaf2d31fceaf945ae715 /3rdParty/CppUnit/src/Test.cpp
downloadswift-2812bddd81f8a1b804c7460f4e14cd0aa393d129.zip
swift-2812bddd81f8a1b804c7460f4e14cd0aa393d129.tar.bz2
Import.
Diffstat (limited to '3rdParty/CppUnit/src/Test.cpp')
-rw-r--r--3rdParty/CppUnit/src/Test.cpp97
1 files changed, 97 insertions, 0 deletions
diff --git a/3rdParty/CppUnit/src/Test.cpp b/3rdParty/CppUnit/src/Test.cpp
new file mode 100644
index 0000000..fef8be7
--- /dev/null
+++ b/3rdParty/CppUnit/src/Test.cpp
@@ -0,0 +1,97 @@
+#include <cppunit/Portability.h>
+#include <cppunit/Test.h>
+#include <cppunit/TestPath.h>
+#include <stdexcept>
+
+
+CPPUNIT_NS_BEGIN
+
+
+Test *
+Test::getChildTestAt( int index ) const
+{
+ checkIsValidIndex( index );
+ return doGetChildTestAt( index );
+}
+
+
+Test *
+Test::findTest( const std::string &testName ) const
+{
+ TestPath path;
+ Test *mutableThis = CPPUNIT_CONST_CAST( Test *, this );
+ mutableThis->findTestPath( testName, path );
+ if ( !path.isValid() )
+ throw std::invalid_argument( "No test named <" + testName + "> found in test <"
+ + getName() + ">." );
+ return path.getChildTest();
+}
+
+
+bool
+Test::findTestPath( const std::string &testName,
+ TestPath &testPath ) const
+{
+ Test *mutableThis = CPPUNIT_CONST_CAST( Test *, this );
+ if ( getName() == testName )
+ {
+ testPath.add( mutableThis );
+ return true;
+ }
+
+ int childCount = getChildTestCount();
+ for ( int childIndex =0; childIndex < childCount; ++childIndex )
+ {
+ if ( getChildTestAt( childIndex )->findTestPath( testName, testPath ) )
+ {
+ testPath.insert( mutableThis, 0 );
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+bool
+Test::findTestPath( const Test *test,
+ TestPath &testPath ) const
+{
+ Test *mutableThis = CPPUNIT_CONST_CAST( Test *, this );
+ if ( this == test )
+ {
+ testPath.add( mutableThis );
+ return true;
+ }
+
+ int childCount = getChildTestCount();
+ for ( int childIndex =0; childIndex < childCount; ++childIndex )
+ {
+ if ( getChildTestAt( childIndex )->findTestPath( test, testPath ) )
+ {
+ testPath.insert( mutableThis, 0 );
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+TestPath
+Test::resolveTestPath( const std::string &testPath ) const
+{
+ Test *mutableThis = CPPUNIT_CONST_CAST( Test *, this );
+ return TestPath( mutableThis, testPath );
+}
+
+
+void
+Test::checkIsValidIndex( int index ) const
+{
+ if ( index < 0 || index >= getChildTestCount() )
+ throw std::out_of_range( "Test::checkValidIndex(): invalid index" );
+}
+
+
+CPPUNIT_NS_END