| [ab4b55] | 1 | /* | 
|---|
|  | 2 | * ParserUnitTest.cpp | 
|---|
|  | 3 | * | 
|---|
|  | 4 | *  Created on: Mar 3, 2010 | 
|---|
|  | 5 | *      Author: metzler | 
|---|
|  | 6 | */ | 
|---|
|  | 7 |  | 
|---|
|  | 8 | #include "ParserUnitTest.hpp" | 
|---|
|  | 9 |  | 
|---|
|  | 10 | #include <cppunit/CompilerOutputter.h> | 
|---|
|  | 11 | #include <cppunit/extensions/TestFactoryRegistry.h> | 
|---|
|  | 12 | #include <cppunit/ui/text/TestRunner.h> | 
|---|
|  | 13 |  | 
|---|
| [1b2d30] | 14 | #include "Parser/MpqcParser.hpp" | 
|---|
|  | 15 | #include "Parser/PcpParser.hpp" | 
|---|
| [9131f3] | 16 | #include "Parser/TremoloParser.hpp" | 
|---|
| [1b2d30] | 17 | #include "Parser/XyzParser.hpp" | 
|---|
| [ab4b55] | 18 | #include "World.hpp" | 
|---|
| [b8d4a3] | 19 | #include "atom.hpp" | 
|---|
| [ab4b55] | 20 | #include "element.hpp" | 
|---|
|  | 21 | #include "periodentafel.hpp" | 
|---|
| [b8d4a3] | 22 | #include "Descriptors/AtomTypeDescriptor.hpp" | 
|---|
| [ab4b55] | 23 |  | 
|---|
|  | 24 | #ifdef HAVE_TESTRUNNER | 
|---|
|  | 25 | #include "UnitTestMain.hpp" | 
|---|
|  | 26 | #endif /*HAVE_TESTRUNNER*/ | 
|---|
|  | 27 |  | 
|---|
|  | 28 | using namespace std; | 
|---|
|  | 29 |  | 
|---|
|  | 30 | // Registers the fixture into the 'registry' | 
|---|
|  | 31 | CPPUNIT_TEST_SUITE_REGISTRATION( ParserUnitTest ); | 
|---|
|  | 32 |  | 
|---|
| [1b2d30] | 33 | static string waterPcp = "# ParallelCarParinello - main configuration file - created with molecuilder\n\ | 
|---|
|  | 34 | \n\ | 
|---|
|  | 35 | mainname\tpcp\t# programm name (for runtime files)\n\ | 
|---|
|  | 36 | defaultpath\not specified\t# where to put files during runtime\n\ | 
|---|
|  | 37 | pseudopotpath\not specified\t# where to find pseudopotentials\n\ | 
|---|
|  | 38 | \n\ | 
|---|
|  | 39 | ProcPEGamma\t8\t# for parallel computing: share constants\n\ | 
|---|
|  | 40 | ProcPEPsi\t1\t# for parallel computing: share wave functions\n\ | 
|---|
|  | 41 | DoOutVis\t0\t# Output data for OpenDX\n\ | 
|---|
|  | 42 | DoOutMes\t1\t# Output data for measurements\n\ | 
|---|
|  | 43 | DoOutOrbitals\t0\t# Output all Orbitals\n\ | 
|---|
|  | 44 | DoOutCurr\t0\t# Ouput current density for OpenDx\n\ | 
|---|
|  | 45 | DoOutNICS\t0\t# Output Nucleus independent current shieldings\n\ | 
|---|
|  | 46 | DoPerturbation\t0\t# Do perturbation calculate and determine susceptibility and shielding\n\ | 
|---|
|  | 47 | DoFullCurrent\t0\t# Do full perturbation\n\ | 
|---|
|  | 48 | DoConstrainedMD\t0\t# Do perform a constrained (>0, relating to current MD step) instead of unconstrained (0) MD\n\ | 
|---|
|  | 49 | Thermostat\tBerendsen\t2.5\t# Which Thermostat and its parameters to use in MD case.\n\ | 
|---|
|  | 50 | CommonWannier\t0\t# Put virtual centers at indivual orbits, all common, merged by variance, to grid point, to cell center\n\ | 
|---|
|  | 51 | SawtoothStart\t0.01\t# Absolute value for smooth transition at cell border \n\ | 
|---|
|  | 52 | VectorPlane\t0\t# Cut plane axis (x, y or z: 0,1,2) for two-dim current vector plot\n\ | 
|---|
|  | 53 | VectorCut\t0\t# Cut plane axis value\n\ | 
|---|
|  | 54 | AddGramSch\t1\t# Additional GramSchmidtOrtogonalization to be safe\n\ | 
|---|
|  | 55 | Seed\t1\t# initial value for random seed for Psi coefficients\n\ | 
|---|
|  | 56 | \n\ | 
|---|
|  | 57 | MaxOuterStep\t0\t# number of MolecularDynamics/Structure optimization steps\n\ | 
|---|
|  | 58 | Deltat\t0.01\t# time per MD step\n\ | 
|---|
|  | 59 | OutVisStep\t10\t# Output visual data every ...th step\n\ | 
|---|
|  | 60 | OutSrcStep\t5\t# Output \"restart\" data every ..th step\n\ | 
|---|
|  | 61 | TargetTemp\t0.000950045\t# Target temperature\n\ | 
|---|
|  | 62 | MaxPsiStep\t3\t# number of Minimisation steps per state (0 - default)\n\ | 
|---|
|  | 63 | EpsWannier\t1e-07\t# tolerance value for spread minimisation of orbitals\n\ | 
|---|
|  | 64 | # Values specifying when to stop\n\ | 
|---|
|  | 65 | MaxMinStep\t100\t# Maximum number of steps\n\ | 
|---|
|  | 66 | RelEpsTotalE\t1e-07\t# relative change in total energy\n\ | 
|---|
|  | 67 | RelEpsKineticE\t1e-05\t# relative change in kinetic energy\n\ | 
|---|
| [2fd80b5] | 68 | MaxMinStopStep\t2\t# check every ..th steps\n\ | 
|---|
| [1b2d30] | 69 | MaxMinGapStopStep\t1\t# check every ..th steps\n\ | 
|---|
|  | 70 | \n\ | 
|---|
|  | 71 | # Values specifying when to stop for INIT, otherwise same as above\n\ | 
|---|
|  | 72 | MaxInitMinStep\t100\t# Maximum number of steps\n\ | 
|---|
|  | 73 | InitRelEpsTotalE\t1e-05\t# relative change in total energy\n\ | 
|---|
|  | 74 | InitRelEpsKineticE\t0.0001\t# relative change in kinetic energy\n\ | 
|---|
| [2fd80b5] | 75 | InitMaxMinStopStep\t2\t# check every ..th steps\n\ | 
|---|
| [1b2d30] | 76 | InitMaxMinGapStopStep\t1\t# check every ..th steps\n\ | 
|---|
|  | 77 | \n\ | 
|---|
|  | 78 | BoxLength\t# (Length of a unit cell)\n\ | 
|---|
|  | 79 | 20\n\ | 
|---|
|  | 80 | 0\t20\n\ | 
|---|
|  | 81 | 0\t0\t20\n\ | 
|---|
|  | 82 | \n\ | 
|---|
|  | 83 | ECut\t128\t# energy cutoff for discretization in Hartrees\n\ | 
|---|
|  | 84 | MaxLevel\t5\t# number of different levels in the code, >=2\n\ | 
|---|
|  | 85 | Level0Factor\t2\t# factor by which node number increases from S to 0 level\n\ | 
|---|
|  | 86 | RiemannTensor\t0\t# (Use metric)\n\ | 
|---|
|  | 87 | PsiType\t0\t# 0 - doubly occupied, 1 - SpinUp,SpinDown\n\ | 
|---|
| [2fd80b5] | 88 | MaxPsiDouble\t2\t# here: specifying both maximum number of SpinUp- and -Down-states\n\ | 
|---|
|  | 89 | PsiMaxNoUp\t2\t# here: specifying maximum number of SpinUp-states\n\ | 
|---|
|  | 90 | PsiMaxNoDown\t2\t# here: specifying maximum number of SpinDown-states\n\ | 
|---|
| [1b2d30] | 91 | AddPsis\t0\t# Additional unoccupied Psis for bandgap determination\n\ | 
|---|
|  | 92 | \n\ | 
|---|
|  | 93 | RCut\t20\t# R-cut for the ewald summation\n\ | 
|---|
|  | 94 | StructOpt\t0\t# Do structure optimization beforehand\n\ | 
|---|
|  | 95 | IsAngstroem\t1\t# 0 - Bohr, 1 - Angstroem\n\ | 
|---|
|  | 96 | RelativeCoord\t0\t# whether ion coordinates are relative (1) or absolute (0)\n\ | 
|---|
|  | 97 | MaxTypes\t2\t# maximum number of different ion types\n\ | 
|---|
|  | 98 | \n\ | 
|---|
|  | 99 | # Ion type data (PP = PseudoPotential, Z = atomic number)\n\ | 
|---|
|  | 100 | #Ion_TypeNr.\tAmount\tZ\tRGauss\tL_Max(PP)L_Loc(PP)IonMass\t# chemical name, symbol\n\ | 
|---|
|  | 101 | Ion_Type1\t2\t1\t1.0\t3\t3\t1.008\tHydrogen\tH\n\ | 
|---|
|  | 102 | Ion_Type2\t1\t8\t1.0\t3\t3\t15.999\tOxygen\tO\n\ | 
|---|
|  | 103 | #Ion_TypeNr._Nr.R[0]\tR[1]\tR[2]\tMoveType (0 MoveIon, 1 FixedIon)\n\ | 
|---|
|  | 104 | Ion_Type2_1\t0.000000000\t0.000000000\t0.000000000\t0 # molecule nr 0\n\ | 
|---|
|  | 105 | Ion_Type1_1\t0.758602\t0.000000000\t0.504284\t0 # molecule nr 1\n\ | 
|---|
|  | 106 | Ion_Type1_2\t0.758602\t0.000000000\t-0.504284\t0 # molecule nr 2\n"; | 
|---|
|  | 107 | static string waterMpqc ="% Created by MoleCuilder\n\ | 
|---|
|  | 108 | mpqc: (\n\ | 
|---|
|  | 109 | \tsavestate = no\n\ | 
|---|
|  | 110 | \tdo_gradient = yes\n\ | 
|---|
|  | 111 | \tmole<MBPT2>: (\n\ | 
|---|
|  | 112 | \t\tmaxiter = 200\n\ | 
|---|
|  | 113 | \t\tbasis = $:basis\n\ | 
|---|
|  | 114 | \t\tmolecule = $:molecule\n\ | 
|---|
|  | 115 | \t\treference<CLHF>: (\n\ | 
|---|
|  | 116 | \t\t\tbasis = $:basis\n\ | 
|---|
|  | 117 | \t\t\tmolecule = $:molecule\n\ | 
|---|
|  | 118 | \t\t)\n\ | 
|---|
|  | 119 | \t)\n\ | 
|---|
|  | 120 | )\n\ | 
|---|
|  | 121 | molecule<Molecule>: (\n\ | 
|---|
|  | 122 | \tunit = angstrom\n\ | 
|---|
|  | 123 | \t{ atoms geometry } = {\n\ | 
|---|
| [2fd80b5] | 124 | \t\tO [ -0.505735\t0\t0 ]\n\ | 
|---|
|  | 125 | \t\tH [ 0.252867\t0\t0.504284 ]\n\ | 
|---|
|  | 126 | \t\tH [ 0.252867\t0\t-0.504284 ]\n\ | 
|---|
| [1b2d30] | 127 | \t}\n\ | 
|---|
|  | 128 | )\n\ | 
|---|
|  | 129 | basis<GaussianBasisSet>: (\n\ | 
|---|
|  | 130 | \tname = \"3-21G\"\n\ | 
|---|
|  | 131 | \tmolecule = $:molecule\n\ | 
|---|
|  | 132 | )\n"; | 
|---|
| [2fd80b5] | 133 | static string waterXyz = "3\nH2O: water molecule\nO\t0\t0\t0\nH\t0.758602\t0\t0.504284\nH\t0.758602\t0\t-0.504284\n"; | 
|---|
| [1b2d30] | 134 | static string Tremolo_Atomdata1 = "# ATOMDATA\tId\tname\tType\tx=3\n"; | 
|---|
|  | 135 | static string Tremolo_Atomdata2 = "#\n#ATOMDATA Id name Type x=3\n1 hydrogen H 3.0 4.5 0.1\n\n"; | 
|---|
|  | 136 | static string Tremolo_invalidkey = "#\n#ATOMDATA Id name foo Type x=3\n\n\n"; | 
|---|
|  | 137 | static string Tremolo_velocity = "#\n#ATOMDATA Id name Type u=3\n1 hydrogen H 3.0 4.5 0.1\n\n"; | 
|---|
|  | 138 | static string Tremolo_neighbours = "#\n#ATOMDATA Id Type neighbors=2\n1 H 3 0\n2 H 3 0\n3 O 1 2\n"; | 
|---|
|  | 139 | static string Tremolo_improper = "#\n#ATOMDATA Id Type imprData\n8 H 9-10\n9 H 10-8,8-10\n10 O -\n"; | 
|---|
|  | 140 | static string Tremolo_torsion = "#\n#ATOMDATA Id Type torsion\n8 H 9-10\n9 H 10-8,8-10\n10 O -\n"; | 
|---|
|  | 141 | static string Tremolo_full = "# ATOMDATA\tx=3\tu=3\tF\tstress\tId\tneighbors=5\timprData\tGroupMeasureTypeNo\tType\textType\tname\tresName\tchainID\tresSeq\toccupancy\ttempFactor\tsegID\tCharge\tcharge\tGrpTypeNo\ttorsion\n0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t-\t0\tH\t-\t-\t-\t0\t0\t0\t0\t0\t0\t0\t0\t-\t\n"; | 
|---|
| [ab4b55] | 142 |  | 
|---|
|  | 143 | void ParserUnitTest::setUp() { | 
|---|
| [4eb4fe] | 144 | World::getInstance(); | 
|---|
| [1b2d30] | 145 |  | 
|---|
|  | 146 | // we need hydrogens and oxygens in the following tests | 
|---|
|  | 147 | CPPUNIT_ASSERT(World::getInstance().getPeriode()->FindElement(1) != NULL); | 
|---|
|  | 148 | CPPUNIT_ASSERT(World::getInstance().getPeriode()->FindElement(8) != NULL); | 
|---|
| [ab4b55] | 149 | } | 
|---|
|  | 150 |  | 
|---|
|  | 151 | void ParserUnitTest::tearDown() { | 
|---|
| [2f40c0e] | 152 | ChangeTracker::purgeInstance(); | 
|---|
| [b8d4a3] | 153 | World::purgeInstance(); | 
|---|
| [ab4b55] | 154 | } | 
|---|
|  | 155 |  | 
|---|
|  | 156 | /************************************ tests ***********************************/ | 
|---|
|  | 157 |  | 
|---|
|  | 158 | void ParserUnitTest::rewriteAnXyzTest() { | 
|---|
| [9131f3] | 159 | cout << "Testing the XYZ parser." << endl; | 
|---|
| [ab4b55] | 160 | XyzParser* testParser = new XyzParser(); | 
|---|
|  | 161 | stringstream input; | 
|---|
|  | 162 | input << waterXyz; | 
|---|
|  | 163 | testParser->load(&input); | 
|---|
|  | 164 |  | 
|---|
| [4415da] | 165 | CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms()); | 
|---|
| [ab4b55] | 166 |  | 
|---|
|  | 167 | string newWaterXyz = ""; | 
|---|
|  | 168 | stringstream output; | 
|---|
|  | 169 | testParser->save(&output); | 
|---|
|  | 170 | newWaterXyz = output.str(); | 
|---|
|  | 171 |  | 
|---|
|  | 172 | CPPUNIT_ASSERT(waterXyz == newWaterXyz); | 
|---|
|  | 173 | } | 
|---|
|  | 174 |  | 
|---|
| [b8d4a3] | 175 | void ParserUnitTest::readTremoloPreliminaryCommentsTest() { | 
|---|
| [9131f3] | 176 | cout << "Testing the tremolo parser." << endl; | 
|---|
|  | 177 | TremoloParser* testParser = new TremoloParser(); | 
|---|
| [b8d4a3] | 178 | stringstream input, output; | 
|---|
| [4415da] | 179 |  | 
|---|
|  | 180 | // Atomdata beginning with "# ATOMDATA" | 
|---|
| [1b2d30] | 181 | input << Tremolo_Atomdata1; | 
|---|
| [9131f3] | 182 | testParser->load(&input); | 
|---|
| [b8d4a3] | 183 | testParser->save(&output); | 
|---|
| [1b2d30] | 184 | CPPUNIT_ASSERT(Tremolo_Atomdata1 == output.str()); | 
|---|
| [4415da] | 185 | input.clear(); | 
|---|
| [b8d4a3] | 186 | output.clear(); | 
|---|
| [4415da] | 187 |  | 
|---|
|  | 188 | // Atomdata beginning with "#ATOMDATA" | 
|---|
| [1b2d30] | 189 | input << Tremolo_Atomdata2; | 
|---|
| [b8d4a3] | 190 | testParser->load(&input); | 
|---|
|  | 191 | testParser->save(&output); | 
|---|
|  | 192 | CPPUNIT_ASSERT(output.str().find("hydrogen") != string::npos); | 
|---|
|  | 193 | input.clear(); | 
|---|
|  | 194 | output.clear(); | 
|---|
|  | 195 |  | 
|---|
|  | 196 | // Invalid key in Atomdata line | 
|---|
| [1b2d30] | 197 | input << Tremolo_invalidkey; | 
|---|
| [4415da] | 198 | testParser->load(&input); | 
|---|
| [b8d4a3] | 199 | //TODO: proove invalidity | 
|---|
| [9131f3] | 200 | input.clear(); | 
|---|
| [b8d4a3] | 201 | } | 
|---|
|  | 202 |  | 
|---|
|  | 203 | void ParserUnitTest::readTremoloCoordinatesTest() { | 
|---|
|  | 204 | TremoloParser* testParser = new TremoloParser(); | 
|---|
|  | 205 | stringstream input; | 
|---|
| [4415da] | 206 |  | 
|---|
|  | 207 | // One simple data line | 
|---|
| [1b2d30] | 208 | input << Tremolo_Atomdata2; | 
|---|
| [9131f3] | 209 | testParser->load(&input); | 
|---|
| [b9b604] | 210 | CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->x[0] == 3.0); | 
|---|
| [4415da] | 211 | input.clear(); | 
|---|
| [b8d4a3] | 212 | } | 
|---|
| [4415da] | 213 |  | 
|---|
| [b8d4a3] | 214 | void ParserUnitTest::readTremoloVelocityTest() { | 
|---|
|  | 215 | TremoloParser* testParser = new TremoloParser(); | 
|---|
|  | 216 | stringstream input; | 
|---|
|  | 217 |  | 
|---|
|  | 218 | // One simple data line | 
|---|
| [1b2d30] | 219 | input << Tremolo_velocity; | 
|---|
| [b8d4a3] | 220 | testParser->load(&input); | 
|---|
| [b9b604] | 221 | CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->v[0] == 3.0); | 
|---|
| [b8d4a3] | 222 | input.clear(); | 
|---|
|  | 223 | } | 
|---|
|  | 224 |  | 
|---|
|  | 225 | void ParserUnitTest::readTremoloNeighborInformationTest() { | 
|---|
|  | 226 | TremoloParser* testParser = new TremoloParser(); | 
|---|
|  | 227 | stringstream input; | 
|---|
|  | 228 |  | 
|---|
|  | 229 | // Neighbor data | 
|---|
| [1b2d30] | 230 | input << Tremolo_neighbours; | 
|---|
| [b8d4a3] | 231 | testParser->load(&input); | 
|---|
|  | 232 |  | 
|---|
|  | 233 | CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms()); | 
|---|
|  | 234 | CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(8))-> | 
|---|
|  | 235 | IsBondedTo(World::getInstance().getAtom(AtomByType(1)))); | 
|---|
|  | 236 | input.clear(); | 
|---|
|  | 237 | } | 
|---|
|  | 238 |  | 
|---|
|  | 239 | void ParserUnitTest::readAndWriteTremoloImprDataInformationTest() { | 
|---|
|  | 240 | TremoloParser* testParser = new TremoloParser(); | 
|---|
|  | 241 | stringstream input, output; | 
|---|
|  | 242 |  | 
|---|
|  | 243 | // Neighbor data | 
|---|
| [1b2d30] | 244 | input << Tremolo_improper; | 
|---|
| [4415da] | 245 | testParser->load(&input); | 
|---|
| [b8d4a3] | 246 | testParser->save(&output); | 
|---|
|  | 247 | CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms()); | 
|---|
|  | 248 | CPPUNIT_ASSERT(output.str().find("2-0,0-2") != string::npos); | 
|---|
| [4415da] | 249 | input.clear(); | 
|---|
| [b8d4a3] | 250 | output.clear(); | 
|---|
|  | 251 | } | 
|---|
|  | 252 |  | 
|---|
|  | 253 | void ParserUnitTest::readAndWriteTremoloTorsionInformationTest() { | 
|---|
|  | 254 | TremoloParser* testParser = new TremoloParser(); | 
|---|
|  | 255 | stringstream input, output; | 
|---|
|  | 256 |  | 
|---|
|  | 257 | // Neighbor data | 
|---|
| [1b2d30] | 258 | input << Tremolo_torsion; | 
|---|
| [b8d4a3] | 259 | testParser->load(&input); | 
|---|
|  | 260 | testParser->save(&output); | 
|---|
|  | 261 | CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms()); | 
|---|
|  | 262 | CPPUNIT_ASSERT(output.str().find("2-0,0-2") != string::npos); | 
|---|
|  | 263 | input.clear(); | 
|---|
|  | 264 | output.clear(); | 
|---|
|  | 265 | } | 
|---|
|  | 266 |  | 
|---|
|  | 267 | void ParserUnitTest::writeTremoloTest() { | 
|---|
|  | 268 | TremoloParser* testParser = new TremoloParser(); | 
|---|
|  | 269 | stringstream output; | 
|---|
|  | 270 |  | 
|---|
|  | 271 | // with the maximum number of fields and minimal information, default values are printed | 
|---|
|  | 272 | atom* newAtom = World::getInstance().createAtom(); | 
|---|
|  | 273 | newAtom->type = World::getInstance().getPeriode()->FindElement(1); | 
|---|
|  | 274 | testParser->setFieldsForSave("x=3 u=3 F stress Id neighbors=5 imprData GroupMeasureTypeNo Type extType name resName chainID resSeq occupancy tempFactor segID Charge charge GrpTypeNo torsion"); | 
|---|
|  | 275 | testParser->save(&output); | 
|---|
| [1b2d30] | 276 | CPPUNIT_ASSERT(output.str() == Tremolo_full); | 
|---|
| [4415da] | 277 |  | 
|---|
| [9131f3] | 278 | cout << "testing the tremolo parser is done" << endl; | 
|---|
|  | 279 | } | 
|---|
| [1b2d30] | 280 |  | 
|---|
|  | 281 | void ParserUnitTest::readwritePcpTest() { | 
|---|
|  | 282 | stringstream input(waterPcp); | 
|---|
|  | 283 | PcpParser* testParser = new PcpParser(); | 
|---|
|  | 284 | testParser->load(&input); | 
|---|
|  | 285 | input.clear(); | 
|---|
|  | 286 |  | 
|---|
|  | 287 | CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms()); | 
|---|
|  | 288 |  | 
|---|
|  | 289 | string newWaterPcp = ""; | 
|---|
|  | 290 | stringstream output; | 
|---|
|  | 291 | testParser->save(&output); | 
|---|
|  | 292 |  | 
|---|
|  | 293 | input << output; | 
|---|
|  | 294 | PcpParser* testParser2 = new PcpParser(); | 
|---|
|  | 295 | testParser2->load(&input); | 
|---|
|  | 296 |  | 
|---|
|  | 297 | CPPUNIT_ASSERT_EQUAL(6, World::getInstance().numAtoms()); | 
|---|
|  | 298 |  | 
|---|
|  | 299 | CPPUNIT_ASSERT(*testParser == *testParser2); | 
|---|
|  | 300 | } | 
|---|
|  | 301 |  | 
|---|
|  | 302 | void ParserUnitTest::writeMpqcTest() { | 
|---|
|  | 303 | // build up water molecule | 
|---|
|  | 304 | atom *Walker = NULL; | 
|---|
|  | 305 | Walker = World::getInstance().createAtom(); | 
|---|
|  | 306 | Walker->type = World::getInstance().getPeriode()->FindElement(8); | 
|---|
|  | 307 | Walker->x = Vector(0,0,0); | 
|---|
|  | 308 | Walker = World::getInstance().createAtom(); | 
|---|
|  | 309 | Walker->type = World::getInstance().getPeriode()->FindElement(1); | 
|---|
|  | 310 | Walker->x = Vector(0.758602,0,0.504284); | 
|---|
|  | 311 | Walker = World::getInstance().createAtom(); | 
|---|
|  | 312 | Walker->type = World::getInstance().getPeriode()->FindElement(1); | 
|---|
|  | 313 | Walker->x = Vector(0.758602,0,-0.504284); | 
|---|
|  | 314 | CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms()); | 
|---|
|  | 315 |  | 
|---|
|  | 316 | // create two stringstreams, one stored, one created | 
|---|
|  | 317 | stringstream input(waterMpqc); | 
|---|
|  | 318 | MpqcParser* testParser = new MpqcParser(); | 
|---|
|  | 319 | stringstream output; | 
|---|
|  | 320 | testParser->save(&output); | 
|---|
|  | 321 |  | 
|---|
|  | 322 | // compare both configs | 
|---|
| [2fd80b5] | 323 | string first = input.str(); | 
|---|
|  | 324 | string second = output.str(); | 
|---|
|  | 325 | CPPUNIT_ASSERT(first == second); | 
|---|
| [1b2d30] | 326 | } | 
|---|