Changeset 360c8b for src/Parser/unittests/ParserMpqcUnitTest.cpp
- Timestamp:
- Oct 20, 2011, 10:42:16 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:
- f94953
- Parents:
- fa9d1d (diff), 752bb4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - git-author:
- Frederik Heber <heber@…> (10/20/11 22:40:59)
- git-committer:
- Frederik Heber <heber@…> (10/20/11 22:42:16)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/unittests/ParserMpqcUnitTest.cpp
rfa9d1d r360c8b 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 … … 156 158 )\n"; // basically tested with mpqc 3.0.0-alpha (no parse errors but did not calculate due to missing code) 157 159 158 void ParserMpqcUnitTest::setUp() { 159 mpqc = new MpqcParser(); 160 void ParserMpqcUnitTest::setUp() 161 { 162 // failing asserts should be thrown 163 ASSERT_DO(Assert::Throw); 164 165 parser = new FormatParser<mpqc>(); 160 166 161 167 World::getInstance(); … … 168 174 } 169 175 170 void ParserMpqcUnitTest::tearDown() { 171 delete mpqc; 176 void ParserMpqcUnitTest::tearDown() 177 { 178 delete parser; 172 179 ChangeTracker::purgeInstance(); 173 180 World::purgeInstance(); … … 176 183 /************************************ tests ***********************************/ 177 184 178 void ParserMpqcUnitTest::ParameterTypeTest() {179 // check types in boost::any map180 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 }193 194 185 void ParserMpqcUnitTest::ParameterDefaultTest() { 195 186 // 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); 212 213 // check that values are not removed 214 CPPUNIT_ASSERT(!mpqc->getParams().params[MpqcParser_Parameters::theoryParam].empty()); 215 216 // 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 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")); 220 198 } 221 199 222 200 void ParserMpqcUnitTest::ParameterCloneTest() { 223 FormatParser_Parameters *clone = mpqc->getParams().clone();224 CPPUNIT_ASSERT( mpqc->getParams().getString(MpqcParser_Parameters::theoryParam) == "MBPT2");201 FormatParser_Parameters *clone = parser->getParams().clone(); 202 CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::theoryParam) == std::string("MBPT2")); 225 203 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");204 setvalue >> parser->getParams(); 205 CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::theoryParam) == std::string("CLHF")); 206 parser->getParams().makeClone(*clone); 207 CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::theoryParam) == std::string("MBPT2")); 230 208 } 231 209 … … 234 212 { 235 213 std::stringstream setvalue("theory = CLHF"); 236 setvalue >> mpqc->getParams();214 setvalue >> parser->getParams(); 237 215 // std::cout << "integration method is " 238 // << mpqc->getParams().getString(MpqcParser_Parameters::theoryParam) << std::endl;239 CPPUNIT_ASSERT( mpqc->getParams().getString(MpqcParser_Parameters::theoryParam) == "CLHF");216 // << parser->getParams().getString(MpqcParser_Parameters::theoryParam) << std::endl; 217 CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::theoryParam) == std::string("CLHF")); 240 218 } 241 219 // test a bool 242 220 { 243 221 std::stringstream setvalue("Hessian = yes"); 244 setvalue >> mpqc->getParams();222 setvalue >> parser->getParams(); 245 223 // std::cout << "Hessian is " 246 // << mpqc->getParams().getString(MpqcParser_Parameters::hessianParam) << std::endl;247 CPPUNIT_ASSERT( mpqc->getParams().getString(MpqcParser_Parameters::hessianParam) == "yes");224 // << parser->getParams().getString(MpqcParser_Parameters::hessianParam) << std::endl; 225 CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::hessianParam) == std::string("yes")); 248 226 } 249 227 // test int 250 228 { 251 229 std::stringstream setvalue("maxiter = 500"); 252 setvalue >> mpqc->getParams();230 setvalue >> parser->getParams(); 253 231 // std::cout << "maxiter is " 254 // << mpqc->getParams().getString(MpqcParser_Parameters::maxiterParam) << std::endl;255 CPPUNIT_ASSERT( mpqc->getParams().getInt(MpqcParser_Parameters::maxiterParam) == 500);232 // << parser->getParams().getString(MpqcParser_Parameters::maxiterParam) << std::endl; 233 CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::maxiterParam) == std::string("500")); 256 234 } 257 235 // test whether unknown key fails … … 261 239 #ifndef NDEBUG 262 240 ASSERT_DO(Assert::Throw); 263 CPPUNIT_ASSERT_THROW(setvalue >> mpqc->getParams(), Assert::AssertionFailure);241 CPPUNIT_ASSERT_THROW(setvalue >> parser->getParams(), Assert::AssertionFailure); 264 242 #else 265 setvalue >> mpqc->getParams();243 setvalue >> parser->getParams(); 266 244 #endif 267 245 // std::cout << "Hessian is still " 268 // << mpqc->getParams().getString(MpqcParser_Parameters::hessianParam) << std::endl;269 CPPUNIT_ASSERT( mpqc->getParams().getString(MpqcParser_Parameters::hessianParam) == "yes");246 // << parser->getParams().getString(MpqcParser_Parameters::hessianParam) << std::endl; 247 CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::hessianParam) == std::string("yes")); 270 248 } 271 249 } … … 273 251 void ParserMpqcUnitTest::readMpqcTest() { 274 252 stringstream input(waterMpqc_CLHF); 275 mpqc->getParams().setTheory(MpqcParser_Parameters::CLHF); 276 mpqc->load(&input); 253 parser->getParams().setParameter( 254 MpqcParser_Parameters::theoryParam, 255 parser->getParams().getTheoryName(MpqcParser_Parameters::CLHF) 256 ); 257 parser->load(&input); 277 258 278 259 CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms()); … … 301 282 // compare both configs for CLHF 302 283 stringstream output; 303 mpqc->getParams().setTheory(MpqcParser_Parameters::CLHF); 304 mpqc->save(&output, atoms); 284 parser->getParams().setParameter( 285 MpqcParser_Parameters::theoryParam, 286 parser->getParams().getTheoryName(MpqcParser_Parameters::CLHF) 287 ); 288 parser->save(&output, atoms); 305 289 stringstream input(waterMpqc_CLHF); 290 // check for non-empty streams 291 input.peek(); 292 output.peek(); 293 CPPUNIT_ASSERT(input.good() && output.good()); 294 // check equality of streams per line (for debugging) 306 295 for (; std::getline(input, first) && std::getline(output, second); ) { 307 296 //std::cout << "Comparing '" << first << "' to '" << second << "'" << std::endl; … … 312 301 // compare both configs for CLKS 313 302 stringstream output; 314 mpqc->getParams().setTheory(MpqcParser_Parameters::CLKS); 315 mpqc->save(&output, atoms); 303 parser->getParams().setParameter( 304 MpqcParser_Parameters::theoryParam, 305 parser->getParams().getTheoryName(MpqcParser_Parameters::CLKS) 306 ); 307 parser->save(&output, atoms); 316 308 stringstream input(waterMpqc_CLKS); 309 // check for non-empty streams 310 input.peek(); 311 output.peek(); 312 CPPUNIT_ASSERT(input.good() && output.good()); 313 // check equality of streams per line (for debugging) 317 314 for (; std::getline(input, first) && std::getline(output, second); ) { 318 315 //std::cout << "Comparing '" << first << "' to '" << second << "'" << std::endl; … … 323 320 // compare both configs for MBPT2 324 321 stringstream output; 325 mpqc->getParams().setTheory(MpqcParser_Parameters::MBPT2); 326 mpqc->save(&output, atoms); 322 parser->getParams().setParameter( 323 MpqcParser_Parameters::theoryParam, 324 parser->getParams().getTheoryName(MpqcParser_Parameters::MBPT2) 325 ); 326 parser->save(&output, atoms); 327 327 stringstream input(waterMpqc_MBPT2); 328 // check for non-empty streams 329 input.peek(); 330 output.peek(); 331 CPPUNIT_ASSERT(input.good() && output.good()); 332 // check equality of streams per line (for debugging) 328 333 for (; std::getline(input, first) && std::getline(output, second); ) { 329 334 //std::cout << "Comparing '" << first << "' to '" << second << "'" << std::endl; … … 334 339 // compare both configs for MBPT2_R12 335 340 stringstream output; 336 mpqc->getParams().setTheory(MpqcParser_Parameters::MBPT2_R12); 337 mpqc->save(&output, atoms); 341 parser->getParams().setParameter( 342 MpqcParser_Parameters::theoryParam, 343 parser->getParams().getTheoryName(MpqcParser_Parameters::MBPT2_R12) 344 ); 345 parser->save(&output, atoms); 338 346 stringstream input(waterMpqc_MBPT2_R12); 347 // check for non-empty streams 348 input.peek(); 349 output.peek(); 350 CPPUNIT_ASSERT(input.good() && output.good()); 351 // check equality of streams per line (for debugging) 339 352 for (; std::getline(input, first) && std::getline(output, second); ) { 340 353 //std::cout << "Comparing '" << first << "' to '" << second << "'" << std::endl;
Note:
See TracChangeset
for help on using the changeset viewer.