/* * Project: MoleCuilder * Description: creates and alters molecular systems * Copyright (C) 2010-2012 University of Bonn. All rights reserved. * * * This file is part of MoleCuilder. * * MoleCuilder is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * MoleCuilder is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with MoleCuilder. If not, see . */ /* * 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() ); }