/* * Project: MoleCuilder * Description: creates and alters molecular systems * Copyright (C) 2010 University of Bonn. All rights reserved. * Please see the LICENSE file or "Copyright notice" in builder.cpp for details. */ /* * RandomNumberEngineFactoryUnitTest.cpp * * Created on: Jan 03, 2011 * Author: heber */ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include "CodePatterns/Assert.hpp" #include "RandomNumberEngineFactoryUnitTest.hpp" #include "RandomNumbers/RandomNumberEngine_Encapsulation.hpp" #include "RandomNumbers/RandomNumberEngineFactory.hpp" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_TESTRUNNER #include "UnitTestMain.hpp" #endif /*HAVE_TESTRUNNER*/ /********************************************** Test classes **************************************/ // Registers the fixture into the 'registry' CPPUNIT_TEST_SUITE_REGISTRATION( RandomNumberEngineFactoryTest ); void RandomNumberEngineFactoryTest::setUp() { RandomNumberEngineFactory::getInstance(); } void RandomNumberEngineFactoryTest::tearDown() { RandomNumberEngineFactory::purgeInstance(); } void RandomNumberEngineFactoryTest::EngineTest() { // check the injectiveness of enum and string map for (RandomNumberEngineFactory::EngineNamesMap::const_iterator iter = RandomNumberEngineFactory::getInstance().engineNames.begin(); iter != RandomNumberEngineFactory::getInstance().engineNames.end(); ++iter) { CPPUNIT_ASSERT_EQUAL( iter->second, RandomNumberEngineFactory::getInstance().getName( RandomNumberEngineFactory::getInstance().getEnum( iter->second ) ) ); } // check one of the engines in the table RandomNumberEngine* rng = RandomNumberEngineFactory::getInstance(). EnginePrototypeTable[RandomNumberEngineFactory::minstd_rand0]->create(); CPPUNIT_ASSERT_EQUAL( std::string(typeid(boost::minstd_rand0).name()), rng->name() ); delete rng; }