/* * 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. */ /* * RandomNumberGeneratorFactoryUnitTest.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 "RandomNumberGeneratorFactoryUnitTest.hpp" #include "RandomNumbers/RandomNumberGenerator.hpp" #include "RandomNumbers/RandomNumberEngineFactory.hpp" #include "RandomNumbers/RandomNumberDistributionFactory.hpp" #include "RandomNumbers/RandomNumberGeneratorFactory.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( RandomNumberGeneratorFactoryTest ); void RandomNumberGeneratorFactoryTest::setUp() { RandomNumberGeneratorFactory::getInstance(); } void RandomNumberGeneratorFactoryTest::tearDown() { RandomNumberDistributionFactory::purgeInstance(); RandomNumberEngineFactory::purgeInstance(); RandomNumberGeneratorFactory::purgeInstance(); } void RandomNumberGeneratorFactoryTest::GeneratorTest() { // check one of the engines and distributions RandomNumberGenerator& rng = *(RandomNumberGeneratorFactory::getInstance(). GeneratorPrototypeTable[RandomNumberEngineFactory::minstd_rand0] [RandomNumberDistributionFactory::uniform_smallint]); CPPUNIT_ASSERT_EQUAL( std::string(typeid(boost::minstd_rand0).name()), rng.EngineName() ); CPPUNIT_ASSERT_EQUAL( std::string(typeid(boost::uniform_smallint<> ).name()), rng.DistributionName() ); // set types in lower factories RandomNumberEngineFactory::getInstance().setCurrentType(RandomNumberEngineFactory::minstd_rand0); RandomNumberDistributionFactory::getInstance().setCurrentType(RandomNumberDistributionFactory::uniform_int); // ... and check whether generator delivers those set types RandomNumberGenerator &rng_A = RandomNumberGeneratorFactory::getInstance(). makeRandomNumberGenerator(); CPPUNIT_ASSERT_EQUAL( std::string(typeid(boost::minstd_rand0).name()), rng_A.EngineName() ); CPPUNIT_ASSERT_EQUAL( std::string(typeid(boost::uniform_int<> ).name()), rng_A.DistributionName() ); }