Changeset 765f16 for src/Parser/unittests/ParserMpqcUnitTest.cpp
- Timestamp:
- Oct 14, 2011, 3:15:30 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:
- d3d6c6
- Parents:
- 9a6b76e
- git-author:
- Frederik Heber <heber@…> (09/27/11 19:04:36)
- git-committer:
- Frederik Heber <heber@…> (10/14/11 15:15:30)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/unittests/ParserMpqcUnitTest.cpp
r9a6b76e r765f16 32 32 #include "Descriptors/AtomTypeDescriptor.hpp" 33 33 #include "CodePatterns/Assert.hpp" 34 #include "Parser/ChangeTracker.hpp" 35 #include "Parser/MpqcParser.hpp" 34 36 35 37 #ifdef HAVE_TESTRUNNER … … 157 159 158 160 void ParserMpqcUnitTest::setUp() { 159 mpqc = new MpqcParser();161 parser = new FormatParser<mpqc>(); 160 162 161 163 World::getInstance(); … … 169 171 170 172 void ParserMpqcUnitTest::tearDown() { 171 delete mpqc;173 delete parser; 172 174 ChangeTracker::purgeInstance(); 173 175 World::purgeInstance(); … … 178 180 void ParserMpqcUnitTest::ParameterTypeTest() { 179 181 // check types in boost::any map 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));182 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::hessianParam].type() == typeid(bool)); 183 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::hessianParam].type() != typeid(int)); 184 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::savestateParam].type() == typeid(bool)); 185 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::do_gradientParam].type() == typeid(bool)); 186 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::maxiterParam].type() == typeid(int)); 187 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::memoryParam].type() == typeid(int)); 188 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::stdapproxParam].type() == typeid(std::string)); 189 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::nfzcParam].type() == typeid(int)); 190 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::basisParam].type() == typeid(std::string)); 191 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::aux_basisParam].type() == typeid(std::string)); 192 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::integrationParam].type() == typeid(MpqcParser_Parameters::IntegralCints)); 193 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::theoryParam].type() == typeid(MpqcParser_Parameters::MBPT2)); 192 194 } 193 195 194 196 void ParserMpqcUnitTest::ParameterDefaultTest() { 195 197 // check default values 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);198 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::hessianParam) == "no"); 199 CPPUNIT_ASSERT(!parser->getParams().getBool(MpqcParser_Parameters::hessianParam)); 200 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::savestateParam) == "no"); 201 CPPUNIT_ASSERT(!parser->getParams().getBool(MpqcParser_Parameters::savestateParam)); 202 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::do_gradientParam) == "yes"); 203 CPPUNIT_ASSERT(parser->getParams().getBool(MpqcParser_Parameters::do_gradientParam)); 204 CPPUNIT_ASSERT(parser->getParams().getInt(MpqcParser_Parameters::maxiterParam) == 1000); 205 CPPUNIT_ASSERT(parser->getParams().getInt(MpqcParser_Parameters::memoryParam) == 16000000); 206 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::stdapproxParam) == "A'"); 207 CPPUNIT_ASSERT(parser->getParams().getInt(MpqcParser_Parameters::nfzcParam) == 1); 208 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::basisParam) == "3-21G"); 209 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::aux_basisParam) == "aug-cc-pVDZ"); 210 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::integrationParam) == "IntegralCints"); 211 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::theoryParam) == "MBPT2"); 212 CPPUNIT_ASSERT(parser->getParams().getTheory() == MpqcParser_Parameters::MBPT2); 213 CPPUNIT_ASSERT(parser->getParams().getIntegration() == MpqcParser_Parameters::IntegralCints); 212 214 213 215 // check that values are not removed 214 CPPUNIT_ASSERT(! mpqc->getParams().params[MpqcParser_Parameters::theoryParam].empty());216 CPPUNIT_ASSERT(!parser->getParams().params[MpqcParser_Parameters::theoryParam].empty()); 215 217 216 218 // check throw, for the moment aren't, are caught in getInt() 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 CPPUNIT_ASSERT_THROW(parser->getParams().getInt(MpqcParser_Parameters::integrationParam), boost::bad_any_cast); 220 CPPUNIT_ASSERT_THROW(parser->getParams().getInt(MpqcParser_Parameters::theoryParam), boost::bad_any_cast); 219 221 220 222 } 221 223 222 224 void ParserMpqcUnitTest::ParameterCloneTest() { 223 FormatParser_Parameters *clone = mpqc->getParams().clone();224 CPPUNIT_ASSERT( mpqc->getParams().getString(MpqcParser_Parameters::theoryParam) == "MBPT2");225 FormatParser_Parameters *clone = parser->getParams().clone(); 226 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::theoryParam) == "MBPT2"); 225 227 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");228 setvalue >> parser->getParams(); 229 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::theoryParam) == "CLHF"); 230 parser->getParams().makeClone(*clone); 231 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::theoryParam) == "MBPT2"); 230 232 } 231 233 … … 234 236 { 235 237 std::stringstream setvalue("theory = CLHF"); 236 setvalue >> mpqc->getParams();238 setvalue >> parser->getParams(); 237 239 // std::cout << "integration method is " 238 // << mpqc->getParams().getString(MpqcParser_Parameters::theoryParam) << std::endl;239 CPPUNIT_ASSERT( mpqc->getParams().getString(MpqcParser_Parameters::theoryParam) == "CLHF");240 // << parser->getParams().getString(MpqcParser_Parameters::theoryParam) << std::endl; 241 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::theoryParam) == "CLHF"); 240 242 } 241 243 // test a bool 242 244 { 243 245 std::stringstream setvalue("Hessian = yes"); 244 setvalue >> mpqc->getParams();246 setvalue >> parser->getParams(); 245 247 // std::cout << "Hessian is " 246 // << mpqc->getParams().getString(MpqcParser_Parameters::hessianParam) << std::endl;247 CPPUNIT_ASSERT( mpqc->getParams().getString(MpqcParser_Parameters::hessianParam) == "yes");248 // << parser->getParams().getString(MpqcParser_Parameters::hessianParam) << std::endl; 249 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::hessianParam) == "yes"); 248 250 } 249 251 // test int 250 252 { 251 253 std::stringstream setvalue("maxiter = 500"); 252 setvalue >> mpqc->getParams();254 setvalue >> parser->getParams(); 253 255 // std::cout << "maxiter is " 254 // << mpqc->getParams().getString(MpqcParser_Parameters::maxiterParam) << std::endl;255 CPPUNIT_ASSERT( mpqc->getParams().getInt(MpqcParser_Parameters::maxiterParam) == 500);256 // << parser->getParams().getString(MpqcParser_Parameters::maxiterParam) << std::endl; 257 CPPUNIT_ASSERT(parser->getParams().getInt(MpqcParser_Parameters::maxiterParam) == 500); 256 258 } 257 259 // test whether unknown key fails … … 261 263 #ifndef NDEBUG 262 264 ASSERT_DO(Assert::Throw); 263 CPPUNIT_ASSERT_THROW(setvalue >> mpqc->getParams(), Assert::AssertionFailure);265 CPPUNIT_ASSERT_THROW(setvalue >> parser->getParams(), Assert::AssertionFailure); 264 266 #else 265 setvalue >> mpqc->getParams();267 setvalue >> parser->getParams(); 266 268 #endif 267 269 // std::cout << "Hessian is still " 268 // << mpqc->getParams().getString(MpqcParser_Parameters::hessianParam) << std::endl;269 CPPUNIT_ASSERT( mpqc->getParams().getString(MpqcParser_Parameters::hessianParam) == "yes");270 // << parser->getParams().getString(MpqcParser_Parameters::hessianParam) << std::endl; 271 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::hessianParam) == "yes"); 270 272 } 271 273 } … … 273 275 void ParserMpqcUnitTest::readMpqcTest() { 274 276 stringstream input(waterMpqc_CLHF); 275 mpqc->getParams().setTheory(MpqcParser_Parameters::CLHF);276 mpqc->load(&input);277 parser->getParams().setTheory(MpqcParser_Parameters::CLHF); 278 parser->load(&input); 277 279 278 280 CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms()); … … 301 303 // compare both configs for CLHF 302 304 stringstream output; 303 mpqc->getParams().setTheory(MpqcParser_Parameters::CLHF);304 mpqc->save(&output, atoms);305 parser->getParams().setTheory(MpqcParser_Parameters::CLHF); 306 parser->save(&output, atoms); 305 307 stringstream input(waterMpqc_CLHF); 306 308 for (; std::getline(input, first) && std::getline(output, second); ) { … … 312 314 // compare both configs for CLKS 313 315 stringstream output; 314 mpqc->getParams().setTheory(MpqcParser_Parameters::CLKS);315 mpqc->save(&output, atoms);316 parser->getParams().setTheory(MpqcParser_Parameters::CLKS); 317 parser->save(&output, atoms); 316 318 stringstream input(waterMpqc_CLKS); 317 319 for (; std::getline(input, first) && std::getline(output, second); ) { … … 323 325 // compare both configs for MBPT2 324 326 stringstream output; 325 mpqc->getParams().setTheory(MpqcParser_Parameters::MBPT2);326 mpqc->save(&output, atoms);327 parser->getParams().setTheory(MpqcParser_Parameters::MBPT2); 328 parser->save(&output, atoms); 327 329 stringstream input(waterMpqc_MBPT2); 328 330 for (; std::getline(input, first) && std::getline(output, second); ) { … … 334 336 // compare both configs for MBPT2_R12 335 337 stringstream output; 336 mpqc->getParams().setTheory(MpqcParser_Parameters::MBPT2_R12);337 mpqc->save(&output, atoms);338 parser->getParams().setTheory(MpqcParser_Parameters::MBPT2_R12); 339 parser->save(&output, atoms); 338 340 stringstream input(waterMpqc_MBPT2_R12); 339 341 for (; std::getline(input, first) && std::getline(output, second); ) {
Note:
See TracChangeset
for help on using the changeset viewer.