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