source: src/Parser/unittests/ParserMpqcUnitTest.cpp@ 9e4fd1

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
Last change on this file since 9e4fd1 was 9e4fd1, checked in by Frederik Heber <heber@…>, 14 years ago

Split up ParserCommonUnitTest into a UnitTest for each Parser.

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010 University of Bonn. All rights reserved.
5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
8/*
9 * ParserMpqcUnitTest.cpp
10 *
11 * Created on: Mar 3, 2010
12 * Author: metzler
13 */
14
15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
19
20#include "ParserMpqcUnitTest.hpp"
21
22#include <cppunit/CompilerOutputter.h>
23#include <cppunit/extensions/TestFactoryRegistry.h>
24#include <cppunit/ui/text/TestRunner.h>
25
26#include "Parser/MpqcParser.hpp"
27#include "World.hpp"
28#include "atom.hpp"
29#include "element.hpp"
30#include "periodentafel.hpp"
31#include "Descriptors/AtomTypeDescriptor.hpp"
32
33#ifdef HAVE_TESTRUNNER
34#include "UnitTestMain.hpp"
35#endif /*HAVE_TESTRUNNER*/
36
37using namespace std;
38
39// Registers the fixture into the 'registry'
40CPPUNIT_TEST_SUITE_REGISTRATION( ParserMpqcUnitTest );
41
42static string waterMpqc ="% Created by MoleCuilder\n\
43mpqc: (\n\
44\tsavestate = no\n\
45\tdo_gradient = yes\n\
46\tmole<MBPT2>: (\n\
47\t\tmaxiter = 200\n\
48\t\tbasis = $:basis\n\
49\t\tmolecule = $:molecule\n\
50\t\treference<CLHF>: (\n\
51\t\t\tbasis = $:basis\n\
52\t\t\tmolecule = $:molecule\n\
53\t\t)\n\
54\t)\n\
55)\n\
56molecule<Molecule>: (\n\
57\tunit = angstrom\n\
58\t{ atoms geometry } = {\n\
59\t\tO [ -0.505735\t0\t0 ]\n\
60\t\tH [ 0.252867\t0\t0.504284 ]\n\
61\t\tH [ 0.252867\t0\t-0.504284 ]\n\
62\t}\n\
63)\n\
64basis<GaussianBasisSet>: (\n\
65\tname = \"3-21G\"\n\
66\tmolecule = $:molecule\n\
67)\n";
68
69void ParserMpqcUnitTest::setUp() {
70 World::getInstance();
71
72 setVerbosity(2);
73
74 // we need hydrogens and oxygens in the following tests
75 CPPUNIT_ASSERT(World::getInstance().getPeriode()->FindElement(1) != NULL);
76 CPPUNIT_ASSERT(World::getInstance().getPeriode()->FindElement(8) != NULL);
77}
78
79void ParserMpqcUnitTest::tearDown() {
80 ChangeTracker::purgeInstance();
81 World::purgeInstance();
82}
83
84/************************************ tests ***********************************/
85
86void ParserMpqcUnitTest::writeMpqcTest() {
87 // build up water molecule
88 atom *Walker = NULL;
89 Walker = World::getInstance().createAtom();
90 Walker->setType(8);
91 Walker->setPosition(Vector(0,0,0));
92 Walker = World::getInstance().createAtom();
93 Walker->setType(1);
94 Walker->setPosition(Vector(0.758602,0,0.504284));
95 Walker = World::getInstance().createAtom();
96 Walker->setType(1);
97 Walker->setPosition(Vector(0.758602,0,-0.504284));
98 CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms());
99
100 // create two stringstreams, one stored, one created
101 stringstream input(waterMpqc);
102 MpqcParser* testParser = new MpqcParser();
103 stringstream output;
104 std::vector<atom *> atoms = World::getInstance().getAllAtoms();
105 testParser->save(&output, atoms);
106
107 // compare both configs
108 string first = input.str();
109 string second = output.str();
110 CPPUNIT_ASSERT(first == second);
111}
Note: See TracBrowser for help on using the repository browser.