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/TestResultCollector.cpp
downloadswift-contrib-2812bddd81f8a1b804c7460f4e14cd0aa393d129.zip
swift-contrib-2812bddd81f8a1b804c7460f4e14cd0aa393d129.tar.bz2
Import.
Diffstat (limited to '3rdParty/CppUnit/src/TestResultCollector.cpp')
-rw-r--r--3rdParty/CppUnit/src/TestResultCollector.cpp117
1 files changed, 117 insertions, 0 deletions
diff --git a/3rdParty/CppUnit/src/TestResultCollector.cpp b/3rdParty/CppUnit/src/TestResultCollector.cpp
new file mode 100644
index 0000000..4371c50
--- /dev/null
+++ b/3rdParty/CppUnit/src/TestResultCollector.cpp
@@ -0,0 +1,117 @@
+#include <cppunit/TestFailure.h>
+#include <cppunit/TestResultCollector.h>
+
+
+CPPUNIT_NS_BEGIN
+
+
+TestResultCollector::TestResultCollector( SynchronizationObject *syncObject )
+ : TestSuccessListener( syncObject )
+{
+ reset();
+}
+
+
+TestResultCollector::~TestResultCollector()
+{
+ freeFailures();
+}
+
+
+void
+TestResultCollector::freeFailures()
+{
+ TestFailures::iterator itFailure = m_failures.begin();
+ while ( itFailure != m_failures.end() )
+ delete *itFailure++;
+ m_failures.clear();
+}
+
+
+void
+TestResultCollector::reset()
+{
+ TestSuccessListener::reset();
+
+ ExclusiveZone zone( m_syncObject );
+ freeFailures();
+ m_testErrors = 0;
+ m_tests.clear();
+}
+
+
+void
+TestResultCollector::startTest( Test *test )
+{
+ ExclusiveZone zone (m_syncObject);
+ m_tests.push_back( test );
+}
+
+
+void
+TestResultCollector::addFailure( const TestFailure &failure )
+{
+ TestSuccessListener::addFailure( failure );
+
+ ExclusiveZone zone( m_syncObject );
+ if ( failure.isError() )
+ ++m_testErrors;
+ m_failures.push_back( failure.clone() );
+}
+
+
+/// Gets the number of run tests.
+int
+TestResultCollector::runTests() const
+{
+ ExclusiveZone zone( m_syncObject );
+ return m_tests.size();
+}
+
+
+/// Gets the number of detected errors (uncaught exception).
+int
+TestResultCollector::testErrors() const
+{
+ ExclusiveZone zone( m_syncObject );
+ return m_testErrors;
+}
+
+
+/// Gets the number of detected failures (failed assertion).
+int
+TestResultCollector::testFailures() const
+{
+ ExclusiveZone zone( m_syncObject );
+ return m_failures.size() - m_testErrors;
+}
+
+
+/// Gets the total number of detected failures.
+int
+TestResultCollector::testFailuresTotal() const
+{
+ ExclusiveZone zone( m_syncObject );
+ return m_failures.size();
+}
+
+
+/// Returns a the list failures (random access collection).
+const TestResultCollector::TestFailures &
+TestResultCollector::failures() const
+{
+ ExclusiveZone zone( m_syncObject );
+ return m_failures;
+}
+
+
+const TestResultCollector::Tests &
+TestResultCollector::tests() const
+{
+ ExclusiveZone zone( m_syncObject );
+ return m_tests;
+}
+
+
+CPPUNIT_NS_END
+