Changeset 4fbca9c for src/unittests
- Timestamp:
- Dec 5, 2010, 12:01:43 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:
- cabb46
- Parents:
- e828c0
- git-author:
- Frederik Heber <heber@…> (12/04/10 18:05:33)
- git-committer:
- Frederik Heber <heber@…> (12/05/10 00:01:43)
- Location:
- src/unittests
- Files:
-
- 2 added
- 1 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
src/unittests/Makefile.am
re828c0 r4fbca9c 35 35 MoleculeDescriptorTest \ 36 36 ObserverTest \ 37 ParserUnitTest \ 37 ParserCommonUnitTest \ 38 ParserTremoloUnitTest \ 38 39 periodentafelTest \ 39 40 PlaneUnittest \ … … 48 49 VectorContentUnitTest \ 49 50 VectorUnitTest 50 51 51 52 52 53 check_PROGRAMS = $(TESTS) 53 54 noinst_PROGRAMS = $(TESTS) TestRunner … … 96 97 MoleculeDescriptorTest.cpp \ 97 98 ObserverTest.cpp \ 98 ParserUnitTest.cpp \ 99 ParserCommonUnitTest.cpp \ 100 ParserTremoloUnitTest.cpp \ 99 101 periodentafelTest.cpp \ 100 102 PlaneUnittest.cpp \ … … 137 139 ObserverTest.hpp \ 138 140 periodentafelTest.hpp \ 139 ParserUnitTest.hpp \ 141 ParserCommonUnitTest.hpp \ 142 ParserTremoloUnitTest.hpp \ 140 143 PlaneUnittest.hpp \ 141 144 RegistryUnitTest.hpp \ … … 203 206 LineUnittest_LDADD = ${ALLLIBS} 204 207 205 LinkedCellUnitTest_SOURCES = UnitTestMain.cpp LinkedCellUnitTest.cpp LinkedCellUnitTest.hpp 208 LinkedCellUnitTest_SOURCES = UnitTestMain.cpp LinkedCellUnitTest.cpp LinkedCellUnitTest.hpp 206 209 LinkedCellUnitTest_LDADD = ${ALLLIBS} 207 210 … … 209 212 ListOfBondsUnitTest_LDADD = ${ALLLIBS} 210 213 211 LogUnitTest_SOURCES = UnitTestMain.cpp logunittest.cpp logunittest.hpp 214 LogUnitTest_SOURCES = UnitTestMain.cpp logunittest.cpp logunittest.hpp 212 215 LogUnitTest_LDADD = ${ALLLIBS} 213 216 … … 227 230 ObserverTest_LDADD = ${ALLLIBS} 228 231 229 ParserUnitTest_SOURCES = UnitTestMain.cpp ParserUnitTest.cpp ParserUnitTest.hpp 230 ParserUnitTest_LDADD = ${ALLLIBS} 232 ParserCommonUnitTest_SOURCES = UnitTestMain.cpp ParserCommonUnitTest.cpp ParserCommonUnitTest.hpp 233 ParserCommonUnitTest_LDADD = ${ALLLIBS} 234 235 ParserTremoloUnitTest_SOURCES = UnitTestMain.cpp ParserTremoloUnitTest.cpp ParserTremoloUnitTest.hpp 236 ParserTremoloUnitTest_LDADD = ${ALLLIBS} 231 237 232 238 periodentafelTest_SOURCES = UnitTestMain.cpp periodentafelTest.cpp periodentafelTest.hpp -
src/unittests/ParserCommonUnitTest.cpp
re828c0 r4fbca9c 7 7 8 8 /* 9 * Parser UnitTest.cpp9 * ParserCommonUnitTest.cpp 10 10 * 11 11 * Created on: Mar 3, 2010 … … 18 18 #endif 19 19 20 #include "Parser UnitTest.hpp"20 #include "ParserCommonUnitTest.hpp" 21 21 22 22 #include <cppunit/CompilerOutputter.h> … … 25 25 26 26 #include "Parser/MpqcParser.hpp" 27 #include "Parser/PdbParser.hpp" 27 28 #include "Parser/PcpParser.hpp" 28 29 #include "Parser/TremoloParser.hpp" … … 41 42 42 43 // Registers the fixture into the 'registry' 43 CPPUNIT_TEST_SUITE_REGISTRATION( Parser UnitTest );44 CPPUNIT_TEST_SUITE_REGISTRATION( ParserCommonUnitTest ); 44 45 45 46 static string waterPcp = "# ParallelCarParinello - main configuration file - created with molecuilder\n\ … … 117 118 Ion_Type1_1\t0.758602\t0.000000000\t0.504284\t0 # molecule nr 1\n\ 118 119 Ion_Type1_2\t0.758602\t0.000000000\t-0.504284\t0 # molecule nr 2\n"; 120 //----|----*|---||--*||---|***|-------|-------|-------|-----|---------------|-|- 121 //000000011111111112222222222333333333344444444445555555555666666666677777777778 122 //345678901234567890123456789012345678901234567890123456789012345678901234567890 123 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"; 119 138 static string waterMpqc ="% Created by MoleCuilder\n\ 120 139 mpqc: (\n\ … … 144 163 )\n"; 145 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"; 146 static string Tremolo_Atomdata1 = "# ATOMDATA\tId\tname\tType\tx=3\n"; 147 static string Tremolo_Atomdata2 = "#\n#ATOMDATA Id name Type x=3\n1 hydrogen H 3.0 4.5 0.1\n\n"; 148 static string Tremolo_invalidkey = "#\n#ATOMDATA Id name foo Type x=3\n\n\n"; 149 static string Tremolo_velocity = "#\n#ATOMDATA Id name Type u=3\n1 hydrogen H 3.0 4.5 0.1\n\n"; 150 static string Tremolo_neighbours = "#\n#ATOMDATA Id Type neighbors=2\n1 H 3 0\n2 H 3 0\n3 O 1 2\n"; 151 static string Tremolo_improper = "#\n#ATOMDATA Id Type imprData\n8 H 9-10\n9 H 10-8,8-10\n10 O -\n"; 152 static string Tremolo_torsion = "#\n#ATOMDATA Id Type torsion\n8 H 9-10\n9 H 10-8,8-10\n10 O -\n"; 153 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\t1\t0\t0\t0\t0\t0\t-\t0\tH\t-\t-\t-\t0\t0\t0\t0\t0\t0\t0\t0\t-\t\n"; 154 155 void ParserUnitTest::setUp() { 165 166 void ParserCommonUnitTest::setUp() { 156 167 World::getInstance(); 168 169 setVerbosity(2); 157 170 158 171 // we need hydrogens and oxygens in the following tests … … 161 174 } 162 175 163 void Parser UnitTest::tearDown() {176 void ParserCommonUnitTest::tearDown() { 164 177 ChangeTracker::purgeInstance(); 165 178 World::purgeInstance(); … … 168 181 /************************************ tests ***********************************/ 169 182 170 void Parser UnitTest::rewriteAnXyzTest() {183 void ParserCommonUnitTest::rewriteAnXyzTest() { 171 184 cout << "Testing the XYZ parser." << endl; 172 185 XyzParser* testParser = new XyzParser(); … … 185 198 } 186 199 187 void ParserUnitTest::readTremoloPreliminaryCommentsTest() { 188 cout << "Testing the tremolo parser." << endl; 189 TremoloParser* testParser = new TremoloParser(); 190 stringstream input, output; 191 192 // Atomdata beginning with "# ATOMDATA" 193 input << Tremolo_Atomdata1; 194 testParser->load(&input); 195 testParser->save(&output); 196 CPPUNIT_ASSERT(Tremolo_Atomdata1 == output.str()); 197 input.clear(); 198 output.clear(); 199 200 // Atomdata beginning with "#ATOMDATA" 201 input << Tremolo_Atomdata2; 202 testParser->load(&input); 203 testParser->save(&output); 204 CPPUNIT_ASSERT(output.str().find("hydrogen") != string::npos); 205 input.clear(); 206 output.clear(); 207 208 // Invalid key in Atomdata line 209 input << Tremolo_invalidkey; 210 testParser->load(&input); 211 //TODO: proove invalidity 212 input.clear(); 213 } 214 215 void ParserUnitTest::readTremoloCoordinatesTest() { 216 TremoloParser* testParser = new TremoloParser(); 217 stringstream input; 218 219 // One simple data line 220 input << Tremolo_Atomdata2; 221 testParser->load(&input); 222 CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->at(0) == 3.0); 223 input.clear(); 224 } 225 226 void ParserUnitTest::readTremoloVelocityTest() { 227 TremoloParser* testParser = new TremoloParser(); 228 stringstream input; 229 230 // One simple data line 231 input << Tremolo_velocity; 232 testParser->load(&input); 233 CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->AtomicVelocity[0] == 3.0); 234 input.clear(); 235 } 236 237 void ParserUnitTest::readTremoloNeighborInformationTest() { 238 TremoloParser* testParser = new TremoloParser(); 239 stringstream input; 240 241 // Neighbor data 242 input << Tremolo_neighbours; 243 testParser->load(&input); 244 245 CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms()); 246 CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(8))-> 247 IsBondedTo(World::getInstance().getAtom(AtomByType(1)))); 248 input.clear(); 249 } 250 251 void ParserUnitTest::readAndWriteTremoloImprDataInformationTest() { 252 TremoloParser* testParser = new TremoloParser(); 253 stringstream input, output; 254 255 // Neighbor data 256 input << Tremolo_improper; 257 testParser->load(&input); 258 testParser->save(&output); 259 CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms()); 260 CPPUNIT_ASSERT(output.str().find("2-0,0-2") != string::npos); 261 input.clear(); 262 output.clear(); 263 } 264 265 void ParserUnitTest::readAndWriteTremoloTorsionInformationTest() { 266 TremoloParser* testParser = new TremoloParser(); 267 stringstream input, output; 268 269 // Neighbor data 270 input << Tremolo_torsion; 271 testParser->load(&input); 272 testParser->save(&output); 273 CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms()); 274 CPPUNIT_ASSERT(output.str().find("2-0,0-2") != string::npos); 275 input.clear(); 276 output.clear(); 277 } 278 279 void ParserUnitTest::writeTremoloTest() { 280 TremoloParser* testParser = new TremoloParser(); 281 stringstream output; 282 283 // with the maximum number of fields and minimal information, default values are printed 284 atom* newAtom = World::getInstance().createAtom(); 285 newAtom->setType(1); 286 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"); 287 testParser->save(&output); 288 CPPUNIT_ASSERT(output.str() == Tremolo_full); 289 290 cout << "testing the tremolo parser is done" << endl; 291 } 292 293 void ParserUnitTest::readwritePcpTest() { 200 void ParserCommonUnitTest::readwritePcpTest() { 294 201 stringstream input(waterPcp); 295 202 PcpParser* testParser = new PcpParser(); … … 299 206 CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms()); 300 207 301 string newWaterPcp = ""; 302 stringstream output; 303 testParser->save(&output); 304 305 input << output; 208 // check that equality function is ok 209 CPPUNIT_ASSERT(*testParser == *testParser); 210 211 stringstream output; 212 testParser->save(&output); 213 214 input << output.str(); 306 215 PcpParser* testParser2 = new PcpParser(); 307 216 testParser2->load(&input); … … 312 221 } 313 222 314 void ParserUnitTest::writeMpqcTest() { 223 void ParserCommonUnitTest::readwritePdbTest() { 224 stringstream input; 225 input << waterPdb; 226 PdbParser* testParser = new PdbParser(); 227 testParser->load(&input); 228 input.clear(); 229 230 CPPUNIT_ASSERT_EQUAL(6, World::getInstance().numAtoms()); 231 232 stringstream output; 233 testParser->save(&output); 234 235 // std::cout << "Save PDB is:" << std::endl; 236 // std::cout << output.str() << std::endl; 237 238 input << output.str(); 239 PdbParser* testParser2 = new PdbParser(); 240 testParser2->load(&input); 241 242 CPPUNIT_ASSERT_EQUAL(12, World::getInstance().numAtoms()); 243 } 244 245 void ParserCommonUnitTest::writeMpqcTest() { 315 246 // build up water molecule 316 247 atom *Walker = NULL; -
src/unittests/ParserTremoloUnitTest.hpp
re828c0 r4fbca9c 1 1 /* 2 * Parser UnitTest.hpp2 * ParserTremoloUnitTest.hpp 3 3 * 4 4 * Created on: Mar 3, 2010 5 5 * Author: metzler 6 6 */ 7 #ifndef PARSER UNITTEST_HPP_8 #define PARSER UNITTEST_HPP_7 #ifndef PARSERTREMOLOUNITTEST_HPP_ 8 #define PARSERTREMOLOUNITTEST_HPP_ 9 9 10 10 #include <cppunit/extensions/HelperMacros.h> 11 11 #include <string> 12 12 13 class Parser UnitTest : public CppUnit::TestFixture13 class ParserTremoloUnitTest : public CppUnit::TestFixture 14 14 { 15 CPPUNIT_TEST_SUITE( ParserUnitTest ) ; 16 CPPUNIT_TEST ( rewriteAnXyzTest ); 15 CPPUNIT_TEST_SUITE( ParserTremoloUnitTest ) ; 17 16 CPPUNIT_TEST ( readTremoloPreliminaryCommentsTest ); 18 17 CPPUNIT_TEST ( readTremoloCoordinatesTest ); … … 22 21 CPPUNIT_TEST ( readAndWriteTremoloTorsionInformationTest ); 23 22 CPPUNIT_TEST ( writeTremoloTest ); 24 CPPUNIT_TEST ( readwritePcpTest );25 CPPUNIT_TEST ( writeMpqcTest );26 23 CPPUNIT_TEST_SUITE_END(); 27 24 … … 30 27 void tearDown(); 31 28 32 void rewriteAnXyzTest();33 29 void readTremoloPreliminaryCommentsTest(); 34 30 void readTremoloCoordinatesTest(); … … 38 34 void readAndWriteTremoloTorsionInformationTest(); 39 35 void writeTremoloTest(); 40 void readwritePcpTest();41 void writeMpqcTest();42 36 }; 43 37 44 #endif /* PARSER UNITTEST_HPP_ */38 #endif /* PARSERTREMOLOUNITTEST_HPP_ */
Note:
See TracChangeset
for help on using the changeset viewer.