I'm writing a script (in Python) that, given a file whose content is:
#ifndef AoeuTest_H
#define AoeuTest_H
#include <boost/utility.hpp>
#include <cppunit/TestFixture.h>
namespace aoeu
{
class AoeuTest:
public CppUnit::TestFixture,
private boost::noncopyable
{
public: void test0();
public: void test1();
};
}
#endif
will output:
#include "AoeuTest.H"
#include <cppunit/TestCaller.h>
#include <cppunit/TestSuite.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <memory>
#include <MSBase/MSSingleton.H>
using namespace aoeu;
namespace
{
class _TestFactory:
public CppUnit::TestFactory
{
public: virtual CppUnit::Test* makeTest();
};
CppUnit::Test*
_TestFactory::makeTest()
{
std::auto_ptr< CppUnit::TestSuite > result(
new CppUnit::TestSuite( "AoeuTest" ) );
result->addTest(
new CppUnit::TestCaller< AoeuTest >(
"aoeu::AoeuTest::test0()",
&AoeuTest::test0 ) );
result->addTest(
new CppUnit::TestCaller< AoeuTest >(
"aoeu::AoeuTest::test1()",
&AoeuTest::test1 ) );
return result.release();
}
}
namespace
{
bool _registerFactory();
bool _factoryRegistration = ::_registerFactory();
bool _registerFactory()
{
CppUnit::TestFactoryRegistry::getRegistry().registerFactory( &MSSingleton< ::_TestFactory >::instance() );
CppUnit::TestFactoryRegistry::getRegistry( "aoeu::AoeuTest" ).registerFactory( &MSSingleton< ::_TestFactory >::instance() );
return true;
}
}
Would such a script be helpful to the CppUnit project in general?
Thanks,
Noel
|