Changeset 61d69a4 for src/Parser/unittests
- Timestamp:
- Feb 7, 2011, 10:43:35 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:
- 44fce5
- Parents:
- 9cff8b
- git-author:
- Frederik Heber <heber@…> (02/03/11 11:56:26)
- git-committer:
- Frederik Heber <heber@…> (02/07/11 10:43:35)
- Location:
- src/Parser/unittests
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/unittests/ParserMpqcUnitTest.cpp
r9cff8b r61d69a4 24 24 #include <cppunit/ui/text/TestRunner.h> 25 25 26 #include "Parser/MpqcParser.hpp" 26 #include <boost/any.hpp> 27 27 28 #include "World.hpp" 28 29 #include "atom.hpp" … … 47 48 \t\tmolecule = $:molecule\n\ 48 49 \t\tbasis = $:basis\n\ 50 \t\tmaxiter = 1000\n\ 49 51 \t\tmemory = 16000000\n\ 50 52 \t)\n\ … … 70 72 \t\tmolecule = $:molecule\n\ 71 73 \t\tbasis = $:basis\n\ 74 \t\tmaxiter = 1000\n\ 72 75 \t\tmemory = 16000000\n\ 73 76 \t)\n\ … … 92 95 \t\tbasis = $:basis\n\ 93 96 \t\tmolecule = $:molecule\n\ 97 \t\tmemory = 16000000\n\ 94 98 \t\treference<CLHF>: (\n\ 95 99 \t\t\tmaxiter = 1000\n\ 96 100 \t\t\tbasis = $:basis\n\ 97 101 \t\t\tmolecule = $:molecule\n\ 102 \t\t\tmemory = 16000000\n\ 98 103 \t\t)\n\ 99 104 \t)\n\ … … 151 156 152 157 void ParserMpqcUnitTest::setUp() { 158 mpqc = new MpqcParser(); 159 153 160 World::getInstance(); 154 161 … … 161 168 162 169 void ParserMpqcUnitTest::tearDown() { 170 delete mpqc; 163 171 ChangeTracker::purgeInstance(); 164 172 World::purgeInstance(); … … 167 175 /************************************ tests ***********************************/ 168 176 177 void ParserMpqcUnitTest::ParameterTypeTest() { 178 // check types in boost::any map 179 CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::HessianParam].type() == typeid(bool)); 180 CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::HessianParam].type() != typeid(int)); 181 CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::savestateParam].type() == typeid(bool)); 182 CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::do_gradientParam].type() == typeid(bool)); 183 CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::maxiterParam].type() == typeid(int)); 184 CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::memoryParam].type() == typeid(int)); 185 CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::stdapproxParam].type() == typeid(std::string)); 186 CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::nfzcParam].type() == typeid(int)); 187 CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::basisParam].type() == typeid(std::string)); 188 CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::aux_basisParam].type() == typeid(std::string)); 189 CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::integrationParam].type() == typeid(MpqcParser_Parameters::IntegralCints)); 190 CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::theoryParam].type() == typeid(MpqcParser_Parameters::MBPT2)); 191 } 192 193 void ParserMpqcUnitTest::ParameterDefaultTest() { 194 // check default values 195 CPPUNIT_ASSERT(mpqc->params.getString(MpqcParser_Parameters::HessianParam) == "no"); 196 CPPUNIT_ASSERT(!mpqc->params.getBool(MpqcParser_Parameters::HessianParam)); 197 CPPUNIT_ASSERT(mpqc->params.getString(MpqcParser_Parameters::savestateParam) == "no"); 198 CPPUNIT_ASSERT(!mpqc->params.getBool(MpqcParser_Parameters::savestateParam)); 199 CPPUNIT_ASSERT(mpqc->params.getString(MpqcParser_Parameters::do_gradientParam) == "yes"); 200 CPPUNIT_ASSERT(mpqc->params.getBool(MpqcParser_Parameters::do_gradientParam)); 201 CPPUNIT_ASSERT(mpqc->params.getInt(MpqcParser_Parameters::maxiterParam) == 1000); 202 CPPUNIT_ASSERT(mpqc->params.getInt(MpqcParser_Parameters::memoryParam) == 16000000); 203 CPPUNIT_ASSERT(mpqc->params.getString(MpqcParser_Parameters::stdapproxParam) == "A'"); 204 CPPUNIT_ASSERT(mpqc->params.getInt(MpqcParser_Parameters::nfzcParam) == 1); 205 CPPUNIT_ASSERT(mpqc->params.getString(MpqcParser_Parameters::basisParam) == "3-21G"); 206 CPPUNIT_ASSERT(mpqc->params.getString(MpqcParser_Parameters::aux_basisParam) == "aug-cc-pVDZ"); 207 CPPUNIT_ASSERT(mpqc->params.getString(MpqcParser_Parameters::integrationParam) == "IntegralCints"); 208 CPPUNIT_ASSERT(mpqc->params.getString(MpqcParser_Parameters::theoryParam) == "MBPT2"); 209 CPPUNIT_ASSERT(mpqc->params.getTheory() == MpqcParser_Parameters::MBPT2); 210 CPPUNIT_ASSERT(mpqc->params.getIntegration() == MpqcParser_Parameters::IntegralCints); 211 212 // check that values are not removed 213 CPPUNIT_ASSERT(!mpqc->params.params[MpqcParser_Parameters::theoryParam].empty()); 214 215 // check throw, for the moment aren't, are caught in getInt() 216 //CPPUNIT_ASSERT_THROW(mpqc->params.getInt(MpqcParser_Parameters::integrationParam), boost::bad_any_cast); 217 //CPPUNIT_ASSERT_THROW(mpqc->params.getInt(MpqcParser_Parameters::theoryParam), boost::bad_any_cast); 218 219 } 220 169 221 void ParserMpqcUnitTest::readMpqcTest() { 170 222 stringstream input(waterMpqc_CLHF); 171 MpqcParser* testParser = new MpqcParser(); 172 testParser->setTheory(MpqcParser::CLHF); 173 testParser->load(&input); 223 mpqc->params.setTheory(MpqcParser_Parameters::CLHF); 224 mpqc->load(&input); 174 225 175 226 CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms()); … … 194 245 // create two stringstreams, one stored, one created 195 246 196 MpqcParser* testParser = new MpqcParser();197 247 std::vector<atom *> atoms = World::getInstance().getAllAtoms(); 198 248 { 199 249 // compare both configs for CLHF 200 250 stringstream output; 201 testParser->setTheory(MpqcParser::CLHF);202 testParser->save(&output, atoms);251 mpqc->params.setTheory(MpqcParser_Parameters::CLHF); 252 mpqc->save(&output, atoms); 203 253 stringstream input(waterMpqc_CLHF); 204 254 for (; std::getline(input, first) && std::getline(output, second); ) { … … 210 260 // compare both configs for CLKS 211 261 stringstream output; 212 testParser->setTheory(MpqcParser::CLKS);213 testParser->save(&output, atoms);262 mpqc->params.setTheory(MpqcParser_Parameters::CLKS); 263 mpqc->save(&output, atoms); 214 264 stringstream input(waterMpqc_CLKS); 215 265 for (; std::getline(input, first) && std::getline(output, second); ) { … … 221 271 // compare both configs for MBPT2 222 272 stringstream output; 223 testParser->setTheory(MpqcParser::MBPT2);224 testParser->save(&output, atoms);273 mpqc->params.setTheory(MpqcParser_Parameters::MBPT2); 274 mpqc->save(&output, atoms); 225 275 stringstream input(waterMpqc_MBPT2); 226 276 for (; std::getline(input, first) && std::getline(output, second); ) { … … 232 282 // compare both configs for MBPT2_R12 233 283 stringstream output; 234 testParser->setTheory(MpqcParser::MBPT2_R12);235 testParser->save(&output, atoms);284 mpqc->params.setTheory(MpqcParser_Parameters::MBPT2_R12); 285 mpqc->save(&output, atoms); 236 286 stringstream input(waterMpqc_MBPT2_R12); 237 287 for (; std::getline(input, first) && std::getline(output, second); ) { -
src/Parser/unittests/ParserMpqcUnitTest.hpp
r9cff8b r61d69a4 13 13 #endif 14 14 15 #include "Parser/MpqcParser.hpp" 15 16 16 17 #include <cppunit/extensions/HelperMacros.h> … … 20 21 { 21 22 CPPUNIT_TEST_SUITE( ParserMpqcUnitTest ) ; 23 CPPUNIT_TEST ( ParameterTypeTest ); 24 CPPUNIT_TEST ( ParameterDefaultTest ); 25 CPPUNIT_TEST ( readMpqcTest ); 22 26 CPPUNIT_TEST ( writeMpqcTest ); 23 CPPUNIT_TEST ( readMpqcTest );24 27 CPPUNIT_TEST_SUITE_END(); 25 28 … … 28 31 void tearDown(); 29 32 33 void ParameterTypeTest(); 34 void ParameterDefaultTest(); 30 35 void readMpqcTest(); 31 36 void writeMpqcTest(); 37 38 private: 39 MpqcParser *mpqc; 32 40 }; 33 41
Note:
See TracChangeset
for help on using the changeset viewer.