/* * 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. */ /* * RandomNumberDistributionFactoryUnitTest.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 "RandomNumberDistributionFactoryUnitTest.hpp" #include "RandomNumbers/RandomNumberDistribution.hpp" #include "RandomNumbers/RandomNumberDistribution_Encapsulation.hpp" #include "RandomNumbers/RandomNumberDistributionFactory.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( RandomNumberDistributionFactoryTest ); void RandomNumberDistributionFactoryTest::setUp() { rndA = NULL; rndA_1 = NULL; rndA_2 = NULL; RandomNumberDistributionFactory::getInstance(); } void RandomNumberDistributionFactoryTest::tearDown() { delete rndA; delete rndA_1; delete rndA_2; RandomNumberDistributionFactory::purgeInstance(); } void RandomNumberDistributionFactoryTest::DistributionTest() { // check the injectiveness of enum and string map for (RandomNumberDistributionFactory::NameMap::const_iterator iter = RandomNumberDistributionFactory::getInstance().names.begin(); iter != RandomNumberDistributionFactory::getInstance().names.end(); ++iter) { CPPUNIT_ASSERT_EQUAL( iter->second, RandomNumberDistributionFactory::getInstance().getName( RandomNumberDistributionFactory::getInstance().getEnum( iter->second ) ) ); } // check one of the distributions in the table rndA = RandomNumberDistributionFactory::getInstance(). PrototypeTable[RandomNumberDistributionFactory::uniform_smallint]->clone(); CPPUNIT_ASSERT_EQUAL( std::string(typeid(boost::uniform_smallint<> ).name()), rndA->name() ); // check min and max of uniform_smallint CPPUNIT_ASSERT_EQUAL( 0., rndA->min() ); CPPUNIT_ASSERT_EQUAL( 9., rndA->max() ); }