summaryrefslogtreecommitdiff
path: root/src/cppunit/TestFactoryRegistry.cpp
diff options
context:
space:
mode:
authorBastiaan Bakker <bastiaan.bakker@lifeline.nl>2001-05-05 22:34:50 +0000
committerBastiaan Bakker <bastiaan.bakker@lifeline.nl>2001-05-05 22:34:50 +0000
commitb657aa515178205772ab2e95f365bd5a77364610 (patch)
tree680d530a1a4c6bbd3dcfa1a867ff608ed1175fa1 /src/cppunit/TestFactoryRegistry.cpp
parenta2509e56dd1e457e88d32410d7524a1363f59e96 (diff)
downloadcppunit-b657aa515178205772ab2e95f365bd5a77364610.tar.gz
Merge of CppUnitW 1.2 phase 2.
Diffstat (limited to 'src/cppunit/TestFactoryRegistry.cpp')
-rw-r--r--src/cppunit/TestFactoryRegistry.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/cppunit/TestFactoryRegistry.cpp b/src/cppunit/TestFactoryRegistry.cpp
index 3f390f6..b38cbb4 100644
--- a/src/cppunit/TestFactoryRegistry.cpp
+++ b/src/cppunit/TestFactoryRegistry.cpp
@@ -9,7 +9,7 @@
#include "cppunit/extensions/TestSuiteBuilder.h"
#ifdef USE_TYPEINFO
-#include "../TypeInfoHelper.h"
+#include "TypeInfoHelper.h"
#endif // USE_TYPEINFO
namespace CppUnit {
@@ -22,6 +22,11 @@ TestFactoryRegistry::TestFactoryRegistry( std::string name ) :
TestFactoryRegistry::~TestFactoryRegistry()
{
+ for ( Factories::iterator it = m_factories.begin(); it != m_factories.end(); ++it )
+ {
+ AbstractTestFactory *factory = it->second;
+ delete factory;
+ }
}
@@ -36,14 +41,22 @@ TestFactoryRegistry::getRegistry()
TestFactoryRegistry &
TestFactoryRegistry::getRegistry( const std::string &name )
{
+// No clean-up at the current time => memory leaks.
+// Need to find a way to solve the folowing issue:
+// getRegistry().registryFactory( "Functionnal",
+// getRegistry( "Functionnal" ) );
+// => the test factory registry "Functionnal" would be
+// destroyed twice: once by the map below, once by the getRegistry() factory.
static NamedRegistries registries;
- TestFactoryRegistry*& registryPointer = registries[ name ];
- if (NULL == registryPointer) {
- registryPointer = new TestFactoryRegistry( name );
+ NamedRegistries::const_iterator foundIt = registries.find( name );
+ if ( foundIt == registries.end() )
+ {
+ TestFactoryRegistry *factory = new TestFactoryRegistry( name );
+ registries.insert( std::make_pair( name, factory ) );
+ return *factory;
}
-
- return *registryPointer;
+ return *foundIt->second;
}