summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-02-11 12:14:00 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-02-11 12:14:00 (GMT)
commit0efa7c32aaf21a29b42b5926cc116007056843be (patch)
tree882f663a5dd0e65694bf6077b71086dd77fd7ff8 /3rdParty/CppUnit/src/TestFactoryRegistry.cpp
parent1d20eabbc32274b491b4c2bedf73d19933d97bfd (diff)
downloadswift-contrib-0efa7c32aaf21a29b42b5926cc116007056843be.zip
swift-contrib-0efa7c32aaf21a29b42b5926cc116007056843be.tar.bz2
Moved some modules into separate git modules.
Diffstat (limited to '3rdParty/CppUnit/src/TestFactoryRegistry.cpp')
m---------3rdParty/CppUnit0
-rw-r--r--3rdParty/CppUnit/src/TestFactoryRegistry.cpp161
2 files changed, 0 insertions, 161 deletions
diff --git a/3rdParty/CppUnit b/3rdParty/CppUnit
new file mode 160000
+Subproject b4c34eb947c6497c6387c55c7581ec875f4e7d4
diff --git a/3rdParty/CppUnit/src/TestFactoryRegistry.cpp b/3rdParty/CppUnit/src/TestFactoryRegistry.cpp
deleted file mode 100644
index 3457da3..0000000
--- a/3rdParty/CppUnit/src/TestFactoryRegistry.cpp
+++ /dev/null
@@ -1,161 +0,0 @@
-#include <cppunit/config/SourcePrefix.h>
-#include <cppunit/extensions/TestFactoryRegistry.h>
-#include <cppunit/portability/CppUnitMap.h>
-#include <cppunit/TestSuite.h>
-#include <assert.h>
-
-
-CPPUNIT_NS_BEGIN
-
-/*! \brief (INTERNAL) List of all TestFactoryRegistry.
- */
-class TestFactoryRegistryList
-{
-private:
- typedef CppUnitMap<std::string, TestFactoryRegistry *, std::less<std::string> > Registries;
- Registries m_registries;
-
- enum State {
- doNotChange =0,
- notCreated,
- exist,
- destroyed
- };
-
- static State stateFlag( State newState = doNotChange )
- {
- static State state = notCreated;
- if ( newState != doNotChange )
- state = newState;
- return state;
- }
-
- static TestFactoryRegistryList *getInstance()
- {
- static TestFactoryRegistryList list;
- return &list;
- }
-
- TestFactoryRegistry *getInternalRegistry( const std::string &name )
- {
- Registries::const_iterator foundIt = m_registries.find( name );
- if ( foundIt == m_registries.end() )
- {
- TestFactoryRegistry *factory = new TestFactoryRegistry( name );
- m_registries.insert( std::pair<const std::string, TestFactoryRegistry*>( name, factory ) );
- return factory;
- }
- return (*foundIt).second;
- }
-
-public:
- TestFactoryRegistryList()
- {
- stateFlag( exist );
- }
-
- ~TestFactoryRegistryList()
- {
- for ( Registries::iterator it = m_registries.begin(); it != m_registries.end(); ++it )
- delete (*it).second;
-
- stateFlag( destroyed );
- }
-
- static TestFactoryRegistry *getRegistry( const std::string &name )
- {
- // If the following assertion failed, then TestFactoryRegistry::getRegistry()
- // was called during static variable destruction without checking the registry
- // validity beforehand using TestFactoryRegistry::isValid() beforehand.
- assert( isValid() );
- if ( !isValid() ) // release mode
- return NULL; // => force CRASH
-
- return getInstance()->getInternalRegistry( name );
- }
-
- static bool isValid()
- {
- return stateFlag() != destroyed;
- }
-};
-
-
-
-TestFactoryRegistry::TestFactoryRegistry( std::string name ) :
- m_name( name )
-{
-}
-
-
-TestFactoryRegistry::~TestFactoryRegistry()
-{
-}
-
-
-TestFactoryRegistry &
-TestFactoryRegistry::getRegistry( const std::string &name )
-{
- return *TestFactoryRegistryList::getRegistry( name );
-}
-
-
-void
-TestFactoryRegistry::registerFactory( const std::string &,
- TestFactory *factory )
-{
- registerFactory( factory );
-}
-
-
-void
-TestFactoryRegistry::registerFactory( TestFactory *factory )
-{
- m_factories.insert( factory );
-}
-
-
-void
-TestFactoryRegistry::unregisterFactory( TestFactory *factory )
-{
- m_factories.erase( factory );
-}
-
-
-void
-TestFactoryRegistry::addRegistry( const std::string &name )
-{
- registerFactory( &getRegistry( name ) );
-}
-
-
-Test *
-TestFactoryRegistry::makeTest()
-{
- TestSuite *suite = new TestSuite( m_name );
- addTestToSuite( suite );
- return suite;
-}
-
-
-void
-TestFactoryRegistry::addTestToSuite( TestSuite *suite )
-{
- for ( Factories::iterator it = m_factories.begin();
- it != m_factories.end();
- ++it )
- {
- TestFactory *factory = *it;
- suite->addTest( factory->makeTest() );
- }
-}
-
-
-bool
-TestFactoryRegistry::isValid()
-{
- return TestFactoryRegistryList::isValid();
-}
-
-
-CPPUNIT_NS_END