Changeset ee50c1 for src/Parser/unittests
- Timestamp:
- Oct 17, 2011, 4:56:36 PM (13 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:
- 1bef07
- Parents:
- 89a67f
- git-author:
- Frederik Heber <heber@…> (09/30/11 16:20:34)
- git-committer:
- Frederik Heber <heber@…> (10/17/11 16:56:36)
- Location:
- src/Parser/unittests
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/unittests/ParserMpqcUnitTest.cpp
r89a67f ree50c1 183 183 /************************************ tests ***********************************/ 184 184 185 void ParserMpqcUnitTest::ParameterTypeTest() {186 // check types in boost::any map187 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::hessianParam].type() == typeid(bool));188 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::hessianParam].type() != typeid(int));189 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::savestateParam].type() == typeid(bool));190 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::do_gradientParam].type() == typeid(bool));191 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::maxiterParam].type() == typeid(int));192 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::memoryParam].type() == typeid(int));193 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::stdapproxParam].type() == typeid(std::string));194 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::nfzcParam].type() == typeid(int));195 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::basisParam].type() == typeid(std::string));196 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::aux_basisParam].type() == typeid(std::string));197 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::integrationParam].type() == typeid(MpqcParser_Parameters::IntegralCints));198 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::theoryParam].type() == typeid(MpqcParser_Parameters::MBPT2));199 }200 201 185 void ParserMpqcUnitTest::ParameterDefaultTest() { 202 186 // check default values 203 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::hessianParam) == "no"); 204 CPPUNIT_ASSERT(!parser->getParams().getBool(MpqcParser_Parameters::hessianParam)); 205 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::savestateParam) == "no"); 206 CPPUNIT_ASSERT(!parser->getParams().getBool(MpqcParser_Parameters::savestateParam)); 207 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::do_gradientParam) == "yes"); 208 CPPUNIT_ASSERT(parser->getParams().getBool(MpqcParser_Parameters::do_gradientParam)); 209 CPPUNIT_ASSERT(parser->getParams().getInt(MpqcParser_Parameters::maxiterParam) == 1000); 210 CPPUNIT_ASSERT(parser->getParams().getInt(MpqcParser_Parameters::memoryParam) == 16000000); 211 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::stdapproxParam) == "A'"); 212 CPPUNIT_ASSERT(parser->getParams().getInt(MpqcParser_Parameters::nfzcParam) == 1); 213 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::basisParam) == "3-21G"); 214 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::aux_basisParam) == "aug-cc-pVDZ"); 215 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::integrationParam) == "IntegralCints"); 216 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::theoryParam) == "MBPT2"); 217 CPPUNIT_ASSERT(parser->getParams().getTheory() == MpqcParser_Parameters::MBPT2); 218 CPPUNIT_ASSERT(parser->getParams().getIntegration() == MpqcParser_Parameters::IntegralCints); 219 220 // check that values are not removed 221 CPPUNIT_ASSERT(!parser->getParams().params[MpqcParser_Parameters::theoryParam].empty()); 222 223 // check throw, for the moment aren't, are caught in getInt() 224 CPPUNIT_ASSERT_THROW(parser->getParams().getInt(MpqcParser_Parameters::integrationParam), boost::bad_any_cast); 225 CPPUNIT_ASSERT_THROW(parser->getParams().getInt(MpqcParser_Parameters::theoryParam), boost::bad_any_cast); 226 187 CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::hessianParam) == std::string("no")); 188 CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::savestateParam) == std::string("no")); 189 CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::do_gradientParam) == std::string("yes")); 190 CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::maxiterParam) == std::string("1000")); 191 CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::memoryParam) == std::string("16000000")); 192 CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::stdapproxParam) == std::string("A'")); 193 CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::nfzcParam) == std::string("1")); 194 CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::basisParam) == std::string("3-21G")); 195 CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::aux_basisParam) == std::string("aug-cc-pVDZ")); 196 CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::integrationParam) == std::string("IntegralCints")); 197 CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::theoryParam) == std::string("MBPT2")); 227 198 } 228 199 229 200 void ParserMpqcUnitTest::ParameterCloneTest() { 230 201 FormatParser_Parameters *clone = parser->getParams().clone(); 231 CPPUNIT_ASSERT(parser->getParams().get String(MpqcParser_Parameters::theoryParam) == "MBPT2");202 CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::theoryParam) == std::string("MBPT2")); 232 203 std::stringstream setvalue("theory = CLHF"); 233 204 setvalue >> parser->getParams(); 234 CPPUNIT_ASSERT(parser->getParams().get String(MpqcParser_Parameters::theoryParam) == "CLHF");205 CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::theoryParam) == std::string("CLHF")); 235 206 parser->getParams().makeClone(*clone); 236 CPPUNIT_ASSERT(parser->getParams().get String(MpqcParser_Parameters::theoryParam) == "MBPT2");207 CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::theoryParam) == std::string("MBPT2")); 237 208 } 238 209 … … 244 215 // std::cout << "integration method is " 245 216 // << parser->getParams().getString(MpqcParser_Parameters::theoryParam) << std::endl; 246 CPPUNIT_ASSERT(parser->getParams().get String(MpqcParser_Parameters::theoryParam) == "CLHF");217 CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::theoryParam) == std::string("CLHF")); 247 218 } 248 219 // test a bool … … 252 223 // std::cout << "Hessian is " 253 224 // << parser->getParams().getString(MpqcParser_Parameters::hessianParam) << std::endl; 254 CPPUNIT_ASSERT(parser->getParams().get String(MpqcParser_Parameters::hessianParam) == "yes");225 CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::hessianParam) == std::string("yes")); 255 226 } 256 227 // test int … … 260 231 // std::cout << "maxiter is " 261 232 // << parser->getParams().getString(MpqcParser_Parameters::maxiterParam) << std::endl; 262 CPPUNIT_ASSERT(parser->getParams().get Int(MpqcParser_Parameters::maxiterParam) == 500);233 CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::maxiterParam) == std::string("500")); 263 234 } 264 235 // test whether unknown key fails … … 274 245 // std::cout << "Hessian is still " 275 246 // << parser->getParams().getString(MpqcParser_Parameters::hessianParam) << std::endl; 276 CPPUNIT_ASSERT(parser->getParams().get String(MpqcParser_Parameters::hessianParam) == "yes");247 CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::hessianParam) == std::string("yes")); 277 248 } 278 249 } … … 280 251 void ParserMpqcUnitTest::readMpqcTest() { 281 252 stringstream input(waterMpqc_CLHF); 282 parser->getParams().setTheory(MpqcParser_Parameters::CLHF); 253 parser->getParams().setParameter( 254 MpqcParser_Parameters::theoryParam, 255 parser->getParams().getTheoryName(MpqcParser_Parameters::CLHF) 256 ); 283 257 parser->load(&input); 284 258 … … 308 282 // compare both configs for CLHF 309 283 stringstream output; 310 parser->getParams().setTheory(MpqcParser_Parameters::CLHF); 284 parser->getParams().setParameter( 285 MpqcParser_Parameters::theoryParam, 286 parser->getParams().getTheoryName(MpqcParser_Parameters::CLHF) 287 ); 311 288 parser->save(&output, atoms); 312 289 stringstream input(waterMpqc_CLHF); … … 319 296 // compare both configs for CLKS 320 297 stringstream output; 321 parser->getParams().setTheory(MpqcParser_Parameters::CLKS); 322 parser->save(&output, atoms); 298 parser->getParams().setParameter( 299 MpqcParser_Parameters::theoryParam, 300 parser->getParams().getTheoryName(MpqcParser_Parameters::CLKS) 301 ); 323 302 stringstream input(waterMpqc_CLKS); 324 303 for (; std::getline(input, first) && std::getline(output, second); ) { … … 330 309 // compare both configs for MBPT2 331 310 stringstream output; 332 parser->getParams().setTheory(MpqcParser_Parameters::MBPT2); 333 parser->save(&output, atoms); 311 parser->getParams().setParameter( 312 MpqcParser_Parameters::theoryParam, 313 parser->getParams().getTheoryName(MpqcParser_Parameters::MBPT2) 314 ); 334 315 stringstream input(waterMpqc_MBPT2); 335 316 for (; std::getline(input, first) && std::getline(output, second); ) { … … 341 322 // compare both configs for MBPT2_R12 342 323 stringstream output; 343 parser->getParams().setTheory(MpqcParser_Parameters::MBPT2_R12); 344 parser->save(&output, atoms); 324 parser->getParams().setParameter( 325 MpqcParser_Parameters::theoryParam, 326 parser->getParams().getTheoryName(MpqcParser_Parameters::MBPT2_R12) 327 ); 345 328 stringstream input(waterMpqc_MBPT2_R12); 346 329 for (; std::getline(input, first) && std::getline(output, second); ) { -
src/Parser/unittests/ParserMpqcUnitTest.hpp
r89a67f ree50c1 21 21 { 22 22 CPPUNIT_TEST_SUITE( ParserMpqcUnitTest ) ; 23 CPPUNIT_TEST ( ParameterTypeTest );24 23 CPPUNIT_TEST ( ParameterDefaultTest ); 25 24 CPPUNIT_TEST ( ParameterSetterTest ); … … 33 32 void tearDown(); 34 33 35 void ParameterTypeTest();36 34 void ParameterDefaultTest(); 37 35 void ParameterSetterTest();
Note:
See TracChangeset
for help on using the changeset viewer.