Ignore:
Timestamp:
Oct 20, 2011, 10:42:16 PM (13 years ago)
Author:
Frederik Heber <heber@…>
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)
Message:

Merge branch 'Adding_Psi3Parser' into stable

Conflicts:

src/Parser/FormatParser.hpp
src/Parser/unittests/ParserTremoloUnitTest.cpp

Issues:

  • Element and periodentafel have been moved to folder src/Element.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/unittests/ParserMpqcUnitTest.cpp

    rfa9d1d r360c8b  
    3232#include "Descriptors/AtomTypeDescriptor.hpp"
    3333#include "CodePatterns/Assert.hpp"
     34#include "Parser/ChangeTracker.hpp"
     35#include "Parser/MpqcParser.hpp"
    3436
    3537#ifdef HAVE_TESTRUNNER
     
    156158)\n"; // basically tested with mpqc 3.0.0-alpha (no parse errors but did not calculate due to missing code)
    157159
    158 void ParserMpqcUnitTest::setUp() {
    159   mpqc = new MpqcParser();
     160void ParserMpqcUnitTest::setUp()
     161{
     162  // failing asserts should be thrown
     163  ASSERT_DO(Assert::Throw);
     164
     165  parser = new FormatParser<mpqc>();
    160166
    161167  World::getInstance();
     
    168174}
    169175
    170 void ParserMpqcUnitTest::tearDown() {
    171   delete mpqc;
     176void ParserMpqcUnitTest::tearDown()
     177{
     178  delete parser;
    172179  ChangeTracker::purgeInstance();
    173180  World::purgeInstance();
     
    176183/************************************ tests ***********************************/
    177184
    178 void ParserMpqcUnitTest::ParameterTypeTest() {
    179   // 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));
    192 }
    193 
    194185void ParserMpqcUnitTest::ParameterDefaultTest() {
    195186  // 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"));
    220198}
    221199
    222200void 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"));
    225203  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"));
    230208}
    231209
     
    234212  {
    235213    std::stringstream setvalue("theory = CLHF");
    236     setvalue >> mpqc->getParams();
     214    setvalue >> parser->getParams();
    237215//    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"));
    240218  }
    241219  // test a bool
    242220  {
    243221    std::stringstream setvalue("Hessian = yes");
    244     setvalue >> mpqc->getParams();
     222    setvalue >> parser->getParams();
    245223//    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"));
    248226  }
    249227  // test int
    250228  {
    251229    std::stringstream setvalue("maxiter = 500");
    252     setvalue >> mpqc->getParams();
     230    setvalue >> parser->getParams();
    253231//    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"));
    256234  }
    257235  // test whether unknown key fails
     
    261239#ifndef NDEBUG
    262240    ASSERT_DO(Assert::Throw);
    263     CPPUNIT_ASSERT_THROW(setvalue >> mpqc->getParams(), Assert::AssertionFailure);
     241    CPPUNIT_ASSERT_THROW(setvalue >> parser->getParams(), Assert::AssertionFailure);
    264242#else
    265     setvalue >> mpqc->getParams();
     243    setvalue >> parser->getParams();
    266244#endif
    267245//    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"));
    270248  }
    271249}
     
    273251void ParserMpqcUnitTest::readMpqcTest() {
    274252  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);
    277258
    278259  CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms());
     
    301282    // compare both configs for CLHF
    302283    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);
    305289    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)
    306295    for (; std::getline(input, first) && std::getline(output, second); ) {
    307296      //std::cout << "Comparing '" << first << "' to '" << second << "'" << std::endl;
     
    312301    // compare both configs for CLKS
    313302    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);
    316308    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)
    317314    for (; std::getline(input, first) && std::getline(output, second); ) {
    318315      //std::cout << "Comparing '" << first << "' to '" << second << "'" << std::endl;
     
    323320    // compare both configs for MBPT2
    324321    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);
    327327    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)
    328333    for (; std::getline(input, first) && std::getline(output, second); ) {
    329334      //std::cout << "Comparing '" << first << "' to '" << second << "'" << std::endl;
     
    334339    // compare both configs for MBPT2_R12
    335340    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);
    338346    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)
    339352    for (; std::getline(input, first) && std::getline(output, second); ) {
    340353      //std::cout << "Comparing '" << first << "' to '" << second << "'" << std::endl;
Note: See TracChangeset for help on using the changeset viewer.