| [9e4fd1] | 1 | /* | 
|---|
|  | 2 | * Project: MoleCuilder | 
|---|
|  | 3 | * Description: creates and alters molecular systems | 
|---|
| [0aa122] | 4 | * Copyright (C)  2010-2012 University of Bonn. All rights reserved. | 
|---|
| [94d5ac6] | 5 | * | 
|---|
|  | 6 | * | 
|---|
|  | 7 | *   This file is part of MoleCuilder. | 
|---|
|  | 8 | * | 
|---|
|  | 9 | *    MoleCuilder is free software: you can redistribute it and/or modify | 
|---|
|  | 10 | *    it under the terms of the GNU General Public License as published by | 
|---|
|  | 11 | *    the Free Software Foundation, either version 2 of the License, or | 
|---|
|  | 12 | *    (at your option) any later version. | 
|---|
|  | 13 | * | 
|---|
|  | 14 | *    MoleCuilder is distributed in the hope that it will be useful, | 
|---|
|  | 15 | *    but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
|  | 16 | *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
|  | 17 | *    GNU General Public License for more details. | 
|---|
|  | 18 | * | 
|---|
|  | 19 | *    You should have received a copy of the GNU General Public License | 
|---|
|  | 20 | *    along with MoleCuilder.  If not, see <http://www.gnu.org/licenses/>. | 
|---|
| [9e4fd1] | 21 | */ | 
|---|
|  | 22 |  | 
|---|
|  | 23 | /* | 
|---|
|  | 24 | * ParserMpqcUnitTest.cpp | 
|---|
|  | 25 | * | 
|---|
|  | 26 | *  Created on: Mar 3, 2010 | 
|---|
|  | 27 | *      Author: metzler | 
|---|
|  | 28 | */ | 
|---|
|  | 29 |  | 
|---|
|  | 30 | // include config.h | 
|---|
|  | 31 | #ifdef HAVE_CONFIG_H | 
|---|
|  | 32 | #include <config.h> | 
|---|
|  | 33 | #endif | 
|---|
|  | 34 |  | 
|---|
|  | 35 | #include "ParserMpqcUnitTest.hpp" | 
|---|
|  | 36 |  | 
|---|
|  | 37 | #include <cppunit/CompilerOutputter.h> | 
|---|
|  | 38 | #include <cppunit/extensions/TestFactoryRegistry.h> | 
|---|
|  | 39 | #include <cppunit/ui/text/TestRunner.h> | 
|---|
|  | 40 |  | 
|---|
| [61d69a4] | 41 | #include <boost/any.hpp> | 
|---|
|  | 42 |  | 
|---|
| [6f0841] | 43 | #include "Atom/atom.hpp" | 
|---|
| [006e1e] | 44 | #include "Atom/AtomObserver.hpp" | 
|---|
|  | 45 | #include "CodePatterns/Assert.hpp" | 
|---|
|  | 46 | #include "Descriptors/AtomTypeDescriptor.hpp" | 
|---|
| [3bdb6d] | 47 | #include "Element/element.hpp" | 
|---|
|  | 48 | #include "Element/periodentafel.hpp" | 
|---|
| [765f16] | 49 | #include "Parser/ChangeTracker.hpp" | 
|---|
|  | 50 | #include "Parser/MpqcParser.hpp" | 
|---|
| [006e1e] | 51 | #include "World.hpp" | 
|---|
| [9e4fd1] | 52 |  | 
|---|
|  | 53 | #ifdef HAVE_TESTRUNNER | 
|---|
|  | 54 | #include "UnitTestMain.hpp" | 
|---|
|  | 55 | #endif /*HAVE_TESTRUNNER*/ | 
|---|
|  | 56 |  | 
|---|
|  | 57 | using namespace std; | 
|---|
|  | 58 |  | 
|---|
|  | 59 | // Registers the fixture into the 'registry' | 
|---|
|  | 60 | CPPUNIT_TEST_SUITE_REGISTRATION( ParserMpqcUnitTest ); | 
|---|
|  | 61 |  | 
|---|
| [f31edc] | 62 | static string waterMpqc_CLHF ="% Created by MoleCuilder\n\ | 
|---|
|  | 63 | mpqc: (\n\ | 
|---|
|  | 64 | \tsavestate = no\n\ | 
|---|
|  | 65 | \tdo_gradient = yes\n\ | 
|---|
|  | 66 | \tmole<CLHF>: (\n\ | 
|---|
|  | 67 | \t\tmolecule = $:molecule\n\ | 
|---|
|  | 68 | \t\tbasis = $:basis\n\ | 
|---|
| [61d69a4] | 69 | \t\tmaxiter = 1000\n\ | 
|---|
| [f31edc] | 70 | \t\tmemory = 16000000\n\ | 
|---|
|  | 71 | \t)\n\ | 
|---|
|  | 72 | )\n\ | 
|---|
|  | 73 | molecule<Molecule>: (\n\ | 
|---|
|  | 74 | \tunit = angstrom\n\ | 
|---|
|  | 75 | \t{ atoms geometry } = {\n\ | 
|---|
| [e9dc19] | 76 | \t\tO [ 0\t0\t0 ]\n\ | 
|---|
|  | 77 | \t\tH [ 0.758602\t0\t0.504284 ]\n\ | 
|---|
|  | 78 | \t\tH [ 0.758602\t0\t-0.504284 ]\n\ | 
|---|
| [f31edc] | 79 | \t}\n\ | 
|---|
|  | 80 | )\n\ | 
|---|
|  | 81 | basis<GaussianBasisSet>: (\n\ | 
|---|
|  | 82 | \tname = \"3-21G\"\n\ | 
|---|
|  | 83 | \tmolecule = $:molecule\n\ | 
|---|
|  | 84 | )\n"; // tested with mpqc 3.0.0-alpha | 
|---|
|  | 85 | static string waterMpqc_CLKS ="% Created by MoleCuilder\n\ | 
|---|
|  | 86 | mpqc: (\n\ | 
|---|
|  | 87 | \tsavestate = no\n\ | 
|---|
|  | 88 | \tdo_gradient = yes\n\ | 
|---|
|  | 89 | \tmole<CLKS>: (\n\ | 
|---|
|  | 90 | \t\tfunctional<StdDenFunctional>:(name=B3LYP)\n\ | 
|---|
|  | 91 | \t\tmolecule = $:molecule\n\ | 
|---|
|  | 92 | \t\tbasis = $:basis\n\ | 
|---|
| [61d69a4] | 93 | \t\tmaxiter = 1000\n\ | 
|---|
| [f31edc] | 94 | \t\tmemory = 16000000\n\ | 
|---|
|  | 95 | \t)\n\ | 
|---|
|  | 96 | )\n\ | 
|---|
|  | 97 | molecule<Molecule>: (\n\ | 
|---|
|  | 98 | \tunit = angstrom\n\ | 
|---|
|  | 99 | \t{ atoms geometry } = {\n\ | 
|---|
| [e9dc19] | 100 | \t\tO [ 0\t0\t0 ]\n\ | 
|---|
|  | 101 | \t\tH [ 0.758602\t0\t0.504284 ]\n\ | 
|---|
|  | 102 | \t\tH [ 0.758602\t0\t-0.504284 ]\n\ | 
|---|
| [f31edc] | 103 | \t}\n\ | 
|---|
|  | 104 | )\n\ | 
|---|
|  | 105 | basis<GaussianBasisSet>: (\n\ | 
|---|
|  | 106 | \tname = \"3-21G\"\n\ | 
|---|
|  | 107 | \tmolecule = $:molecule\n\ | 
|---|
|  | 108 | )\n"; // tested with mpqc 3.0.0-alpha | 
|---|
|  | 109 | static string waterMpqc_MBPT2 ="% Created by MoleCuilder\n\ | 
|---|
| [9e4fd1] | 110 | mpqc: (\n\ | 
|---|
|  | 111 | \tsavestate = no\n\ | 
|---|
|  | 112 | \tdo_gradient = yes\n\ | 
|---|
|  | 113 | \tmole<MBPT2>: (\n\ | 
|---|
|  | 114 | \t\tbasis = $:basis\n\ | 
|---|
|  | 115 | \t\tmolecule = $:molecule\n\ | 
|---|
| [61d69a4] | 116 | \t\tmemory = 16000000\n\ | 
|---|
| [9e4fd1] | 117 | \t\treference<CLHF>: (\n\ | 
|---|
| [bb74ba] | 118 | \t\t\tmaxiter = 1000\n\ | 
|---|
| [9e4fd1] | 119 | \t\t\tbasis = $:basis\n\ | 
|---|
|  | 120 | \t\t\tmolecule = $:molecule\n\ | 
|---|
| [61d69a4] | 121 | \t\t\tmemory = 16000000\n\ | 
|---|
| [9e4fd1] | 122 | \t\t)\n\ | 
|---|
|  | 123 | \t)\n\ | 
|---|
|  | 124 | )\n\ | 
|---|
|  | 125 | molecule<Molecule>: (\n\ | 
|---|
|  | 126 | \tunit = angstrom\n\ | 
|---|
|  | 127 | \t{ atoms geometry } = {\n\ | 
|---|
| [e9dc19] | 128 | \t\tO [ 0\t0\t0 ]\n\ | 
|---|
|  | 129 | \t\tH [ 0.758602\t0\t0.504284 ]\n\ | 
|---|
|  | 130 | \t\tH [ 0.758602\t0\t-0.504284 ]\n\ | 
|---|
| [9e4fd1] | 131 | \t}\n\ | 
|---|
|  | 132 | )\n\ | 
|---|
|  | 133 | basis<GaussianBasisSet>: (\n\ | 
|---|
|  | 134 | \tname = \"3-21G\"\n\ | 
|---|
|  | 135 | \tmolecule = $:molecule\n\ | 
|---|
| [f31edc] | 136 | )\n"; // tested with mpqc 3.0.0-alpha | 
|---|
|  | 137 | static string waterMpqc_MBPT2_R12 ="% Created by MoleCuilder\n\ | 
|---|
|  | 138 | mpqc: (\n\ | 
|---|
|  | 139 | \tsavestate = no\n\ | 
|---|
|  | 140 | \tdo_gradient = yes\n\ | 
|---|
|  | 141 | \tmole<MBPT2_R12>: (\n\ | 
|---|
|  | 142 | \t\tmolecule = $:molecule\n\ | 
|---|
|  | 143 | \t\tbasis = $:basis\n\ | 
|---|
|  | 144 | \t\taux_basis = $:abasis\n\ | 
|---|
|  | 145 | \t\tstdapprox = \"A'\"\n\ | 
|---|
|  | 146 | \t\tnfzc = 1\n\ | 
|---|
|  | 147 | \t\tmemory = 16000000\n\ | 
|---|
|  | 148 | \t\tintegrals<IntegralCints>:()\n\ | 
|---|
|  | 149 | \t\treference<CLHF>: (\n\ | 
|---|
|  | 150 | \t\t\tmolecule = $:molecule\n\ | 
|---|
|  | 151 | \t\t\tbasis = $:basis\n\ | 
|---|
|  | 152 | \t\t\tmaxiter = 1000\n\ | 
|---|
|  | 153 | \t\t\tmemory = 16000000\n\ | 
|---|
|  | 154 | \t\t\tintegrals<IntegralCints>:()\n\ | 
|---|
|  | 155 | \t\t)\n\ | 
|---|
|  | 156 | \t)\n\ | 
|---|
|  | 157 | )\n\ | 
|---|
|  | 158 | molecule<Molecule>: (\n\ | 
|---|
|  | 159 | \tunit = angstrom\n\ | 
|---|
|  | 160 | \t{ atoms geometry } = {\n\ | 
|---|
| [e9dc19] | 161 | \t\tO [ 0\t0\t0 ]\n\ | 
|---|
|  | 162 | \t\tH [ 0.758602\t0\t0.504284 ]\n\ | 
|---|
|  | 163 | \t\tH [ 0.758602\t0\t-0.504284 ]\n\ | 
|---|
| [f31edc] | 164 | \t}\n\ | 
|---|
|  | 165 | )\n\ | 
|---|
|  | 166 | basis<GaussianBasisSet>: (\n\ | 
|---|
|  | 167 | \tname = \"3-21G\"\n\ | 
|---|
|  | 168 | \tmolecule = $:molecule\n\ | 
|---|
|  | 169 | )\n\ | 
|---|
|  | 170 | % auxiliary basis set specification\n\ | 
|---|
|  | 171 | \tabasis<GaussianBasisSet>: (\n\ | 
|---|
|  | 172 | \tname = \"aug-cc-pVDZ\"\n\ | 
|---|
|  | 173 | \tmolecule = $:molecule\n\ | 
|---|
|  | 174 | )\n"; // basically tested with mpqc 3.0.0-alpha (no parse errors but did not calculate due to missing code) | 
|---|
| [9e4fd1] | 175 |  | 
|---|
| [3308b6] | 176 | void ParserMpqcUnitTest::setUp() | 
|---|
|  | 177 | { | 
|---|
|  | 178 | // failing asserts should be thrown | 
|---|
|  | 179 | ASSERT_DO(Assert::Throw); | 
|---|
|  | 180 |  | 
|---|
| [765f16] | 181 | parser = new FormatParser<mpqc>(); | 
|---|
| [61d69a4] | 182 |  | 
|---|
| [9e4fd1] | 183 | World::getInstance(); | 
|---|
|  | 184 |  | 
|---|
|  | 185 | setVerbosity(2); | 
|---|
|  | 186 |  | 
|---|
|  | 187 | // we need hydrogens and oxygens in the following tests | 
|---|
|  | 188 | CPPUNIT_ASSERT(World::getInstance().getPeriode()->FindElement(1) != NULL); | 
|---|
|  | 189 | CPPUNIT_ASSERT(World::getInstance().getPeriode()->FindElement(8) != NULL); | 
|---|
|  | 190 | } | 
|---|
|  | 191 |  | 
|---|
| [3308b6] | 192 | void ParserMpqcUnitTest::tearDown() | 
|---|
|  | 193 | { | 
|---|
| [765f16] | 194 | delete parser; | 
|---|
| [9e4fd1] | 195 | ChangeTracker::purgeInstance(); | 
|---|
|  | 196 | World::purgeInstance(); | 
|---|
| [708277] | 197 | AtomObserver::purgeInstance(); | 
|---|
| [9e4fd1] | 198 | } | 
|---|
|  | 199 |  | 
|---|
|  | 200 | /************************************ tests ***********************************/ | 
|---|
|  | 201 |  | 
|---|
| [61d69a4] | 202 | void ParserMpqcUnitTest::ParameterDefaultTest() { | 
|---|
|  | 203 | // check default values | 
|---|
| [ee50c1] | 204 | CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::hessianParam) == std::string("no")); | 
|---|
|  | 205 | CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::savestateParam) == std::string("no")); | 
|---|
|  | 206 | CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::do_gradientParam) == std::string("yes")); | 
|---|
|  | 207 | CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::maxiterParam) == std::string("1000")); | 
|---|
|  | 208 | CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::memoryParam) == std::string("16000000")); | 
|---|
|  | 209 | CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::stdapproxParam) == std::string("A'")); | 
|---|
|  | 210 | CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::nfzcParam) == std::string("1")); | 
|---|
|  | 211 | CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::basisParam) == std::string("3-21G")); | 
|---|
|  | 212 | CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::aux_basisParam) == std::string("aug-cc-pVDZ")); | 
|---|
|  | 213 | CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::integrationParam) == std::string("IntegralCints")); | 
|---|
|  | 214 | CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::theoryParam) == std::string("MBPT2")); | 
|---|
| [61d69a4] | 215 | } | 
|---|
|  | 216 |  | 
|---|
| [c1db05] | 217 | void ParserMpqcUnitTest::ParameterCloneTest() { | 
|---|
| [765f16] | 218 | FormatParser_Parameters *clone = parser->getParams().clone(); | 
|---|
| [ee50c1] | 219 | CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::theoryParam) == std::string("MBPT2")); | 
|---|
| [c1db05] | 220 | std::stringstream setvalue("theory = CLHF"); | 
|---|
| [765f16] | 221 | setvalue >> parser->getParams(); | 
|---|
| [ee50c1] | 222 | CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::theoryParam) == std::string("CLHF")); | 
|---|
| [765f16] | 223 | parser->getParams().makeClone(*clone); | 
|---|
| [ee50c1] | 224 | CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::theoryParam) == std::string("MBPT2")); | 
|---|
| [c1db05] | 225 | } | 
|---|
|  | 226 |  | 
|---|
| [44fce5] | 227 | void ParserMpqcUnitTest::ParameterSetterTest() { | 
|---|
|  | 228 | // test a string | 
|---|
|  | 229 | { | 
|---|
|  | 230 | std::stringstream setvalue("theory = CLHF"); | 
|---|
| [765f16] | 231 | setvalue >> parser->getParams(); | 
|---|
| [44fce5] | 232 | //    std::cout << "integration method is " | 
|---|
| [765f16] | 233 | //        << parser->getParams().getString(MpqcParser_Parameters::theoryParam) << std::endl; | 
|---|
| [ee50c1] | 234 | CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::theoryParam) == std::string("CLHF")); | 
|---|
| [44fce5] | 235 | } | 
|---|
|  | 236 | // test a bool | 
|---|
|  | 237 | { | 
|---|
|  | 238 | std::stringstream setvalue("Hessian = yes"); | 
|---|
| [765f16] | 239 | setvalue >> parser->getParams(); | 
|---|
| [44fce5] | 240 | //    std::cout << "Hessian is " | 
|---|
| [765f16] | 241 | //        << parser->getParams().getString(MpqcParser_Parameters::hessianParam) << std::endl; | 
|---|
| [ee50c1] | 242 | CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::hessianParam) == std::string("yes")); | 
|---|
| [44fce5] | 243 | } | 
|---|
|  | 244 | // test int | 
|---|
|  | 245 | { | 
|---|
|  | 246 | std::stringstream setvalue("maxiter = 500"); | 
|---|
| [765f16] | 247 | setvalue >> parser->getParams(); | 
|---|
| [44fce5] | 248 | //    std::cout << "maxiter is " | 
|---|
| [765f16] | 249 | //        << parser->getParams().getString(MpqcParser_Parameters::maxiterParam) << std::endl; | 
|---|
| [ee50c1] | 250 | CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::maxiterParam) == std::string("500")); | 
|---|
| [44fce5] | 251 | } | 
|---|
|  | 252 | // test whether unknown key fails | 
|---|
| [311da7b] | 253 | std::cout << "The following Assertion warning is desired and does not indicate a failure of the test." << std::endl; | 
|---|
| [44fce5] | 254 | { | 
|---|
|  | 255 | std::stringstream setvalue("hessian = no"); | 
|---|
| [311da7b] | 256 | #ifndef NDEBUG | 
|---|
|  | 257 | ASSERT_DO(Assert::Throw); | 
|---|
| [765f16] | 258 | CPPUNIT_ASSERT_THROW(setvalue >> parser->getParams(), Assert::AssertionFailure); | 
|---|
| [311da7b] | 259 | #else | 
|---|
| [765f16] | 260 | setvalue >> parser->getParams(); | 
|---|
| [311da7b] | 261 | #endif | 
|---|
| [44fce5] | 262 | //    std::cout << "Hessian is still " | 
|---|
| [765f16] | 263 | //        << parser->getParams().getString(MpqcParser_Parameters::hessianParam) << std::endl; | 
|---|
| [ee50c1] | 264 | CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::hessianParam) == std::string("yes")); | 
|---|
| [44fce5] | 265 | } | 
|---|
|  | 266 | } | 
|---|
|  | 267 |  | 
|---|
| [aa8ef2] | 268 | void ParserMpqcUnitTest::readMpqcTest() { | 
|---|
|  | 269 | stringstream input(waterMpqc_CLHF); | 
|---|
| [ee50c1] | 270 | parser->getParams().setParameter( | 
|---|
|  | 271 | MpqcParser_Parameters::theoryParam, | 
|---|
|  | 272 | parser->getParams().getTheoryName(MpqcParser_Parameters::CLHF) | 
|---|
|  | 273 | ); | 
|---|
| [765f16] | 274 | parser->load(&input); | 
|---|
| [aa8ef2] | 275 |  | 
|---|
|  | 276 | CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms()); | 
|---|
|  | 277 | } | 
|---|
|  | 278 |  | 
|---|
| [9e4fd1] | 279 | void ParserMpqcUnitTest::writeMpqcTest() { | 
|---|
|  | 280 | // build up water molecule | 
|---|
| [f31edc] | 281 | string first; | 
|---|
|  | 282 | string second; | 
|---|
| [9e4fd1] | 283 | atom *Walker = NULL; | 
|---|
|  | 284 | Walker = World::getInstance().createAtom(); | 
|---|
|  | 285 | Walker->setType(8); | 
|---|
|  | 286 | Walker->setPosition(Vector(0,0,0)); | 
|---|
|  | 287 | Walker = World::getInstance().createAtom(); | 
|---|
|  | 288 | Walker->setType(1); | 
|---|
|  | 289 | Walker->setPosition(Vector(0.758602,0,0.504284)); | 
|---|
|  | 290 | Walker = World::getInstance().createAtom(); | 
|---|
|  | 291 | Walker->setType(1); | 
|---|
|  | 292 | Walker->setPosition(Vector(0.758602,0,-0.504284)); | 
|---|
|  | 293 | CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms()); | 
|---|
|  | 294 |  | 
|---|
|  | 295 | // create two stringstreams, one stored, one created | 
|---|
| [f31edc] | 296 |  | 
|---|
| [9e4fd1] | 297 | std::vector<atom *> atoms = World::getInstance().getAllAtoms(); | 
|---|
| [f31edc] | 298 | { | 
|---|
|  | 299 | // compare both configs for CLHF | 
|---|
|  | 300 | stringstream output; | 
|---|
| [ee50c1] | 301 | parser->getParams().setParameter( | 
|---|
|  | 302 | MpqcParser_Parameters::theoryParam, | 
|---|
|  | 303 | parser->getParams().getTheoryName(MpqcParser_Parameters::CLHF) | 
|---|
|  | 304 | ); | 
|---|
| [765f16] | 305 | parser->save(&output, atoms); | 
|---|
| [f31edc] | 306 | stringstream input(waterMpqc_CLHF); | 
|---|
| [120a86] | 307 | // check for non-empty streams | 
|---|
|  | 308 | input.peek(); | 
|---|
|  | 309 | output.peek(); | 
|---|
|  | 310 | CPPUNIT_ASSERT(input.good() && output.good()); | 
|---|
|  | 311 | // check equality of streams per line (for debugging) | 
|---|
| [f31edc] | 312 | for (; std::getline(input, first) && std::getline(output, second); ) { | 
|---|
|  | 313 | //std::cout << "Comparing '" << first << "' to '" << second << "'" << std::endl; | 
|---|
|  | 314 | CPPUNIT_ASSERT(first == second); | 
|---|
|  | 315 | } | 
|---|
|  | 316 | } | 
|---|
|  | 317 | { | 
|---|
|  | 318 | // compare both configs for CLKS | 
|---|
|  | 319 | stringstream output; | 
|---|
| [ee50c1] | 320 | parser->getParams().setParameter( | 
|---|
|  | 321 | MpqcParser_Parameters::theoryParam, | 
|---|
|  | 322 | parser->getParams().getTheoryName(MpqcParser_Parameters::CLKS) | 
|---|
|  | 323 | ); | 
|---|
| [120a86] | 324 | parser->save(&output, atoms); | 
|---|
| [f31edc] | 325 | stringstream input(waterMpqc_CLKS); | 
|---|
| [120a86] | 326 | // check for non-empty streams | 
|---|
|  | 327 | input.peek(); | 
|---|
|  | 328 | output.peek(); | 
|---|
|  | 329 | CPPUNIT_ASSERT(input.good() && output.good()); | 
|---|
|  | 330 | // check equality of streams per line (for debugging) | 
|---|
| [f31edc] | 331 | for (; std::getline(input, first) && std::getline(output, second); ) { | 
|---|
|  | 332 | //std::cout << "Comparing '" << first << "' to '" << second << "'" << std::endl; | 
|---|
|  | 333 | CPPUNIT_ASSERT(first == second); | 
|---|
|  | 334 | } | 
|---|
|  | 335 | } | 
|---|
|  | 336 | { | 
|---|
|  | 337 | // compare both configs for MBPT2 | 
|---|
|  | 338 | stringstream output; | 
|---|
| [ee50c1] | 339 | parser->getParams().setParameter( | 
|---|
|  | 340 | MpqcParser_Parameters::theoryParam, | 
|---|
|  | 341 | parser->getParams().getTheoryName(MpqcParser_Parameters::MBPT2) | 
|---|
|  | 342 | ); | 
|---|
| [120a86] | 343 | parser->save(&output, atoms); | 
|---|
| [f31edc] | 344 | stringstream input(waterMpqc_MBPT2); | 
|---|
| [120a86] | 345 | // check for non-empty streams | 
|---|
|  | 346 | input.peek(); | 
|---|
|  | 347 | output.peek(); | 
|---|
|  | 348 | CPPUNIT_ASSERT(input.good() && output.good()); | 
|---|
|  | 349 | // check equality of streams per line (for debugging) | 
|---|
| [f31edc] | 350 | for (; std::getline(input, first) && std::getline(output, second); ) { | 
|---|
|  | 351 | //std::cout << "Comparing '" << first << "' to '" << second << "'" << std::endl; | 
|---|
|  | 352 | CPPUNIT_ASSERT(first == second); | 
|---|
|  | 353 | } | 
|---|
|  | 354 | } | 
|---|
|  | 355 | { | 
|---|
|  | 356 | // compare both configs for MBPT2_R12 | 
|---|
|  | 357 | stringstream output; | 
|---|
| [ee50c1] | 358 | parser->getParams().setParameter( | 
|---|
|  | 359 | MpqcParser_Parameters::theoryParam, | 
|---|
|  | 360 | parser->getParams().getTheoryName(MpqcParser_Parameters::MBPT2_R12) | 
|---|
|  | 361 | ); | 
|---|
| [120a86] | 362 | parser->save(&output, atoms); | 
|---|
| [f31edc] | 363 | stringstream input(waterMpqc_MBPT2_R12); | 
|---|
| [120a86] | 364 | // check for non-empty streams | 
|---|
|  | 365 | input.peek(); | 
|---|
|  | 366 | output.peek(); | 
|---|
|  | 367 | CPPUNIT_ASSERT(input.good() && output.good()); | 
|---|
|  | 368 | // check equality of streams per line (for debugging) | 
|---|
| [f31edc] | 369 | for (; std::getline(input, first) && std::getline(output, second); ) { | 
|---|
|  | 370 | //std::cout << "Comparing '" << first << "' to '" << second << "'" << std::endl; | 
|---|
|  | 371 | CPPUNIT_ASSERT(first == second); | 
|---|
|  | 372 | } | 
|---|
|  | 373 | } | 
|---|
| [9e4fd1] | 374 | } | 
|---|