Ignore:
Timestamp:
Feb 7, 2011, 10:43:35 AM (14 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:
44fce5
Parents:
9cff8b
git-author:
Frederik Heber <heber@…> (02/03/11 11:56:26)
git-committer:
Frederik Heber <heber@…> (02/07/11 10:43:35)
Message:

Added MpqcParser_Parameter class to MpqcParser.

  • contains all extra info for the mpqc style config file.
  • so far not prepared for setting details via action.
Location:
src/Parser/unittests
Files:
2 edited

Legend:

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

    r9cff8b r61d69a4  
    2424#include <cppunit/ui/text/TestRunner.h>
    2525
    26 #include "Parser/MpqcParser.hpp"
     26#include <boost/any.hpp>
     27
    2728#include "World.hpp"
    2829#include "atom.hpp"
     
    4748\t\tmolecule = $:molecule\n\
    4849\t\tbasis = $:basis\n\
     50\t\tmaxiter = 1000\n\
    4951\t\tmemory = 16000000\n\
    5052\t)\n\
     
    7072\t\tmolecule = $:molecule\n\
    7173\t\tbasis = $:basis\n\
     74\t\tmaxiter = 1000\n\
    7275\t\tmemory = 16000000\n\
    7376\t)\n\
     
    9295\t\tbasis = $:basis\n\
    9396\t\tmolecule = $:molecule\n\
     97\t\tmemory = 16000000\n\
    9498\t\treference<CLHF>: (\n\
    9599\t\t\tmaxiter = 1000\n\
    96100\t\t\tbasis = $:basis\n\
    97101\t\t\tmolecule = $:molecule\n\
     102\t\t\tmemory = 16000000\n\
    98103\t\t)\n\
    99104\t)\n\
     
    151156
    152157void ParserMpqcUnitTest::setUp() {
     158  mpqc = new MpqcParser();
     159
    153160  World::getInstance();
    154161
     
    161168
    162169void ParserMpqcUnitTest::tearDown() {
     170  delete mpqc;
    163171  ChangeTracker::purgeInstance();
    164172  World::purgeInstance();
     
    167175/************************************ tests ***********************************/
    168176
     177void ParserMpqcUnitTest::ParameterTypeTest() {
     178  // check types in boost::any map
     179  CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::HessianParam].type() == typeid(bool));
     180  CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::HessianParam].type() != typeid(int));
     181  CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::savestateParam].type() == typeid(bool));
     182  CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::do_gradientParam].type() == typeid(bool));
     183  CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::maxiterParam].type() == typeid(int));
     184  CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::memoryParam].type() == typeid(int));
     185  CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::stdapproxParam].type() == typeid(std::string));
     186  CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::nfzcParam].type() == typeid(int));
     187  CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::basisParam].type() == typeid(std::string));
     188  CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::aux_basisParam].type() == typeid(std::string));
     189  CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::integrationParam].type() == typeid(MpqcParser_Parameters::IntegralCints));
     190  CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::theoryParam].type() == typeid(MpqcParser_Parameters::MBPT2));
     191}
     192
     193void ParserMpqcUnitTest::ParameterDefaultTest() {
     194  // check default values
     195  CPPUNIT_ASSERT(mpqc->params.getString(MpqcParser_Parameters::HessianParam) == "no");
     196  CPPUNIT_ASSERT(!mpqc->params.getBool(MpqcParser_Parameters::HessianParam));
     197  CPPUNIT_ASSERT(mpqc->params.getString(MpqcParser_Parameters::savestateParam) == "no");
     198  CPPUNIT_ASSERT(!mpqc->params.getBool(MpqcParser_Parameters::savestateParam));
     199  CPPUNIT_ASSERT(mpqc->params.getString(MpqcParser_Parameters::do_gradientParam) == "yes");
     200  CPPUNIT_ASSERT(mpqc->params.getBool(MpqcParser_Parameters::do_gradientParam));
     201  CPPUNIT_ASSERT(mpqc->params.getInt(MpqcParser_Parameters::maxiterParam) == 1000);
     202  CPPUNIT_ASSERT(mpqc->params.getInt(MpqcParser_Parameters::memoryParam) == 16000000);
     203  CPPUNIT_ASSERT(mpqc->params.getString(MpqcParser_Parameters::stdapproxParam) == "A'");
     204  CPPUNIT_ASSERT(mpqc->params.getInt(MpqcParser_Parameters::nfzcParam) == 1);
     205  CPPUNIT_ASSERT(mpqc->params.getString(MpqcParser_Parameters::basisParam) == "3-21G");
     206  CPPUNIT_ASSERT(mpqc->params.getString(MpqcParser_Parameters::aux_basisParam) == "aug-cc-pVDZ");
     207  CPPUNIT_ASSERT(mpqc->params.getString(MpqcParser_Parameters::integrationParam) == "IntegralCints");
     208  CPPUNIT_ASSERT(mpqc->params.getString(MpqcParser_Parameters::theoryParam) == "MBPT2");
     209  CPPUNIT_ASSERT(mpqc->params.getTheory() == MpqcParser_Parameters::MBPT2);
     210  CPPUNIT_ASSERT(mpqc->params.getIntegration() == MpqcParser_Parameters::IntegralCints);
     211
     212  // check that values are not removed
     213  CPPUNIT_ASSERT(!mpqc->params.params[MpqcParser_Parameters::theoryParam].empty());
     214
     215  // check throw, for the moment aren't, are caught in getInt()
     216  //CPPUNIT_ASSERT_THROW(mpqc->params.getInt(MpqcParser_Parameters::integrationParam), boost::bad_any_cast);
     217  //CPPUNIT_ASSERT_THROW(mpqc->params.getInt(MpqcParser_Parameters::theoryParam), boost::bad_any_cast);
     218
     219}
     220
    169221void ParserMpqcUnitTest::readMpqcTest() {
    170222  stringstream input(waterMpqc_CLHF);
    171   MpqcParser* testParser = new MpqcParser();
    172   testParser->setTheory(MpqcParser::CLHF);
    173   testParser->load(&input);
     223  mpqc->params.setTheory(MpqcParser_Parameters::CLHF);
     224  mpqc->load(&input);
    174225
    175226  CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms());
     
    194245  // create two stringstreams, one stored, one created
    195246
    196   MpqcParser* testParser = new MpqcParser();
    197247  std::vector<atom *> atoms = World::getInstance().getAllAtoms();
    198248  {
    199249    // compare both configs for CLHF
    200250    stringstream output;
    201     testParser->setTheory(MpqcParser::CLHF);
    202     testParser->save(&output, atoms);
     251    mpqc->params.setTheory(MpqcParser_Parameters::CLHF);
     252    mpqc->save(&output, atoms);
    203253    stringstream input(waterMpqc_CLHF);
    204254    for (; std::getline(input, first) && std::getline(output, second); ) {
     
    210260    // compare both configs for CLKS
    211261    stringstream output;
    212     testParser->setTheory(MpqcParser::CLKS);
    213     testParser->save(&output, atoms);
     262    mpqc->params.setTheory(MpqcParser_Parameters::CLKS);
     263    mpqc->save(&output, atoms);
    214264    stringstream input(waterMpqc_CLKS);
    215265    for (; std::getline(input, first) && std::getline(output, second); ) {
     
    221271    // compare both configs for MBPT2
    222272    stringstream output;
    223     testParser->setTheory(MpqcParser::MBPT2);
    224     testParser->save(&output, atoms);
     273    mpqc->params.setTheory(MpqcParser_Parameters::MBPT2);
     274    mpqc->save(&output, atoms);
    225275    stringstream input(waterMpqc_MBPT2);
    226276    for (; std::getline(input, first) && std::getline(output, second); ) {
     
    232282    // compare both configs for MBPT2_R12
    233283    stringstream output;
    234     testParser->setTheory(MpqcParser::MBPT2_R12);
    235     testParser->save(&output, atoms);
     284    mpqc->params.setTheory(MpqcParser_Parameters::MBPT2_R12);
     285    mpqc->save(&output, atoms);
    236286    stringstream input(waterMpqc_MBPT2_R12);
    237287    for (; std::getline(input, first) && std::getline(output, second); ) {
  • src/Parser/unittests/ParserMpqcUnitTest.hpp

    r9cff8b r61d69a4  
    1313#endif
    1414
     15#include "Parser/MpqcParser.hpp"
    1516
    1617#include <cppunit/extensions/HelperMacros.h>
     
    2021{
    2122  CPPUNIT_TEST_SUITE( ParserMpqcUnitTest ) ;
     23  CPPUNIT_TEST ( ParameterTypeTest );
     24  CPPUNIT_TEST ( ParameterDefaultTest );
     25  CPPUNIT_TEST ( readMpqcTest );
    2226  CPPUNIT_TEST ( writeMpqcTest );
    23   CPPUNIT_TEST ( readMpqcTest );
    2427  CPPUNIT_TEST_SUITE_END();
    2528
     
    2831  void tearDown();
    2932
     33  void ParameterTypeTest();
     34  void ParameterDefaultTest();
    3035  void readMpqcTest();
    3136  void writeMpqcTest();
     37
     38private:
     39  MpqcParser *mpqc;
    3240};
    3341
Note: See TracChangeset for help on using the changeset viewer.