Changeset 9e4fd1 for src/Parser
- Timestamp:
- Feb 7, 2011, 10:25:52 AM (14 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:
- bb74ba
- Parents:
- 881c05
- git-author:
- Frederik Heber <heber@…> (02/02/11 19:38:08)
- git-committer:
- Frederik Heber <heber@…> (02/07/11 10:25:52)
- Location:
- src/Parser/unittests
- Files:
-
- 7 added
- 1 deleted
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/unittests/Makefile.am
r881c05 r9e4fd1 8 8 9 9 TESTS = \ 10 ParserCommonUnitTest \ 11 ParserTremoloUnitTest 10 ParserMpqcUnitTest \ 11 ParserPcpUnitTest \ 12 ParserPdbUnitTest \ 13 ParserTremoloUnitTest \ 14 ParserXyzUnitTest 12 15 13 16 … … 34 37 UILIBS = ../../UIElements/libMolecuilderUI.la 35 38 36 ParserCommonUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \ 37 ParserCommonUnitTest.cpp \ 38 ParserCommonUnitTest.hpp 39 ParserCommonUnitTest_LDADD = ${ALLLIBS} 39 ParserMpqcUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \ 40 ParserMpqcUnitTest.cpp \ 41 ParserMpqcUnitTest.hpp 42 ParserMpqcUnitTest_LDADD = ${ALLLIBS} 43 44 ParserPcpUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \ 45 ParserPcpUnitTest.cpp \ 46 ParserPcpUnitTest.hpp 47 ParserPcpUnitTest_LDADD = ${ALLLIBS} 48 49 ParserPdbUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \ 50 ParserPdbUnitTest.cpp \ 51 ParserPdbUnitTest.hpp 52 ParserPdbUnitTest_LDADD = ${ALLLIBS} 40 53 41 54 ParserTremoloUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \ … … 44 57 ParserTremoloUnitTest_LDADD = ${ALLLIBS} 45 58 59 ParserXyzUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \ 60 ParserXyzUnitTest.cpp \ 61 ParserXyzUnitTest.hpp 62 ParserXyzUnitTest_LDADD = ${ALLLIBS} 63 46 64 47 65 #AUTOMAKE_OPTIONS = parallel-tests -
src/Parser/unittests/ParserPcpUnitTest.cpp
r881c05 r9e4fd1 7 7 8 8 /* 9 * Parser CommonUnitTest.cpp9 * ParserPcpUnitTest.cpp 10 10 * 11 11 * Created on: Mar 3, 2010 … … 18 18 #endif 19 19 20 #include "Parser CommonUnitTest.hpp"20 #include "ParserPcpUnitTest.hpp" 21 21 22 22 #include <cppunit/CompilerOutputter.h> … … 24 24 #include <cppunit/ui/text/TestRunner.h> 25 25 26 #include "Parser/MpqcParser.hpp"27 #include "Parser/PdbParser.hpp"28 26 #include "Parser/PcpParser.hpp" 29 #include "Parser/TremoloParser.hpp"30 #include "Parser/XyzParser.hpp"31 27 #include "World.hpp" 32 28 #include "atom.hpp" … … 42 38 43 39 // Registers the fixture into the 'registry' 44 CPPUNIT_TEST_SUITE_REGISTRATION( Parser CommonUnitTest );40 CPPUNIT_TEST_SUITE_REGISTRATION( ParserPcpUnitTest ); 45 41 46 42 static string waterPcp = "# ParallelCarParinello - main configuration file - created with molecuilder\n\ … … 61 57 DoConstrainedMD\t0\t# Do perform a constrained (>0, relating to current MD step) instead of unconstrained (0) MD\n\ 62 58 Thermostat\tBerendsen\t2.5\t# Which Thermostat and its parameters to use in MD case.\n\ 63 CommonWannier\t0\t# Put virtual centers at indivual orbits, all common, merged by variance, to grid point, to cell center\n\59 PcpWannier\t0\t# Put virtual centers at indivual orbits, all common, merged by variance, to grid point, to cell center\n\ 64 60 SawtoothStart\t0.01\t# Absolute value for smooth transition at cell border \n\ 65 61 VectorPlane\t0\t# Cut plane axis (x, y or z: 0,1,2) for two-dim current vector plot\n\ … … 118 114 Ion_Type1_1\t0.758602\t0.000000000\t0.504284\t0 # molecule nr 1\n\ 119 115 Ion_Type1_2\t0.758602\t0.000000000\t-0.504284\t0 # molecule nr 2\n"; 120 //----|----*|---||--*||---|***|-------|-------|-------|-----|---------------|-|-121 //000000011111111112222222222333333333344444444445555555555666666666677777777778122 //345678901234567890123456789012345678901234567890123456789012345678901234567890123 static string waterPdb = "\124 REMARK This is a test water molecule as written by TREMOLO.\n\125 ATOM 1 OT GMT- 0 1.583 1.785 1.480 1.00178.02 O-2\n\126 ATOM 2 HT GMT- 0 1.186 1.643 2.213 1.00103.58 H+1\n\127 ATOM 3 HT GMT- 0 2.642 1.896 1.730 1.00126.00 H+1\n\128 ATOM 4 OT GMT- 1 3.583 1.785 1.480 1.00178.02 O-2\n\129 ATOM 5 HT GMT- 1 3.186 1.643 2.213 1.00103.58 H+1\n\130 ATOM 6 HT GMT- 1 4.642 1.896 1.730 1.00126.00 H+1\n\131 CONECT 1 2 3\n\132 CONECT 2 1\n\133 CONECT 3 1\n\134 CONECT 4 5 6\n\135 CONECT 5 4\n\136 CONECT 6 4\n\137 END";138 static string waterMpqc ="% Created by MoleCuilder\n\139 mpqc: (\n\140 \tsavestate = no\n\141 \tdo_gradient = yes\n\142 \tmole<MBPT2>: (\n\143 \t\tmaxiter = 200\n\144 \t\tbasis = $:basis\n\145 \t\tmolecule = $:molecule\n\146 \t\treference<CLHF>: (\n\147 \t\t\tbasis = $:basis\n\148 \t\t\tmolecule = $:molecule\n\149 \t\t)\n\150 \t)\n\151 )\n\152 molecule<Molecule>: (\n\153 \tunit = angstrom\n\154 \t{ atoms geometry } = {\n\155 \t\tO [ -0.505735\t0\t0 ]\n\156 \t\tH [ 0.252867\t0\t0.504284 ]\n\157 \t\tH [ 0.252867\t0\t-0.504284 ]\n\158 \t}\n\159 )\n\160 basis<GaussianBasisSet>: (\n\161 \tname = \"3-21G\"\n\162 \tmolecule = $:molecule\n\163 )\n";164 static string waterXyz = "3\n\tH2O: water molecule\nO\t0\t0\t0\nH\t0.758602\t0\t0.504284\nH\t0.758602\t0\t-0.504284\n";165 116 166 void Parser CommonUnitTest::setUp() {117 void ParserPcpUnitTest::setUp() { 167 118 World::getInstance(); 168 119 … … 174 125 } 175 126 176 void Parser CommonUnitTest::tearDown() {127 void ParserPcpUnitTest::tearDown() { 177 128 ChangeTracker::purgeInstance(); 178 129 World::purgeInstance(); … … 181 132 /************************************ tests ***********************************/ 182 133 183 void ParserCommonUnitTest::rewriteAnXyzTest() { 184 cout << "Testing the XYZ parser." << endl; 185 XyzParser* testParser = new XyzParser(); 186 stringstream input; 187 input << waterXyz; 188 testParser->load(&input); 189 input.clear(); 190 191 CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms()); 192 193 // store and parse in again 194 { 195 stringstream output; 196 std::vector<atom *> atoms = World::getInstance().getAllAtoms(); 197 testParser->save(&output, atoms); 198 input << output.str(); 199 testParser->load(&input); 200 } 201 202 // now twice as many 203 CPPUNIT_ASSERT_EQUAL(6, World::getInstance().numAtoms()); 204 205 // check every atom 206 std::vector<atom *> atoms = World::getInstance().getAllAtoms(); 207 std::vector<atom *>::const_iterator firstiter = atoms.begin(); 208 std::vector<atom *>::const_iterator seconditer = atoms.begin(); 209 for (size_t i=0;i<3;i++) 210 ++seconditer; 211 for (; 212 seconditer != atoms.end(); 213 ++firstiter,++seconditer) { 214 // check position and type (only stuff xyz stores) 215 CPPUNIT_ASSERT_EQUAL((*firstiter)->getPosition(),(*seconditer)->getPosition()); 216 CPPUNIT_ASSERT_EQUAL((*firstiter)->getType(),(*seconditer)->getType()); 217 } 218 } 219 220 void ParserCommonUnitTest::readwritePcpTest() { 134 void ParserPcpUnitTest::readwritePcpTest() { 221 135 stringstream input(waterPcp); 222 136 PcpParser* testParser = new PcpParser(); … … 241 155 CPPUNIT_ASSERT(*testParser == *testParser2); 242 156 } 243 244 void ParserCommonUnitTest::readwritePdbTest() {245 stringstream input;246 input << waterPdb;247 PdbParser* testParser = new PdbParser();248 testParser->load(&input);249 input.clear();250 251 CPPUNIT_ASSERT_EQUAL(6, World::getInstance().numAtoms());252 253 stringstream output;254 std::vector<atom *> atoms = World::getInstance().getAllAtoms();255 testParser->save(&output, atoms);256 257 // std::cout << "Save PDB is:" << std::endl;258 // std::cout << output.str() << std::endl;259 260 input << output.str();261 PdbParser* testParser2 = new PdbParser();262 testParser2->load(&input);263 264 CPPUNIT_ASSERT_EQUAL(12, World::getInstance().numAtoms());265 }266 267 void ParserCommonUnitTest::writeMpqcTest() {268 // build up water molecule269 atom *Walker = NULL;270 Walker = World::getInstance().createAtom();271 Walker->setType(8);272 Walker->setPosition(Vector(0,0,0));273 Walker = World::getInstance().createAtom();274 Walker->setType(1);275 Walker->setPosition(Vector(0.758602,0,0.504284));276 Walker = World::getInstance().createAtom();277 Walker->setType(1);278 Walker->setPosition(Vector(0.758602,0,-0.504284));279 CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms());280 281 // create two stringstreams, one stored, one created282 stringstream input(waterMpqc);283 MpqcParser* testParser = new MpqcParser();284 stringstream output;285 std::vector<atom *> atoms = World::getInstance().getAllAtoms();286 testParser->save(&output, atoms);287 288 // compare both configs289 string first = input.str();290 string second = output.str();291 CPPUNIT_ASSERT(first == second);292 }
Note:
See TracChangeset
for help on using the changeset viewer.