Changeset 4eb4fe for src/unittests
- Timestamp:
- May 18, 2010, 3:20:52 PM (16 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, Candidate_v1.7.0, Candidate_v1.7.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:
- 673c7f, b0e9c9
- Parents:
- 5079a0
- Location:
- src/unittests
- Files:
-
- 2 added
- 18 edited
-
AnalysisCorrelationToPointUnitTest.cpp (modified) (2 diffs)
-
AnalysisCorrelationToPointUnitTest.hpp (modified) (2 diffs)
-
AnalysisCorrelationToSurfaceUnitTest.cpp (modified) (4 diffs)
-
AnalysisCorrelationToSurfaceUnitTest.hpp (modified) (1 diff)
-
AnalysisPairCorrelationUnitTest.cpp (modified) (1 diff)
-
AnalysisPairCorrelationUnitTest.hpp (modified) (2 diffs)
-
CountBondsUnitTest.cpp (modified) (6 diffs)
-
CountBondsUnitTest.hpp (modified) (1 diff)
-
LinkedCellUnitTest.cpp (modified) (2 diffs)
-
LinkedCellUnitTest.hpp (modified) (1 diff)
-
Makefile.am (modified) (4 diffs)
-
ParserUnitTest.cpp (modified) (1 diff)
-
analysisbondsunittest.cpp (modified) (2 diffs)
-
analysisbondsunittest.hpp (modified) (1 diff)
-
bondgraphunittest.cpp (modified) (7 diffs)
-
bondgraphunittest.hpp (modified) (1 diff)
-
listofbondsunittest.cpp (modified) (2 diffs)
-
listofbondsunittest.hpp (modified) (1 diff)
-
periodentafelTest.cpp (added)
-
periodentafelTest.hpp (added)
Legend:
- Unmodified
- Added
- Removed
-
src/unittests/AnalysisCorrelationToPointUnitTest.cpp
r5079a0 r4eb4fe 17 17 #include "AnalysisCorrelationToPointUnitTest.hpp" 18 18 19 #include "World.hpp"20 19 #include "atom.hpp" 21 #include "boundary.hpp"22 20 #include "element.hpp" 23 21 #include "molecule.hpp" 24 22 #include "linkedcell.hpp" 25 23 #include "periodentafel.hpp" 26 #include "tesselation.hpp"27 24 #include "World.hpp" 28 25 … … 43 40 TestList = NULL; 44 41 TestMolecule = NULL; 45 hydrogen = NULL;46 tafel = NULL;47 42 pointmap = NULL; 48 43 binmap = NULL; 49 44 point = NULL; 50 45 51 // construct element52 hydrogen = new element;53 hydrogen->Z = 1;54 strcpy(hydrogen->name, "hydrogen");55 strcpy(hydrogen->symbol, "H");56 57 58 // construct periodentafel59 tafel = World::getInstance().getPeriode();60 tafel->AddElement(hydrogen);61 62 46 // construct molecule (tetraeder of hydrogens) 47 hydrogen = World::getInstance().getPeriode()->FindElement(1); 48 CPPUNIT_ASSERT(hydrogen != NULL && "hydrogen element not found"); 63 49 TestMolecule = World::getInstance().createMolecule(); 64 50 Walker = World::getInstance().createAtom(); -
src/unittests/AnalysisCorrelationToPointUnitTest.hpp
r5079a0 r4eb4fe 12 12 13 13 class element; 14 class LinkedCell;15 14 class molecule; 16 15 class MoleculeListClass; 17 class periodentafel;18 class Tesselation;19 16 class Vector; 20 17 … … 40 37 MoleculeListClass *TestList; 41 38 molecule *TestMolecule; 42 element *hydrogen; 43 periodentafel *tafel; 39 const element *hydrogen; 44 40 45 41 CorrelationToPointMap *pointmap; -
src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
r5079a0 r4eb4fe 17 17 #include "AnalysisCorrelationToSurfaceUnitTest.hpp" 18 18 19 #include "World.hpp"20 19 #include "atom.hpp" 21 20 #include "boundary.hpp" … … 47 46 TestList = NULL; 48 47 TestSurfaceMolecule = NULL; 49 hydrogen = NULL;50 tafel = NULL;51 48 surfacemap = NULL; 52 49 binmap = NULL; … … 54 51 LC = NULL; 55 52 56 // construct element57 hydrogen = new element;58 hydrogen->Z = 1;59 strcpy(hydrogen->name, "hydrogen");60 strcpy(hydrogen->symbol, "H");61 carbon = new element;62 carbon->Z = 6;63 strcpy(carbon->name, "carbon");64 strcpy(carbon->symbol, "C");65 66 // construct periodentafel67 tafel = World::getInstance().getPeriode();68 tafel->AddElement(hydrogen);69 tafel->AddElement(carbon);70 71 53 // construct molecule (tetraeder of hydrogens) base 54 hydrogen = World::getInstance().getPeriode()->FindElement(1); 72 55 TestSurfaceMolecule = World::getInstance().createMolecule(); 73 56 Walker = World::getInstance().createAtom(); … … 102 85 103 86 // add outer atoms 87 carbon = World::getInstance().getPeriode()->FindElement(6); 104 88 TestSurfaceMolecule = World::getInstance().createMolecule(); 105 89 Walker = World::getInstance().createAtom(); -
src/unittests/AnalysisCorrelationToSurfaceUnitTest.hpp
r5079a0 r4eb4fe 45 45 MoleculeListClass *TestList; 46 46 molecule *TestSurfaceMolecule; 47 element *hydrogen; 48 element *carbon; 49 periodentafel *tafel; 47 const element *hydrogen; 48 const element *carbon; 50 49 51 50 CorrelationToSurfaceMap *surfacemap; -
src/unittests/AnalysisPairCorrelationUnitTest.cpp
r5079a0 r4eb4fe 44 44 TestList = NULL; 45 45 TestMolecule = NULL; 46 hydrogen = NULL;47 tafel = NULL;48 46 correlationmap = NULL; 49 47 binmap = NULL; 50 48 51 // construct element52 hydrogen = new element;53 hydrogen->Z = 1;54 strcpy(hydrogen->name, "hydrogen");55 strcpy(hydrogen->symbol, "H");56 57 // construct periodentafel58 tafel = World::getInstance().getPeriode();59 tafel->AddElement(hydrogen);60 61 49 // construct molecule (tetraeder of hydrogens) 50 hydrogen = World::getInstance().getPeriode()->FindElement(1); 62 51 TestMolecule = World::getInstance().createMolecule(); 63 52 Walker = World::getInstance().createAtom(); -
src/unittests/AnalysisPairCorrelationUnitTest.hpp
r5079a0 r4eb4fe 12 12 13 13 class element; 14 class LinkedCell;15 14 class molecule; 16 15 class MoleculeListClass; 17 class periodentafel;18 class Tesselation;19 16 class Vector; 20 17 … … 40 37 MoleculeListClass *TestList; 41 38 molecule *TestMolecule; 42 element *hydrogen; 43 periodentafel *tafel; 39 const element *hydrogen; 44 40 45 41 PairCorrelationMap *correlationmap; -
src/unittests/CountBondsUnitTest.cpp
r5079a0 r4eb4fe 16 16 #include <stdio.h> 17 17 #include <cstring> 18 19 #include "Helpers/Assert.hpp" 18 20 19 21 #include "analysis_bonds.hpp" … … 40 42 { 41 43 atom *Walker = NULL; 42 BG = NULL;43 filename = NULL;44 45 // init private all pointers to zero46 molecules = NULL;47 TestMolecule1 = NULL;48 TestMolecule2 = NULL;49 hydrogen = NULL;50 oxygen = NULL;51 tafel = NULL;52 44 53 45 // construct element 54 hydrogen = new element; 55 hydrogen->Z = 1; 56 hydrogen->CovalentRadius = 0.23; 57 strcpy(hydrogen->name, "hydrogen"); 58 strcpy(hydrogen->symbol, "H"); 59 oxygen = new element; 60 oxygen->Z = 8; 61 oxygen->CovalentRadius = 0.68; 62 strcpy(oxygen->name, "oxygen"); 63 strcpy(oxygen->symbol, "O"); 64 65 // construct periodentafel 66 tafel = World::getInstance().getPeriode(); 67 tafel->AddElement(hydrogen); 68 tafel->AddElement(oxygen); 46 hydrogen = World::getInstance().getPeriode()->FindElement(1); 47 oxygen = World::getInstance().getPeriode()->FindElement(8); 48 CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen"); 49 CPPUNIT_ASSERT(oxygen != NULL && "could not find element oxygen"); 69 50 70 51 // construct molecule (water molecule) 71 52 TestMolecule1 = World::getInstance().createMolecule(); 72 Walker = World::getInstance().createAtom(); 53 CPPUNIT_ASSERT(TestMolecule1 != NULL && "could not create first molecule"); 54 Walker = World::getInstance().createAtom(); 55 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 73 56 Walker->type = hydrogen; 74 57 *Walker->node = Vector(-0.2418, 0.9350, 0. ); 75 58 TestMolecule1->AddAtom(Walker); 76 59 Walker = World::getInstance().createAtom(); 60 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 77 61 Walker->type = hydrogen; 78 62 *Walker->node = Vector(0.9658, 0., 0. ); 79 63 TestMolecule1->AddAtom(Walker); 80 64 Walker = World::getInstance().createAtom(); 65 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 81 66 Walker->type = oxygen; 82 67 *Walker->node = Vector(0., 0., 0. ); … … 84 69 85 70 TestMolecule2 = World::getInstance().createMolecule(); 86 Walker = World::getInstance().createAtom(); 71 CPPUNIT_ASSERT(TestMolecule2 != NULL && "could not create second molecule"); 72 Walker = World::getInstance().createAtom(); 73 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 87 74 Walker->type = hydrogen; 88 75 *Walker->node = Vector(-0.2418, 0.9350, 0. ); 89 76 TestMolecule2->AddAtom(Walker); 90 77 Walker = World::getInstance().createAtom(); 78 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 91 79 Walker->type = hydrogen; 92 80 *Walker->node = Vector(0.9658, 0., 0. ); 93 81 TestMolecule2->AddAtom(Walker); 94 82 Walker = World::getInstance().createAtom(); 83 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 95 84 Walker->type = oxygen; 96 85 *Walker->node = Vector(0., 0., 0. ); … … 98 87 99 88 molecules = World::getInstance().getMolecules(); 89 CPPUNIT_ASSERT(molecules != NULL && "could not obtain list of molecules"); 100 90 molecules->insert(TestMolecule1); 101 91 molecules->insert(TestMolecule2); … … 111 101 // create a small file with table 112 102 BG = new BondGraph(true); 103 CPPUNIT_ASSERT(BG != NULL && "could not create BondGraph"); 113 104 114 105 // construct bond graphs … … 158 149 { 159 150 double *mirror = new double[3]; 151 CPPUNIT_ASSERT(mirror != NULL && "could not create array of doubles"); 160 152 for (int i=0;i<3;i++) 161 153 mirror[i] = -1.; -
src/unittests/CountBondsUnitTest.hpp
r5079a0 r4eb4fe 39 39 molecule *TestMolecule1; 40 40 molecule *TestMolecule2; 41 element *hydrogen; 42 element *oxygen; 43 periodentafel *tafel; 41 const element *hydrogen; 42 const element *oxygen; 44 43 45 44 BondGraph *BG; -
src/unittests/LinkedCellUnitTest.cpp
r5079a0 r4eb4fe 38 38 atom *Walker = NULL; 39 39 40 // init private all pointers to zero41 TestMolecule = NULL;42 hydrogen = NULL;43 tafel = NULL;44 45 40 // construct element 46 hydrogen = new element; 47 hydrogen->Z = 1; 48 hydrogen->CovalentRadius = 0.23; 49 strcpy(hydrogen->name, "hydrogen"); 50 strcpy(hydrogen->symbol, "H"); 51 52 // construct periodentafel 53 tafel = World::getInstance().getPeriode(); 54 tafel->AddElement(hydrogen); 41 hydrogen = World::getInstance().getPeriode()->FindElement(1); 42 CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen"); 55 43 56 44 // construct molecule (water molecule) 57 45 TestMolecule = World::getInstance().createMolecule(); 46 CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule"); 58 47 for (double x=0.5;x<3;x+=1.) 59 48 for (double y=0.5;y<3;y+=1.) 60 49 for (double z=0.5;z<3;z+=1.) { 61 50 Walker = World::getInstance().createAtom(); 51 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 62 52 Walker->type = hydrogen; 63 53 *Walker->node = Vector(x, y, z ); … … 67 57 // construct linked cell 68 58 LC = new LinkedCell (TestMolecule, 1.); 59 CPPUNIT_ASSERT(LC != NULL && "could not create LinkedCell"); 69 60 70 61 // check that TestMolecule was correctly constructed -
src/unittests/LinkedCellUnitTest.hpp
r5079a0 r4eb4fe 48 48 49 49 molecule *TestMolecule; 50 element *hydrogen; 51 periodentafel *tafel; 50 const element *hydrogen; 52 51 LinkedCell *LC; 53 52 }; -
src/unittests/Makefile.am
r5079a0 r4eb4fe 33 33 MemoryAllocatorUnitTest \ 34 34 MoleculeDescriptorTest \ 35 PlaneUnittest \36 35 ObserverTest \ 37 36 ParserUnitTest \ 37 periodentafelTest \ 38 PlaneUnittest \ 38 39 SingletonTest \ 39 40 StackClassUnitTest \ … … 75 76 memoryusageobserverunittest.cpp \ 76 77 MoleculeDescriptorTest.cpp \ 77 PlaneUnittest.cpp \78 78 ObserverTest.cpp \ 79 79 ParserUnitTest.cpp \ 80 periodentafelTest.cpp \ 81 PlaneUnittest.cpp \ 80 82 SingletonTest.cpp \ 81 83 stackclassunittest.cpp \ … … 109 111 memoryusageobserverunittest.hpp \ 110 112 MoleculeDescriptorTest.hpp \ 113 periodentafelTest.hpp \ 111 114 PlaneUnittest.hpp \ 112 115 ObserverTest.hpp \ … … 194 197 ParserUnitTest_LDADD = ${ALLLIBS} 195 198 199 periodentafelTest_SOURCES = UnitTestMain.cpp periodentafelTest.cpp periodentafelTest.hpp 200 periodentafelTest_LDADD = ${ALLLIBS} 201 196 202 PlaneUnittest_SOURCES = UnitTestMain.cpp PlaneUnittest.cpp PlaneUnittest.hpp 197 203 PlaneUnittest_LDADD = ${ALLLIBS} -
src/unittests/ParserUnitTest.cpp
r5079a0 r4eb4fe 31 31 32 32 void ParserUnitTest::setUp() { 33 element* oxygen = new element(); 34 oxygen->symbol[0] = 'O'; 35 oxygen->Z = 8; 36 World::getInstance().getPeriode()->AddElement(oxygen); 37 38 element* hydrogen = new element(); 39 hydrogen->symbol[0] = 'H'; 40 hydrogen->Z = 1; 41 World::getInstance().getPeriode()->AddElement(hydrogen); 33 World::getInstance(); 42 34 } 43 35 -
src/unittests/analysisbondsunittest.cpp
r5079a0 r4eb4fe 40 40 atom *Walker = NULL; 41 41 42 // init private all pointers to zero 43 TestMolecule = NULL; 44 hydrogen = NULL; 45 tafel = NULL; 46 47 // construct element 48 hydrogen = new element; 49 hydrogen->Z = 1; 50 hydrogen->Valence = 1; 51 hydrogen->NoValenceOrbitals = 1; 52 strcpy(hydrogen->name, "hydrogen"); 53 strcpy(hydrogen->symbol, "H"); 54 carbon = new element; 55 carbon->Z = 2; 56 carbon->Valence = 4; 57 carbon->NoValenceOrbitals = 4; 58 strcpy(carbon->name, "carbon"); 59 strcpy(carbon->symbol, "C"); 60 61 62 // construct periodentafel 63 tafel = World::getInstance().getPeriode(); 64 tafel->AddElement(hydrogen); 65 tafel->AddElement(carbon); 42 // get elements 43 hydrogen = World::getInstance().getPeriode()->FindElement(1); 44 carbon = World::getInstance().getPeriode()->FindElement(6); 45 CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen"); 46 CPPUNIT_ASSERT(carbon != NULL && "could not find element carbon"); 66 47 67 48 // construct molecule (tetraeder of hydrogens) 68 49 TestMolecule = World::getInstance().createMolecule(); 50 CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule"); 69 51 Walker = World::getInstance().createAtom(); 52 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 70 53 Walker->type = hydrogen; 71 54 *Walker->node = Vector(1.5, 0., 1.5 ); 72 55 TestMolecule->AddAtom(Walker); 73 56 Walker = World::getInstance().createAtom(); 57 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 74 58 Walker->type = hydrogen; 75 59 *Walker->node = Vector(0., 1.5, 1.5 ); 76 60 TestMolecule->AddAtom(Walker); 77 61 Walker = World::getInstance().createAtom(); 62 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 78 63 Walker->type = hydrogen; 79 64 *Walker->node = Vector(1.5, 1.5, 0. ); 80 65 TestMolecule->AddAtom(Walker); 81 66 Walker = World::getInstance().createAtom(); 67 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 82 68 Walker->type = hydrogen; 83 69 *Walker->node = Vector(0., 0., 0. ); 84 70 TestMolecule->AddAtom(Walker); 85 71 Walker = World::getInstance().createAtom(); 72 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 86 73 Walker->type = carbon; 87 74 *Walker->node = Vector(0.5, 0.5, 0.5 ); … … 93 80 // create a small file with table 94 81 filename = new string("test.dat"); 82 CPPUNIT_ASSERT(filename != NULL && "could not create string"); 95 83 ofstream test(filename->c_str()); 96 test << ".\tH\tC\n"; 97 test << "H\t1.\t1.2\n"; 98 test << "C\t1.2\t1.5\n"; 84 test << ".\tH\tHe\tLi\tBe\tB\tC\n"; 85 test << "H\t1.\t1.\t1.\t1.\t1.\t1.2\n"; 86 test << "He\t1.\t1.\t1.\t1.\t1.\t1.\n"; 87 test << "Li\t1.\t1.\t1.\t1.\t1.\t1.\n"; 88 test << "Be\t1.\t1.\t1.\t1.\t1.\t1.\n"; 89 test << "B\t1.\t1.\t1.\t1.\t1.\t1.\n"; 90 test << "C\t1.2\t1.\t1.\t1.\t1.\t1.5\n"; 99 91 test.close(); 100 92 BG = new BondGraph(true); 93 CPPUNIT_ASSERT(BG != NULL && "could not create BondGraph"); 101 94 102 95 CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) ); 103 96 CPPUNIT_ASSERT_EQUAL( 1., BG->GetBondLength(0,0) ); 104 CPPUNIT_ASSERT_EQUAL( 1.2, BG->GetBondLength(0, 1) );105 CPPUNIT_ASSERT_EQUAL( 1.5, BG->GetBondLength( 1,1) );97 CPPUNIT_ASSERT_EQUAL( 1.2, BG->GetBondLength(0,5) ); 98 CPPUNIT_ASSERT_EQUAL( 1.5, BG->GetBondLength(5,5) ); 106 99 107 100 BG->ConstructBondGraph(TestMolecule); -
src/unittests/analysisbondsunittest.hpp
r5079a0 r4eb4fe 34 34 35 35 molecule *TestMolecule; 36 element *hydrogen; 37 element *carbon; 38 periodentafel *tafel; 36 const element *hydrogen; 37 const element *carbon; 39 38 40 39 BondGraph *BG; -
src/unittests/bondgraphunittest.cpp
r5079a0 r4eb4fe 15 15 #include <stdio.h> 16 16 #include <cstring> 17 18 #include "Helpers/Assert.hpp" 17 19 18 20 #include "World.hpp" … … 41 43 atom *Walker = NULL; 42 44 43 // init private all pointers to zero44 TestMolecule = NULL;45 hydrogen = NULL;46 tafel = NULL;47 48 45 // construct element 49 hydrogen = new element; 50 hydrogen->Z = 1; 51 hydrogen->CovalentRadius = 0.23; 52 hydrogen->VanDerWaalsRadius = 1.09; 53 strcpy(hydrogen->name, "hydrogen"); 54 strcpy(hydrogen->symbol, "H"); 55 carbon = new element; 56 carbon->Z = 2; 57 carbon->CovalentRadius = 0.68; 58 carbon->VanDerWaalsRadius = 1.7; 59 strcpy(carbon->name, "carbon"); 60 strcpy(carbon->symbol, "C"); 61 62 63 // construct periodentafel 64 tafel = World::getInstance().getPeriode(); 65 tafel->AddElement(hydrogen); 66 tafel->AddElement(carbon); 46 hydrogen = World::getInstance().getPeriode()->FindElement(1); 47 carbon = World::getInstance().getPeriode()->FindElement(6); 48 CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen"); 49 CPPUNIT_ASSERT(carbon != NULL && "could not find element carbon"); 67 50 68 51 // construct molecule (tetraeder of hydrogens) 69 52 TestMolecule = World::getInstance().createMolecule(); 53 CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule"); 70 54 Walker = World::getInstance().createAtom(); 55 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 71 56 Walker->type = carbon; 72 57 *Walker->node = Vector(1., 0., 1. ); … … 74 59 75 60 Walker = World::getInstance().createAtom(); 61 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 76 62 Walker->type = carbon; 77 63 *Walker->node = Vector(0., 1., 1. ); … … 79 65 80 66 Walker = World::getInstance().createAtom(); 67 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 81 68 Walker->type = carbon; 82 69 *Walker->node = Vector(1., 1., 0. ); … … 84 71 85 72 Walker = World::getInstance().createAtom(); 73 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 86 74 Walker->type = carbon; 87 75 *Walker->node = Vector(0., 0., 0. ); … … 93 81 // create a small file with table 94 82 dummyname = new string("dummy.dat"); 83 CPPUNIT_ASSERT(dummyname != NULL && "could not create string"); 95 84 filename = new string("test.dat"); 85 CPPUNIT_ASSERT(filename != NULL && "could not create string"); 96 86 ofstream test(filename->c_str()); 97 test << ".\tH\tC\n"; 98 test << "H\t1.\t1.2\n"; 99 test << "C\t1.2\t1.5\n"; 87 test << ".\tH\tHe\tLi\tBe\tB\tC\n"; 88 test << "H\t1.\t1.\t1.\t1.\t1.\t1.2\n"; 89 test << "He\t1.\t1.\t1.\t1.\t1.\t1.\n"; 90 test << "Li\t1.\t1.\t1.\t1.\t1.\t1.\n"; 91 test << "Be\t1.\t1.\t1.\t1.\t1.\t1.\n"; 92 test << "B\t1.\t1.\t1.\t1.\t1.\t1.\n"; 93 test << "C\t1.2\t1.\t1.\t1.\t1.\t1.5\n"; 100 94 test.close(); 101 95 BG = new BondGraph(true); 96 CPPUNIT_ASSERT(BG != NULL && "could not create BondGraph"); 102 97 }; 103 98 … … 126 121 CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) ); 127 122 CPPUNIT_ASSERT_EQUAL( 1., BG->GetBondLength(0,0) ); 128 CPPUNIT_ASSERT_EQUAL( 1.2, BG->GetBondLength(0, 1) );129 CPPUNIT_ASSERT_EQUAL( 1.5, BG->GetBondLength( 1,1) );123 CPPUNIT_ASSERT_EQUAL( 1.2, BG->GetBondLength(0,5) ); 124 CPPUNIT_ASSERT_EQUAL( 1.5, BG->GetBondLength(5,5) ); 130 125 }; 131 126 -
src/unittests/bondgraphunittest.hpp
r5079a0 r4eb4fe 37 37 38 38 molecule *TestMolecule; 39 element *hydrogen; 40 element *carbon; 41 periodentafel *tafel; 39 const element *hydrogen; 40 const element *carbon; 42 41 43 42 BondGraph *BG; -
src/unittests/listofbondsunittest.cpp
r5079a0 r4eb4fe 38 38 atom *Walker = NULL; 39 39 40 // init private all pointers to zero41 TestMolecule = NULL;42 hydrogen = NULL;43 tafel = NULL;44 45 40 // construct element 46 hydrogen = new element; 47 hydrogen->Z = 1; 48 strcpy(hydrogen->name, "hydrogen"); 49 strcpy(hydrogen->symbol, "H"); 50 51 52 // construct periodentafel 53 tafel = World::getInstance().getPeriode(); 54 tafel->AddElement(hydrogen); 41 hydrogen = World::getInstance().getPeriode()->FindElement(1); 42 CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen"); 55 43 56 44 // construct molecule (tetraeder of hydrogens) 57 45 TestMolecule = World::getInstance().createMolecule(); 58 Walker = World::getInstance().createAtom(); 46 CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule"); 47 Walker = World::getInstance().createAtom(); 48 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 59 49 Walker->type = hydrogen; 60 50 *Walker->node = Vector(1., 0., 1. ); 61 51 TestMolecule->AddAtom(Walker); 62 52 Walker = World::getInstance().createAtom(); 53 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 63 54 Walker->type = hydrogen; 64 55 *Walker->node = Vector(0., 1., 1. ); 65 56 TestMolecule->AddAtom(Walker); 66 57 Walker = World::getInstance().createAtom(); 58 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 67 59 Walker->type = hydrogen; 68 60 *Walker->node = Vector(1., 1., 0. ); 69 61 TestMolecule->AddAtom(Walker); 70 62 Walker = World::getInstance().createAtom(); 63 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 71 64 Walker->type = hydrogen; 72 65 *Walker->node = Vector(0., 0., 0. ); … … 75 68 // check that TestMolecule was correctly constructed 76 69 CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 ); 77 78 70 }; 79 71 -
src/unittests/listofbondsunittest.hpp
r5079a0 r4eb4fe 41 41 42 42 molecule *TestMolecule; 43 element *hydrogen; 44 periodentafel *tafel; 43 const element *hydrogen; 45 44 }; 46 45
Note:
See TracChangeset
for help on using the changeset viewer.
