Changeset 765f16 for src/Parser/unittests
- Timestamp:
- Oct 14, 2011, 3:15:30 PM (13 years ago)
- 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:
- d3d6c6
- Parents:
- 9a6b76e
- git-author:
- Frederik Heber <heber@…> (09/27/11 19:04:36)
- git-committer:
- Frederik Heber <heber@…> (10/14/11 15:15:30)
- Location:
- src/Parser/unittests
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/unittests/ParserMpqcUnitTest.cpp
r9a6b76e r765f16 32 32 #include "Descriptors/AtomTypeDescriptor.hpp" 33 33 #include "CodePatterns/Assert.hpp" 34 #include "Parser/ChangeTracker.hpp" 35 #include "Parser/MpqcParser.hpp" 34 36 35 37 #ifdef HAVE_TESTRUNNER … … 157 159 158 160 void ParserMpqcUnitTest::setUp() { 159 mpqc = new MpqcParser();161 parser = new FormatParser<mpqc>(); 160 162 161 163 World::getInstance(); … … 169 171 170 172 void ParserMpqcUnitTest::tearDown() { 171 delete mpqc;173 delete parser; 172 174 ChangeTracker::purgeInstance(); 173 175 World::purgeInstance(); … … 178 180 void ParserMpqcUnitTest::ParameterTypeTest() { 179 181 // check types in boost::any map 180 CPPUNIT_ASSERT( mpqc->getParams().params[MpqcParser_Parameters::hessianParam].type() == typeid(bool));181 CPPUNIT_ASSERT( mpqc->getParams().params[MpqcParser_Parameters::hessianParam].type() != typeid(int));182 CPPUNIT_ASSERT( mpqc->getParams().params[MpqcParser_Parameters::savestateParam].type() == typeid(bool));183 CPPUNIT_ASSERT( mpqc->getParams().params[MpqcParser_Parameters::do_gradientParam].type() == typeid(bool));184 CPPUNIT_ASSERT( mpqc->getParams().params[MpqcParser_Parameters::maxiterParam].type() == typeid(int));185 CPPUNIT_ASSERT( mpqc->getParams().params[MpqcParser_Parameters::memoryParam].type() == typeid(int));186 CPPUNIT_ASSERT( mpqc->getParams().params[MpqcParser_Parameters::stdapproxParam].type() == typeid(std::string));187 CPPUNIT_ASSERT( mpqc->getParams().params[MpqcParser_Parameters::nfzcParam].type() == typeid(int));188 CPPUNIT_ASSERT( mpqc->getParams().params[MpqcParser_Parameters::basisParam].type() == typeid(std::string));189 CPPUNIT_ASSERT( mpqc->getParams().params[MpqcParser_Parameters::aux_basisParam].type() == typeid(std::string));190 CPPUNIT_ASSERT( mpqc->getParams().params[MpqcParser_Parameters::integrationParam].type() == typeid(MpqcParser_Parameters::IntegralCints));191 CPPUNIT_ASSERT( mpqc->getParams().params[MpqcParser_Parameters::theoryParam].type() == typeid(MpqcParser_Parameters::MBPT2));182 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::hessianParam].type() == typeid(bool)); 183 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::hessianParam].type() != typeid(int)); 184 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::savestateParam].type() == typeid(bool)); 185 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::do_gradientParam].type() == typeid(bool)); 186 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::maxiterParam].type() == typeid(int)); 187 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::memoryParam].type() == typeid(int)); 188 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::stdapproxParam].type() == typeid(std::string)); 189 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::nfzcParam].type() == typeid(int)); 190 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::basisParam].type() == typeid(std::string)); 191 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::aux_basisParam].type() == typeid(std::string)); 192 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::integrationParam].type() == typeid(MpqcParser_Parameters::IntegralCints)); 193 CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::theoryParam].type() == typeid(MpqcParser_Parameters::MBPT2)); 192 194 } 193 195 194 196 void ParserMpqcUnitTest::ParameterDefaultTest() { 195 197 // check default values 196 CPPUNIT_ASSERT( mpqc->getParams().getString(MpqcParser_Parameters::hessianParam) == "no");197 CPPUNIT_ASSERT(! mpqc->getParams().getBool(MpqcParser_Parameters::hessianParam));198 CPPUNIT_ASSERT( mpqc->getParams().getString(MpqcParser_Parameters::savestateParam) == "no");199 CPPUNIT_ASSERT(! mpqc->getParams().getBool(MpqcParser_Parameters::savestateParam));200 CPPUNIT_ASSERT( mpqc->getParams().getString(MpqcParser_Parameters::do_gradientParam) == "yes");201 CPPUNIT_ASSERT( mpqc->getParams().getBool(MpqcParser_Parameters::do_gradientParam));202 CPPUNIT_ASSERT( mpqc->getParams().getInt(MpqcParser_Parameters::maxiterParam) == 1000);203 CPPUNIT_ASSERT( mpqc->getParams().getInt(MpqcParser_Parameters::memoryParam) == 16000000);204 CPPUNIT_ASSERT( mpqc->getParams().getString(MpqcParser_Parameters::stdapproxParam) == "A'");205 CPPUNIT_ASSERT( mpqc->getParams().getInt(MpqcParser_Parameters::nfzcParam) == 1);206 CPPUNIT_ASSERT( mpqc->getParams().getString(MpqcParser_Parameters::basisParam) == "3-21G");207 CPPUNIT_ASSERT( mpqc->getParams().getString(MpqcParser_Parameters::aux_basisParam) == "aug-cc-pVDZ");208 CPPUNIT_ASSERT( mpqc->getParams().getString(MpqcParser_Parameters::integrationParam) == "IntegralCints");209 CPPUNIT_ASSERT( mpqc->getParams().getString(MpqcParser_Parameters::theoryParam) == "MBPT2");210 CPPUNIT_ASSERT( mpqc->getParams().getTheory() == MpqcParser_Parameters::MBPT2);211 CPPUNIT_ASSERT( mpqc->getParams().getIntegration() == MpqcParser_Parameters::IntegralCints);198 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::hessianParam) == "no"); 199 CPPUNIT_ASSERT(!parser->getParams().getBool(MpqcParser_Parameters::hessianParam)); 200 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::savestateParam) == "no"); 201 CPPUNIT_ASSERT(!parser->getParams().getBool(MpqcParser_Parameters::savestateParam)); 202 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::do_gradientParam) == "yes"); 203 CPPUNIT_ASSERT(parser->getParams().getBool(MpqcParser_Parameters::do_gradientParam)); 204 CPPUNIT_ASSERT(parser->getParams().getInt(MpqcParser_Parameters::maxiterParam) == 1000); 205 CPPUNIT_ASSERT(parser->getParams().getInt(MpqcParser_Parameters::memoryParam) == 16000000); 206 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::stdapproxParam) == "A'"); 207 CPPUNIT_ASSERT(parser->getParams().getInt(MpqcParser_Parameters::nfzcParam) == 1); 208 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::basisParam) == "3-21G"); 209 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::aux_basisParam) == "aug-cc-pVDZ"); 210 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::integrationParam) == "IntegralCints"); 211 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::theoryParam) == "MBPT2"); 212 CPPUNIT_ASSERT(parser->getParams().getTheory() == MpqcParser_Parameters::MBPT2); 213 CPPUNIT_ASSERT(parser->getParams().getIntegration() == MpqcParser_Parameters::IntegralCints); 212 214 213 215 // check that values are not removed 214 CPPUNIT_ASSERT(! mpqc->getParams().params[MpqcParser_Parameters::theoryParam].empty());216 CPPUNIT_ASSERT(!parser->getParams().params[MpqcParser_Parameters::theoryParam].empty()); 215 217 216 218 // check throw, for the moment aren't, are caught in getInt() 217 CPPUNIT_ASSERT_THROW( mpqc->getParams().getInt(MpqcParser_Parameters::integrationParam), boost::bad_any_cast);218 CPPUNIT_ASSERT_THROW( mpqc->getParams().getInt(MpqcParser_Parameters::theoryParam), boost::bad_any_cast);219 CPPUNIT_ASSERT_THROW(parser->getParams().getInt(MpqcParser_Parameters::integrationParam), boost::bad_any_cast); 220 CPPUNIT_ASSERT_THROW(parser->getParams().getInt(MpqcParser_Parameters::theoryParam), boost::bad_any_cast); 219 221 220 222 } 221 223 222 224 void ParserMpqcUnitTest::ParameterCloneTest() { 223 FormatParser_Parameters *clone = mpqc->getParams().clone();224 CPPUNIT_ASSERT( mpqc->getParams().getString(MpqcParser_Parameters::theoryParam) == "MBPT2");225 FormatParser_Parameters *clone = parser->getParams().clone(); 226 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::theoryParam) == "MBPT2"); 225 227 std::stringstream setvalue("theory = CLHF"); 226 setvalue >> mpqc->getParams();227 CPPUNIT_ASSERT( mpqc->getParams().getString(MpqcParser_Parameters::theoryParam) == "CLHF");228 mpqc->getParams().makeClone(*clone);229 CPPUNIT_ASSERT( mpqc->getParams().getString(MpqcParser_Parameters::theoryParam) == "MBPT2");228 setvalue >> parser->getParams(); 229 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::theoryParam) == "CLHF"); 230 parser->getParams().makeClone(*clone); 231 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::theoryParam) == "MBPT2"); 230 232 } 231 233 … … 234 236 { 235 237 std::stringstream setvalue("theory = CLHF"); 236 setvalue >> mpqc->getParams();238 setvalue >> parser->getParams(); 237 239 // std::cout << "integration method is " 238 // << mpqc->getParams().getString(MpqcParser_Parameters::theoryParam) << std::endl;239 CPPUNIT_ASSERT( mpqc->getParams().getString(MpqcParser_Parameters::theoryParam) == "CLHF");240 // << parser->getParams().getString(MpqcParser_Parameters::theoryParam) << std::endl; 241 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::theoryParam) == "CLHF"); 240 242 } 241 243 // test a bool 242 244 { 243 245 std::stringstream setvalue("Hessian = yes"); 244 setvalue >> mpqc->getParams();246 setvalue >> parser->getParams(); 245 247 // std::cout << "Hessian is " 246 // << mpqc->getParams().getString(MpqcParser_Parameters::hessianParam) << std::endl;247 CPPUNIT_ASSERT( mpqc->getParams().getString(MpqcParser_Parameters::hessianParam) == "yes");248 // << parser->getParams().getString(MpqcParser_Parameters::hessianParam) << std::endl; 249 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::hessianParam) == "yes"); 248 250 } 249 251 // test int 250 252 { 251 253 std::stringstream setvalue("maxiter = 500"); 252 setvalue >> mpqc->getParams();254 setvalue >> parser->getParams(); 253 255 // std::cout << "maxiter is " 254 // << mpqc->getParams().getString(MpqcParser_Parameters::maxiterParam) << std::endl;255 CPPUNIT_ASSERT( mpqc->getParams().getInt(MpqcParser_Parameters::maxiterParam) == 500);256 // << parser->getParams().getString(MpqcParser_Parameters::maxiterParam) << std::endl; 257 CPPUNIT_ASSERT(parser->getParams().getInt(MpqcParser_Parameters::maxiterParam) == 500); 256 258 } 257 259 // test whether unknown key fails … … 261 263 #ifndef NDEBUG 262 264 ASSERT_DO(Assert::Throw); 263 CPPUNIT_ASSERT_THROW(setvalue >> mpqc->getParams(), Assert::AssertionFailure);265 CPPUNIT_ASSERT_THROW(setvalue >> parser->getParams(), Assert::AssertionFailure); 264 266 #else 265 setvalue >> mpqc->getParams();267 setvalue >> parser->getParams(); 266 268 #endif 267 269 // std::cout << "Hessian is still " 268 // << mpqc->getParams().getString(MpqcParser_Parameters::hessianParam) << std::endl;269 CPPUNIT_ASSERT( mpqc->getParams().getString(MpqcParser_Parameters::hessianParam) == "yes");270 // << parser->getParams().getString(MpqcParser_Parameters::hessianParam) << std::endl; 271 CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::hessianParam) == "yes"); 270 272 } 271 273 } … … 273 275 void ParserMpqcUnitTest::readMpqcTest() { 274 276 stringstream input(waterMpqc_CLHF); 275 mpqc->getParams().setTheory(MpqcParser_Parameters::CLHF);276 mpqc->load(&input);277 parser->getParams().setTheory(MpqcParser_Parameters::CLHF); 278 parser->load(&input); 277 279 278 280 CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms()); … … 301 303 // compare both configs for CLHF 302 304 stringstream output; 303 mpqc->getParams().setTheory(MpqcParser_Parameters::CLHF);304 mpqc->save(&output, atoms);305 parser->getParams().setTheory(MpqcParser_Parameters::CLHF); 306 parser->save(&output, atoms); 305 307 stringstream input(waterMpqc_CLHF); 306 308 for (; std::getline(input, first) && std::getline(output, second); ) { … … 312 314 // compare both configs for CLKS 313 315 stringstream output; 314 mpqc->getParams().setTheory(MpqcParser_Parameters::CLKS);315 mpqc->save(&output, atoms);316 parser->getParams().setTheory(MpqcParser_Parameters::CLKS); 317 parser->save(&output, atoms); 316 318 stringstream input(waterMpqc_CLKS); 317 319 for (; std::getline(input, first) && std::getline(output, second); ) { … … 323 325 // compare both configs for MBPT2 324 326 stringstream output; 325 mpqc->getParams().setTheory(MpqcParser_Parameters::MBPT2);326 mpqc->save(&output, atoms);327 parser->getParams().setTheory(MpqcParser_Parameters::MBPT2); 328 parser->save(&output, atoms); 327 329 stringstream input(waterMpqc_MBPT2); 328 330 for (; std::getline(input, first) && std::getline(output, second); ) { … … 334 336 // compare both configs for MBPT2_R12 335 337 stringstream output; 336 mpqc->getParams().setTheory(MpqcParser_Parameters::MBPT2_R12);337 mpqc->save(&output, atoms);338 parser->getParams().setTheory(MpqcParser_Parameters::MBPT2_R12); 339 parser->save(&output, atoms); 338 340 stringstream input(waterMpqc_MBPT2_R12); 339 341 for (; std::getline(input, first) && std::getline(output, second); ) { -
src/Parser/unittests/ParserMpqcUnitTest.hpp
r9a6b76e r765f16 41 41 42 42 private: 43 MpqcParser *mpqc;43 FormatParser<mpqc> *parser; 44 44 }; 45 45 -
src/Parser/unittests/ParserPcpUnitTest.cpp
r9a6b76e r765f16 24 24 #include <cppunit/ui/text/TestRunner.h> 25 25 26 #include "Parser/PcpParser.hpp"27 26 #include "World.hpp" 28 27 #include "atom.hpp" … … 31 30 #include "CodePatterns/Log.hpp" 32 31 #include "Descriptors/AtomTypeDescriptor.hpp" 32 #include "Parser/ChangeTracker.hpp" 33 #include "Parser/PcpParser.hpp" 33 34 34 35 #ifdef HAVE_TESTRUNNER … … 119 120 World::getInstance(); 120 121 122 parser = new FormatParser<pcp>(); 123 121 124 setVerbosity(2); 122 125 … … 126 129 } 127 130 128 void ParserPcpUnitTest::tearDown() { 131 void ParserPcpUnitTest::tearDown() 132 { 133 delete parser; 129 134 ChangeTracker::purgeInstance(); 130 135 World::purgeInstance(); … … 135 140 void ParserPcpUnitTest::readwritePcpTest() { 136 141 stringstream input(waterPcp); 137 PcpParser* testParser = new PcpParser(); 138 testParser->load(&input); 142 parser->load(&input); 139 143 input.clear(); 140 144 … … 142 146 143 147 // check that equality function is ok 144 CPPUNIT_ASSERT(* testParser == *testParser);148 CPPUNIT_ASSERT(*parser == *parser); 145 149 146 150 stringstream output; 147 151 std::vector<atom *> atoms = World::getInstance().getAllAtoms(); 148 testParser->save(&output, atoms);152 parser->save(&output, atoms); 149 153 150 154 input << output.str(); 151 PcpParser* testParser2 = new PcpParser();152 testParser2->load(&input);155 FormatParser<pcp>* parser2 = new FormatParser<pcp>(); 156 parser2->load(&input); 153 157 154 158 CPPUNIT_ASSERT_EQUAL(6, World::getInstance().numAtoms()); 155 159 156 CPPUNIT_ASSERT(*testParser == *testParser2); 160 CPPUNIT_ASSERT(*parser == *parser2); 161 162 delete parser2; 157 163 } -
src/Parser/unittests/ParserPcpUnitTest.hpp
r9a6b76e r765f16 13 13 #endif 14 14 15 #include "Parser/PcpParser.hpp" 15 16 16 17 #include <cppunit/extensions/HelperMacros.h> … … 28 29 29 30 void readwritePcpTest(); 31 32 private: 33 FormatParser<pcp> *parser; 30 34 }; 31 35 -
src/Parser/unittests/ParserPdbUnitTest.cpp
r9a6b76e r765f16 24 24 #include <cppunit/ui/text/TestRunner.h> 25 25 26 #include "Parser/PdbParser.hpp"27 26 #include "World.hpp" 28 27 #include "atom.hpp" … … 31 30 #include "CodePatterns/Log.hpp" 32 31 #include "Descriptors/AtomTypeDescriptor.hpp" 32 #include "Parser/ChangeTracker.hpp" 33 #include "Parser/PdbParser.hpp" 33 34 34 35 #ifdef HAVE_TESTRUNNER … … 63 64 World::getInstance(); 64 65 66 parser = new FormatParser<pdb>(); 67 65 68 setVerbosity(2); 66 69 … … 70 73 } 71 74 72 void ParserPdbUnitTest::tearDown() { 75 void ParserPdbUnitTest::tearDown() 76 { 77 delete parser; 73 78 ChangeTracker::purgeInstance(); 74 79 World::purgeInstance(); … … 80 85 stringstream input; 81 86 input << waterPdb; 82 PdbParser* testParser = new PdbParser(); 83 testParser->load(&input); 87 parser->load(&input); 84 88 input.clear(); 85 89 … … 88 92 stringstream output; 89 93 std::vector<atom *> atoms = World::getInstance().getAllAtoms(); 90 testParser->save(&output, atoms);94 parser->save(&output, atoms); 91 95 92 96 // std::cout << "Save PDB is:" << std::endl; … … 94 98 95 99 input << output.str(); 96 PdbParser* testParser2 = new PdbParser();97 testParser2->load(&input);100 FormatParser<pdb>* parser2 = new FormatParser<pdb>(); 101 parser2->load(&input); 98 102 99 103 CPPUNIT_ASSERT_EQUAL(12, World::getInstance().numAtoms()); 104 105 delete parser2; 100 106 } -
src/Parser/unittests/ParserPdbUnitTest.hpp
r9a6b76e r765f16 13 13 #endif 14 14 15 #include "Parser/PdbParser.hpp" 15 16 16 17 #include <cppunit/extensions/HelperMacros.h> … … 28 29 29 30 void readwritePdbTest(); 31 32 private: 33 FormatParser<pdb> *parser; 30 34 }; 31 35 -
src/Parser/unittests/ParserTremoloUnitTest.cpp
r9a6b76e r765f16 27 27 #include "Descriptors/AtomTypeDescriptor.hpp" 28 28 #include "element.hpp" 29 #include "Parser/MpqcParser.hpp"30 #include "Parser/PdbParser.hpp"31 #include "Parser/PcpParser.hpp"32 29 #include "Parser/TremoloParser.hpp" 33 #include "Parser/ XyzParser.hpp"30 #include "Parser/ChangeTracker.hpp" 34 31 #include "periodentafel.hpp" 35 32 #include "World.hpp" … … 85 82 World::getInstance(); 86 83 84 parser = new FormatParser<tremolo>(); 85 87 86 // we need hydrogens and oxygens in the following tests 88 87 CPPUNIT_ASSERT(World::getInstance().getPeriode()->FindElement(1) != NULL); … … 90 89 } 91 90 92 void ParserTremoloUnitTest::tearDown() { 91 void ParserTremoloUnitTest::tearDown() 92 { 93 delete parser; 93 94 ChangeTracker::purgeInstance(); 94 95 World::purgeInstance(); … … 99 100 void ParserTremoloUnitTest::readTremoloPreliminaryCommentsTest() { 100 101 cout << "Testing the tremolo parser." << endl; 101 TremoloParser* testParser = new TremoloParser();102 102 stringstream input, output; 103 103 … … 105 105 { 106 106 input << Tremolo_Atomdata1; 107 testParser->load(&input);108 std::vector<atom *> atoms = World::getInstance().getAllAtoms(); 109 testParser->save(&output, atoms);107 parser->load(&input); 108 std::vector<atom *> atoms = World::getInstance().getAllAtoms(); 109 parser->save(&output, atoms); 110 110 // std::cout << output.str() << std::endl; 111 111 // std::cout << Tremolo_Atomdata1 << std::endl; … … 118 118 { 119 119 input << Tremolo_Atomdata2; 120 testParser->load(&input);121 std::vector<atom *> atoms = World::getInstance().getAllAtoms(); 122 testParser->save(&output, atoms);120 parser->load(&input); 121 std::vector<atom *> atoms = World::getInstance().getAllAtoms(); 122 parser->save(&output, atoms); 123 123 std::cout << output.str() << std::endl; 124 124 CPPUNIT_ASSERT(output.str().find("hydrogen") != string::npos); … … 129 129 // Invalid key in Atomdata line 130 130 input << Tremolo_invalidkey; 131 testParser->load(&input);131 parser->load(&input); 132 132 //TODO: prove invalidity 133 133 input.clear(); … … 135 135 136 136 void ParserTremoloUnitTest::readTremoloCoordinatesTest() { 137 TremoloParser* testParser = new TremoloParser();138 137 stringstream input; 139 138 140 139 // One simple data line 141 140 input << Tremolo_Atomdata2; 142 testParser->load(&input);141 parser->load(&input); 143 142 CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->at(0) == 3.0); 144 143 input.clear(); … … 146 145 147 146 void ParserTremoloUnitTest::readTremoloVelocityTest() { 148 TremoloParser* testParser = new TremoloParser();149 147 stringstream input; 150 148 151 149 // One simple data line 152 150 input << Tremolo_velocity; 153 testParser->load(&input);151 parser->load(&input); 154 152 CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->getAtomicVelocity()[0] == 3.0); 155 153 input.clear(); … … 157 155 158 156 void ParserTremoloUnitTest::readTremoloNeighborInformationTest() { 159 TremoloParser* testParser = new TremoloParser();160 157 stringstream input; 161 158 162 159 // Neighbor data 163 160 input << Tremolo_neighbours; 164 testParser->load(&input);161 parser->load(&input); 165 162 166 163 CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms()); … … 171 168 172 169 void ParserTremoloUnitTest::readAndWriteTremoloImprDataInformationTest() { 173 TremoloParser* testParser = new TremoloParser();174 170 stringstream input, output; 175 171 … … 177 173 { 178 174 input << Tremolo_improper; 179 testParser->load(&input);180 std::vector<atom *> atoms = World::getInstance().getAllAtoms(); 181 testParser->save(&output, atoms);175 parser->load(&input); 176 std::vector<atom *> atoms = World::getInstance().getAllAtoms(); 177 parser->save(&output, atoms); 182 178 CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms()); 183 179 std::cout << output.str() << std::endl; … … 189 185 190 186 void ParserTremoloUnitTest::readAndWriteTremoloTorsionInformationTest() { 191 TremoloParser* testParser = new TremoloParser();192 187 stringstream input, output; 193 188 … … 195 190 { 196 191 input << Tremolo_torsion; 197 testParser->load(&input);198 std::vector<atom *> atoms = World::getInstance().getAllAtoms(); 199 testParser->save(&output, atoms);192 parser->load(&input); 193 std::vector<atom *> atoms = World::getInstance().getAllAtoms(); 194 parser->save(&output, atoms); 200 195 CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms()); 201 196 std::cout << output.str() << std::endl; … … 207 202 208 203 void ParserTremoloUnitTest::writeTremoloTest() { 209 TremoloParser* testParser = new TremoloParser();210 204 stringstream output; 211 205 … … 214 208 atom* newAtom = World::getInstance().createAtom(); 215 209 newAtom->setType(1); 216 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");217 std::vector<atom *> atoms = World::getInstance().getAllAtoms(); 218 testParser->save(&output, atoms);210 parser->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"); 211 std::vector<atom *> atoms = World::getInstance().getAllAtoms(); 212 parser->save(&output, atoms); 219 213 CPPUNIT_ASSERT(output.str() == Tremolo_full); 220 214 } … … 222 216 cout << "testing the tremolo parser is done" << endl; 223 217 } 218 -
src/Parser/unittests/ParserTremoloUnitTest.hpp
r9a6b76e r765f16 13 13 #endif 14 14 15 #include "Parser/TremoloParser.hpp" 15 16 16 17 #include <cppunit/extensions/HelperMacros.h> … … 40 41 void readAndWriteTremoloTorsionInformationTest(); 41 42 void writeTremoloTest(); 43 44 private: 45 FormatParser<tremolo> *parser; 42 46 }; 43 47 -
src/Parser/unittests/ParserXyzUnitTest.cpp
r9a6b76e r765f16 24 24 #include <cppunit/ui/text/TestRunner.h> 25 25 26 #include "Parser/XyzParser.hpp"27 26 #include "World.hpp" 28 27 #include "atom.hpp" … … 31 30 #include "CodePatterns/Log.hpp" 32 31 #include "Descriptors/AtomTypeDescriptor.hpp" 32 #include "Parser/ChangeTracker.hpp" 33 #include "Parser/XyzParser.hpp" 33 34 34 35 #ifdef HAVE_TESTRUNNER … … 62 63 World::getInstance(); 63 64 65 parser = new FormatParser<xyz>(); 66 64 67 setVerbosity(2); 65 68 … … 69 72 } 70 73 71 void ParserXyzUnitTest::tearDown() { 74 void ParserXyzUnitTest::tearDown() 75 { 76 delete parser; 72 77 ChangeTracker::purgeInstance(); 73 78 World::purgeInstance(); … … 78 83 void ParserXyzUnitTest::rewriteAnXyzTest() { 79 84 cout << "Testing the XYZ parser." << endl; 80 XyzParser* testParser = new XyzParser();81 85 stringstream input; 82 86 input << waterXyz; 83 testParser->load(&input);87 parser->load(&input); 84 88 input.clear(); 85 89 … … 90 94 stringstream output; 91 95 std::vector<atom *> atoms = World::getInstance().getAllAtoms(); 92 testParser->save(&output, atoms);96 parser->save(&output, atoms); 93 97 input << output.str(); 94 testParser->load(&input);98 parser->load(&input); 95 99 } 96 100 … … 115 119 void ParserXyzUnitTest::readMultiXyzTest() { 116 120 cout << "Testing the multi time step XYZ parser." << endl; 117 XyzParser* testParser = new XyzParser();118 121 stringstream input; 119 122 input << waterMultiXyz; 120 testParser->load(&input);123 parser->load(&input); 121 124 input.clear(); 122 125 … … 130 133 131 134 void ParserXyzUnitTest::writeMultiXyzTest() { 132 XyzParser* testParser = new XyzParser();133 135 stringstream input; 134 136 input << waterMultiXyz; 135 testParser->load(&input);137 parser->load(&input); 136 138 input.clear(); 137 139 … … 143 145 stringstream output; 144 146 std::vector<atom *> atoms = World::getInstance().getAllAtoms(); 145 testParser->save(&output, atoms);147 parser->save(&output, atoms); 146 148 input << output.str(); 147 testParser->load(&input);149 parser->load(&input); 148 150 } 149 151 -
src/Parser/unittests/ParserXyzUnitTest.hpp
r9a6b76e r765f16 13 13 #endif 14 14 15 #include "Parser/XyzParser.hpp" 15 16 16 17 #include <cppunit/extensions/HelperMacros.h> … … 32 33 void readMultiXyzTest(); 33 34 void writeMultiXyzTest(); 35 36 private: 37 FormatParser<xyz> *parser; 34 38 }; 35 39
Note:
See TracChangeset
for help on using the changeset viewer.