Changeset c1db05 for src/Parser/unittests/ParserMpqcUnitTest.cpp
- Timestamp:
- Oct 10, 2011, 2:27:06 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:
- 4151b0
- Parents:
- e611dc
- git-author:
- Frederik Heber <heber@…> (09/06/11 08:45:22)
- git-committer:
- Frederik Heber <heber@…> (10/10/11 14:27:06)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/unittests/ParserMpqcUnitTest.cpp
re611dc rc1db05 178 178 void ParserMpqcUnitTest::ParameterTypeTest() { 179 179 // check types in boost::any map 180 CPPUNIT_ASSERT(mpqc-> params.params[MpqcParser_Parameters::hessianParam].type() == typeid(bool));181 CPPUNIT_ASSERT(mpqc-> params.params[MpqcParser_Parameters::hessianParam].type() != typeid(int));182 CPPUNIT_ASSERT(mpqc-> params.params[MpqcParser_Parameters::savestateParam].type() == typeid(bool));183 CPPUNIT_ASSERT(mpqc-> params.params[MpqcParser_Parameters::do_gradientParam].type() == typeid(bool));184 CPPUNIT_ASSERT(mpqc-> params.params[MpqcParser_Parameters::maxiterParam].type() == typeid(int));185 CPPUNIT_ASSERT(mpqc-> params.params[MpqcParser_Parameters::memoryParam].type() == typeid(int));186 CPPUNIT_ASSERT(mpqc-> params.params[MpqcParser_Parameters::stdapproxParam].type() == typeid(std::string));187 CPPUNIT_ASSERT(mpqc-> params.params[MpqcParser_Parameters::nfzcParam].type() == typeid(int));188 CPPUNIT_ASSERT(mpqc-> params.params[MpqcParser_Parameters::basisParam].type() == typeid(std::string));189 CPPUNIT_ASSERT(mpqc-> params.params[MpqcParser_Parameters::aux_basisParam].type() == typeid(std::string));190 CPPUNIT_ASSERT(mpqc-> params.params[MpqcParser_Parameters::integrationParam].type() == typeid(MpqcParser_Parameters::IntegralCints));191 CPPUNIT_ASSERT(mpqc-> params.params[MpqcParser_Parameters::theoryParam].type() == typeid(MpqcParser_Parameters::MBPT2));180 CPPUNIT_ASSERT(mpqc->getParams().params[MpqcParser_Parameters::hessianParam].type() == typeid(bool)); 181 CPPUNIT_ASSERT(mpqc->getParams().params[MpqcParser_Parameters::hessianParam].type() != typeid(int)); 182 CPPUNIT_ASSERT(mpqc->getParams().params[MpqcParser_Parameters::savestateParam].type() == typeid(bool)); 183 CPPUNIT_ASSERT(mpqc->getParams().params[MpqcParser_Parameters::do_gradientParam].type() == typeid(bool)); 184 CPPUNIT_ASSERT(mpqc->getParams().params[MpqcParser_Parameters::maxiterParam].type() == typeid(int)); 185 CPPUNIT_ASSERT(mpqc->getParams().params[MpqcParser_Parameters::memoryParam].type() == typeid(int)); 186 CPPUNIT_ASSERT(mpqc->getParams().params[MpqcParser_Parameters::stdapproxParam].type() == typeid(std::string)); 187 CPPUNIT_ASSERT(mpqc->getParams().params[MpqcParser_Parameters::nfzcParam].type() == typeid(int)); 188 CPPUNIT_ASSERT(mpqc->getParams().params[MpqcParser_Parameters::basisParam].type() == typeid(std::string)); 189 CPPUNIT_ASSERT(mpqc->getParams().params[MpqcParser_Parameters::aux_basisParam].type() == typeid(std::string)); 190 CPPUNIT_ASSERT(mpqc->getParams().params[MpqcParser_Parameters::integrationParam].type() == typeid(MpqcParser_Parameters::IntegralCints)); 191 CPPUNIT_ASSERT(mpqc->getParams().params[MpqcParser_Parameters::theoryParam].type() == typeid(MpqcParser_Parameters::MBPT2)); 192 192 } 193 193 194 194 void ParserMpqcUnitTest::ParameterDefaultTest() { 195 195 // check default values 196 CPPUNIT_ASSERT(mpqc-> params.getString(MpqcParser_Parameters::hessianParam) == "no");197 CPPUNIT_ASSERT(!mpqc-> params.getBool(MpqcParser_Parameters::hessianParam));198 CPPUNIT_ASSERT(mpqc-> params.getString(MpqcParser_Parameters::savestateParam) == "no");199 CPPUNIT_ASSERT(!mpqc-> params.getBool(MpqcParser_Parameters::savestateParam));200 CPPUNIT_ASSERT(mpqc-> params.getString(MpqcParser_Parameters::do_gradientParam) == "yes");201 CPPUNIT_ASSERT(mpqc-> params.getBool(MpqcParser_Parameters::do_gradientParam));202 CPPUNIT_ASSERT(mpqc-> params.getInt(MpqcParser_Parameters::maxiterParam) == 1000);203 CPPUNIT_ASSERT(mpqc-> params.getInt(MpqcParser_Parameters::memoryParam) == 16000000);204 CPPUNIT_ASSERT(mpqc-> params.getString(MpqcParser_Parameters::stdapproxParam) == "A'");205 CPPUNIT_ASSERT(mpqc-> params.getInt(MpqcParser_Parameters::nfzcParam) == 1);206 CPPUNIT_ASSERT(mpqc-> params.getString(MpqcParser_Parameters::basisParam) == "3-21G");207 CPPUNIT_ASSERT(mpqc-> params.getString(MpqcParser_Parameters::aux_basisParam) == "aug-cc-pVDZ");208 CPPUNIT_ASSERT(mpqc-> params.getString(MpqcParser_Parameters::integrationParam) == "IntegralCints");209 CPPUNIT_ASSERT(mpqc-> params.getString(MpqcParser_Parameters::theoryParam) == "MBPT2");210 CPPUNIT_ASSERT(mpqc-> params.getTheory() == MpqcParser_Parameters::MBPT2);211 CPPUNIT_ASSERT(mpqc-> params.getIntegration() == MpqcParser_Parameters::IntegralCints);196 CPPUNIT_ASSERT(mpqc->getParams().getString(MpqcParser_Parameters::hessianParam) == "no"); 197 CPPUNIT_ASSERT(!mpqc->getParams().getBool(MpqcParser_Parameters::hessianParam)); 198 CPPUNIT_ASSERT(mpqc->getParams().getString(MpqcParser_Parameters::savestateParam) == "no"); 199 CPPUNIT_ASSERT(!mpqc->getParams().getBool(MpqcParser_Parameters::savestateParam)); 200 CPPUNIT_ASSERT(mpqc->getParams().getString(MpqcParser_Parameters::do_gradientParam) == "yes"); 201 CPPUNIT_ASSERT(mpqc->getParams().getBool(MpqcParser_Parameters::do_gradientParam)); 202 CPPUNIT_ASSERT(mpqc->getParams().getInt(MpqcParser_Parameters::maxiterParam) == 1000); 203 CPPUNIT_ASSERT(mpqc->getParams().getInt(MpqcParser_Parameters::memoryParam) == 16000000); 204 CPPUNIT_ASSERT(mpqc->getParams().getString(MpqcParser_Parameters::stdapproxParam) == "A'"); 205 CPPUNIT_ASSERT(mpqc->getParams().getInt(MpqcParser_Parameters::nfzcParam) == 1); 206 CPPUNIT_ASSERT(mpqc->getParams().getString(MpqcParser_Parameters::basisParam) == "3-21G"); 207 CPPUNIT_ASSERT(mpqc->getParams().getString(MpqcParser_Parameters::aux_basisParam) == "aug-cc-pVDZ"); 208 CPPUNIT_ASSERT(mpqc->getParams().getString(MpqcParser_Parameters::integrationParam) == "IntegralCints"); 209 CPPUNIT_ASSERT(mpqc->getParams().getString(MpqcParser_Parameters::theoryParam) == "MBPT2"); 210 CPPUNIT_ASSERT(mpqc->getParams().getTheory() == MpqcParser_Parameters::MBPT2); 211 CPPUNIT_ASSERT(mpqc->getParams().getIntegration() == MpqcParser_Parameters::IntegralCints); 212 212 213 213 // check that values are not removed 214 CPPUNIT_ASSERT(!mpqc-> params.params[MpqcParser_Parameters::theoryParam].empty());214 CPPUNIT_ASSERT(!mpqc->getParams().params[MpqcParser_Parameters::theoryParam].empty()); 215 215 216 216 // check throw, for the moment aren't, are caught in getInt() 217 CPPUNIT_ASSERT_THROW(mpqc->params.getInt(MpqcParser_Parameters::integrationParam), boost::bad_any_cast); 218 CPPUNIT_ASSERT_THROW(mpqc->params.getInt(MpqcParser_Parameters::theoryParam), boost::bad_any_cast); 219 217 CPPUNIT_ASSERT_THROW(mpqc->getParams().getInt(MpqcParser_Parameters::integrationParam), boost::bad_any_cast); 218 CPPUNIT_ASSERT_THROW(mpqc->getParams().getInt(MpqcParser_Parameters::theoryParam), boost::bad_any_cast); 219 220 } 221 222 void ParserMpqcUnitTest::ParameterCloneTest() { 223 FormatParser_Parameters *clone = mpqc->getParams().clone(); 224 CPPUNIT_ASSERT(mpqc->getParams().getString(MpqcParser_Parameters::theoryParam) == "MBPT2"); 225 std::stringstream setvalue("theory = CLHF"); 226 setvalue >> mpqc->getParams(); 227 CPPUNIT_ASSERT(mpqc->getParams().getString(MpqcParser_Parameters::theoryParam) == "CLHF"); 228 mpqc->getParams().makeClone(*clone); 229 CPPUNIT_ASSERT(mpqc->getParams().getString(MpqcParser_Parameters::theoryParam) == "MBPT2"); 220 230 } 221 231 … … 224 234 { 225 235 std::stringstream setvalue("theory = CLHF"); 226 setvalue >> mpqc-> params;236 setvalue >> mpqc->getParams(); 227 237 // std::cout << "integration method is " 228 // << mpqc-> params.getString(MpqcParser_Parameters::theoryParam) << std::endl;229 CPPUNIT_ASSERT(mpqc-> params.getString(MpqcParser_Parameters::theoryParam) == "CLHF");238 // << mpqc->getParams().getString(MpqcParser_Parameters::theoryParam) << std::endl; 239 CPPUNIT_ASSERT(mpqc->getParams().getString(MpqcParser_Parameters::theoryParam) == "CLHF"); 230 240 } 231 241 // test a bool 232 242 { 233 243 std::stringstream setvalue("Hessian = yes"); 234 setvalue >> mpqc-> params;244 setvalue >> mpqc->getParams(); 235 245 // std::cout << "Hessian is " 236 // << mpqc-> params.getString(MpqcParser_Parameters::hessianParam) << std::endl;237 CPPUNIT_ASSERT(mpqc-> params.getString(MpqcParser_Parameters::hessianParam) == "yes");246 // << mpqc->getParams().getString(MpqcParser_Parameters::hessianParam) << std::endl; 247 CPPUNIT_ASSERT(mpqc->getParams().getString(MpqcParser_Parameters::hessianParam) == "yes"); 238 248 } 239 249 // test int 240 250 { 241 251 std::stringstream setvalue("maxiter = 500"); 242 setvalue >> mpqc-> params;252 setvalue >> mpqc->getParams(); 243 253 // std::cout << "maxiter is " 244 // << mpqc-> params.getString(MpqcParser_Parameters::maxiterParam) << std::endl;245 CPPUNIT_ASSERT(mpqc-> params.getInt(MpqcParser_Parameters::maxiterParam) == 500);254 // << mpqc->getParams().getString(MpqcParser_Parameters::maxiterParam) << std::endl; 255 CPPUNIT_ASSERT(mpqc->getParams().getInt(MpqcParser_Parameters::maxiterParam) == 500); 246 256 } 247 257 // test whether unknown key fails … … 251 261 #ifndef NDEBUG 252 262 ASSERT_DO(Assert::Throw); 253 CPPUNIT_ASSERT_THROW(setvalue >> mpqc-> params, Assert::AssertionFailure);263 CPPUNIT_ASSERT_THROW(setvalue >> mpqc->getParams(), Assert::AssertionFailure); 254 264 #else 255 setvalue >> mpqc-> params;265 setvalue >> mpqc->getParams(); 256 266 #endif 257 267 // std::cout << "Hessian is still " 258 // << mpqc-> params.getString(MpqcParser_Parameters::hessianParam) << std::endl;259 CPPUNIT_ASSERT(mpqc-> params.getString(MpqcParser_Parameters::hessianParam) == "yes");268 // << mpqc->getParams().getString(MpqcParser_Parameters::hessianParam) << std::endl; 269 CPPUNIT_ASSERT(mpqc->getParams().getString(MpqcParser_Parameters::hessianParam) == "yes"); 260 270 } 261 271 } … … 263 273 void ParserMpqcUnitTest::readMpqcTest() { 264 274 stringstream input(waterMpqc_CLHF); 265 mpqc-> params.setTheory(MpqcParser_Parameters::CLHF);275 mpqc->getParams().setTheory(MpqcParser_Parameters::CLHF); 266 276 mpqc->load(&input); 267 277 … … 291 301 // compare both configs for CLHF 292 302 stringstream output; 293 mpqc-> params.setTheory(MpqcParser_Parameters::CLHF);303 mpqc->getParams().setTheory(MpqcParser_Parameters::CLHF); 294 304 mpqc->save(&output, atoms); 295 305 stringstream input(waterMpqc_CLHF); … … 302 312 // compare both configs for CLKS 303 313 stringstream output; 304 mpqc-> params.setTheory(MpqcParser_Parameters::CLKS);314 mpqc->getParams().setTheory(MpqcParser_Parameters::CLKS); 305 315 mpqc->save(&output, atoms); 306 316 stringstream input(waterMpqc_CLKS); … … 313 323 // compare both configs for MBPT2 314 324 stringstream output; 315 mpqc-> params.setTheory(MpqcParser_Parameters::MBPT2);325 mpqc->getParams().setTheory(MpqcParser_Parameters::MBPT2); 316 326 mpqc->save(&output, atoms); 317 327 stringstream input(waterMpqc_MBPT2); … … 324 334 // compare both configs for MBPT2_R12 325 335 stringstream output; 326 mpqc-> params.setTheory(MpqcParser_Parameters::MBPT2_R12);336 mpqc->getParams().setTheory(MpqcParser_Parameters::MBPT2_R12); 327 337 mpqc->save(&output, atoms); 328 338 stringstream input(waterMpqc_MBPT2_R12);
Note:
See TracChangeset
for help on using the changeset viewer.