Changeset c9bc2b7 for src/RandomNumbers/unittests
- Timestamp:
- Feb 3, 2011, 9:51:19 AM (14 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- 1d5a871
- Parents:
- 3f9eba
- git-author:
- Frederik Heber <heber@…> (01/03/11 14:01:22)
- git-committer:
- Frederik Heber <heber@…> (02/03/11 09:51:19)
- Location:
- src/RandomNumbers/unittests
- Files:
-
- 6 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/RandomNumbers/unittests/Makefile.am
r3f9eba rc9bc2b7 8 8 9 9 TESTS = \ 10 RandomNumberGeneratorFactoryUnitTest 10 RandomNumberDistributionFactoryUnitTest \ 11 RandomNumberEngineFactoryUnitTest \ 12 RandomNumberGeneratorFactoryUnitTest \ 13 RandomNumberGeneratorUnitTest 11 14 12 15 … … 31 34 PARSERLIBS = ../../Parser/libMolecuilderParser.la 32 35 36 RandomNumberDistributionFactoryUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \ 37 RandomNumberDistributionFactoryUnitTest.cpp \ 38 RandomNumberDistributionFactoryUnitTest.hpp \ 39 $(srcdir)/../RandomNumberDistributionFactory.cpp \ 40 $(srcdir)/../RandomNumberDistributionFactory.hpp 41 RandomNumberDistributionFactoryUnitTest_LDADD = ${GSLLIBS} 42 43 RandomNumberEngineFactoryUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \ 44 RandomNumberEngineFactoryUnitTest.cpp \ 45 RandomNumberEngineFactoryUnitTest.hpp \ 46 $(srcdir)/../RandomNumberEngineFactory.cpp \ 47 $(srcdir)/../RandomNumberEngineFactory.hpp 48 RandomNumberEngineFactoryUnitTest_LDADD = ${GSLLIBS} 49 33 50 RandomNumberGeneratorFactoryUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \ 34 51 RandomNumberGeneratorFactoryUnitTest.cpp \ 35 52 RandomNumberGeneratorFactoryUnitTest.hpp \ 53 $(srcdir)/../RandomNumberDistributionFactory.cpp \ 54 $(srcdir)/../RandomNumberDistributionFactory.hpp \ 55 $(srcdir)/../RandomNumberEngineFactory.cpp \ 56 $(srcdir)/../RandomNumberEngineFactory.hpp \ 36 57 $(srcdir)/../RandomNumberGeneratorFactory.cpp \ 37 58 $(srcdir)/../RandomNumberGeneratorFactory.hpp 38 59 RandomNumberGeneratorFactoryUnitTest_LDADD = ${GSLLIBS} 39 60 61 RandomNumberGeneratorUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \ 62 RandomNumberGeneratorUnitTest.cpp \ 63 RandomNumberGeneratorUnitTest.hpp \ 64 $(srcdir)/../RandomNumberDistributionFactory.cpp \ 65 $(srcdir)/../RandomNumberDistributionFactory.hpp \ 66 $(srcdir)/../RandomNumberEngineFactory.cpp \ 67 $(srcdir)/../RandomNumberEngineFactory.hpp \ 68 $(srcdir)/../RandomNumberGeneratorFactory.cpp \ 69 $(srcdir)/../RandomNumberGeneratorFactory.hpp 70 RandomNumberGeneratorUnitTest_LDADD = ${GSLLIBS} 71 40 72 41 73 #AUTOMAKE_OPTIONS = parallel-tests -
src/RandomNumbers/unittests/RandomNumberGeneratorFactoryUnitTest.cpp
r3f9eba rc9bc2b7 9 9 * RandomNumberGeneratorFactoryUnitTest.cpp 10 10 * 11 * Created on: Dec 31, 201011 * Created on: Jan 03, 2011 12 12 * Author: heber 13 13 */ … … 26 26 #include "RandomNumberGeneratorFactoryUnitTest.hpp" 27 27 28 #include "RandomNumbers/RandomNumber Distribution_Encapsulation.hpp"29 #include "RandomNumbers/RandomNumberEngine _Encapsulation.hpp"30 #include "RandomNumbers/RandomNumber Generator_Encapsulation.hpp"28 #include "RandomNumbers/RandomNumberGenerator.hpp" 29 #include "RandomNumbers/RandomNumberEngineFactory.hpp" 30 #include "RandomNumbers/RandomNumberDistributionFactory.hpp" 31 31 #include "RandomNumbers/RandomNumberGeneratorFactory.hpp" 32 32 … … 80 80 void RandomNumberGeneratorFactoryTest::tearDown() 81 81 { 82 RandomNumberDistributionFactory::purgeInstance(); 83 RandomNumberEngineFactory::purgeInstance(); 82 84 RandomNumberGeneratorFactory::purgeInstance(); 83 }84 85 void RandomNumberGeneratorFactoryTest::EngineTest()86 {87 // check default value88 CPPUNIT_ASSERT_EQUAL(89 std::string("minstd_rand0"),90 RandomNumberGeneratorFactory::getInstance().getEngine());91 92 // check one of the engines in the table93 CPPUNIT_ASSERT_EQUAL(94 std::string(typeid(boost::minstd_rand0).name()),95 RandomNumberGeneratorFactory::getInstance().96 EnginePrototypeTable[RandomNumberGeneratorFactory::minstd_rand0]->name()97 );98 }99 100 void RandomNumberGeneratorFactoryTest::DistributionTest()101 {102 // check default value103 CPPUNIT_ASSERT_EQUAL(104 std::string("uniform_smallint"),105 RandomNumberGeneratorFactory::getInstance().getDistribution());106 107 // check one of the distributions in the table108 CPPUNIT_ASSERT_EQUAL(109 std::string(typeid(boost::uniform_smallint<> ).name()),110 RandomNumberGeneratorFactory::getInstance().111 DistributionPrototypeTable[RandomNumberGeneratorFactory::uniform_smallint]->name()112 );113 85 } 114 86 115 87 void RandomNumberGeneratorFactoryTest::GeneratorTest() 116 88 { 89 RandomNumberGenerator *rng = NULL; 117 90 // check one of the engines and distributions 91 rng = RandomNumberGeneratorFactory::getInstance(). 92 GeneratorPrototypeTable[RandomNumberEngineFactory::minstd_rand0] 93 [RandomNumberDistributionFactory::uniform_smallint]->create(); 118 94 CPPUNIT_ASSERT_EQUAL( 119 95 std::string(typeid(boost::minstd_rand0).name()), 120 RandomNumberGeneratorFactory::getInstance(). 121 GeneratorPrototypeTable[RandomNumberGeneratorFactory::minstd_rand0][RandomNumberGeneratorFactory::uniform_smallint] 122 ->EngineName() 96 rng->EngineName() 123 97 ); 124 98 CPPUNIT_ASSERT_EQUAL( 125 99 std::string(typeid(boost::uniform_smallint<> ).name()), 126 RandomNumberGeneratorFactory::getInstance(). 127 GeneratorPrototypeTable[RandomNumberGeneratorFactory::minstd_rand0][RandomNumberGeneratorFactory::uniform_smallint] 128 ->DistributionName() 100 rng->DistributionName() 129 101 ); 102 delete rng; 130 103 131 // obtain some random values for uniform_smallint132 RandomNumberGeneratorFactory::getInstance().setDistribution("uniform_smallint");133 RandomNumberGenerator &rng = RandomNumberGeneratorFactory::getInstance().makeRandomNumberGenerator();134 for (size_t i=0; i < 1000; ++i) {135 const int testint = rng();136 CPPUNIT_ASSERT_MESSAGE("randon number from uniform_smallint is out of [0:9]!", testint >= 0);137 CPPUNIT_ASSERT_MESSAGE("randon number from uniform_smallint is out of [0:9]!", testint <= 9);138 }139 104 } 140 105 -
src/RandomNumbers/unittests/RandomNumberGeneratorFactoryUnitTest.hpp
r3f9eba rc9bc2b7 2 2 * RandomNumberGeneratorFactoryUnitTest.hpp 3 3 * 4 * Created on: Dec 31, 20104 * Created on: Jan 03, 2011 5 5 * Author: heber 6 6 */ … … 20 20 { 21 21 CPPUNIT_TEST_SUITE( RandomNumberGeneratorFactoryTest ); 22 CPPUNIT_TEST ( EngineTest );23 CPPUNIT_TEST ( DistributionTest );24 22 CPPUNIT_TEST ( GeneratorTest ); 25 23 CPPUNIT_TEST_SUITE_END(); … … 29 27 void tearDown(); 30 28 31 void EngineTest();32 void DistributionTest();33 29 void GeneratorTest(); 34 30
Note:
See TracChangeset
for help on using the changeset viewer.