Changeset d74077 for src/unittests
- Timestamp:
- Jul 31, 2010, 3:23:10 PM (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:
- 8f4df1
- Parents:
- 5fbaeb
- Location:
- src/unittests
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
src/unittests/AnalysisCorrelationToPointUnitTest.cpp
r5fbaeb rd74077 53 53 TestMolecule = World::getInstance().createMolecule(); 54 54 Walker = World::getInstance().createAtom(); 55 Walker-> type = hydrogen;56 *Walker->node = Vector(1., 0., 1.);55 Walker->setType(hydrogen); 56 Walker->setPosition(Vector(1., 0., 1. )); 57 57 TestMolecule->AddAtom(Walker); 58 58 Walker = World::getInstance().createAtom(); 59 Walker-> type = hydrogen;60 *Walker->node = Vector(0., 1., 1.);59 Walker->setType(hydrogen); 60 Walker->setPosition(Vector(0., 1., 1. )); 61 61 TestMolecule->AddAtom(Walker); 62 62 Walker = World::getInstance().createAtom(); 63 Walker-> type = hydrogen;64 *Walker->node = Vector(1., 1., 0.);63 Walker->setType(hydrogen); 64 Walker->setPosition(Vector(1., 1., 0. )); 65 65 TestMolecule->AddAtom(Walker); 66 66 Walker = World::getInstance().createAtom(); 67 Walker-> type = hydrogen;68 *Walker->node = Vector(0., 0., 0.);67 Walker->setType(hydrogen); 68 Walker->setPosition(Vector(0., 0., 0. )); 69 69 TestMolecule->AddAtom(Walker); 70 70 -
src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
r5fbaeb rd74077 44 44 ASSERT_DO(Assert::Throw); 45 45 46 setVerbosity(5); 47 46 48 atom *Walker = NULL; 47 49 … … 62 64 63 65 Walker = World::getInstance().createAtom(); 64 Walker-> type = hydrogen;65 *Walker->node = Vector(1., 0., 1.);66 TestSurfaceMolecule->AddAtom(Walker); 67 68 Walker = World::getInstance().createAtom(); 69 Walker-> type = hydrogen;70 *Walker->node = Vector(0., 1., 1.);71 TestSurfaceMolecule->AddAtom(Walker); 72 73 Walker = World::getInstance().createAtom(); 74 Walker-> type = hydrogen;75 *Walker->node = Vector(1., 1., 0.);76 TestSurfaceMolecule->AddAtom(Walker); 77 78 Walker = World::getInstance().createAtom(); 79 Walker-> type = hydrogen;80 *Walker->node = Vector(0., 0., 0.);66 Walker->setType(hydrogen); 67 Walker->setPosition(Vector(1., 0., 1. )); 68 TestSurfaceMolecule->AddAtom(Walker); 69 70 Walker = World::getInstance().createAtom(); 71 Walker->setType(hydrogen); 72 Walker->setPosition(Vector(0., 1., 1. )); 73 TestSurfaceMolecule->AddAtom(Walker); 74 75 Walker = World::getInstance().createAtom(); 76 Walker->setType(hydrogen); 77 Walker->setPosition(Vector(1., 1., 0. )); 78 TestSurfaceMolecule->AddAtom(Walker); 79 80 Walker = World::getInstance().createAtom(); 81 Walker->setType(hydrogen); 82 Walker->setPosition(Vector(0., 0., 0. )); 81 83 TestSurfaceMolecule->AddAtom(Walker); 82 84 … … 95 97 TestSurfaceMolecule = World::getInstance().createMolecule(); 96 98 Walker = World::getInstance().createAtom(); 97 Walker-> type = carbon;98 *Walker->node = Vector(4., 0., 4.);99 TestSurfaceMolecule->AddAtom(Walker); 100 101 Walker = World::getInstance().createAtom(); 102 Walker-> type = carbon;103 *Walker->node = Vector(0., 4., 4.);104 TestSurfaceMolecule->AddAtom(Walker); 105 106 Walker = World::getInstance().createAtom(); 107 Walker-> type = carbon;108 *Walker->node = Vector(4., 4., 0.);99 Walker->setType(carbon); 100 Walker->setPosition(Vector(4., 0., 4. )); 101 TestSurfaceMolecule->AddAtom(Walker); 102 103 Walker = World::getInstance().createAtom(); 104 Walker->setType(carbon); 105 Walker->setPosition(Vector(0., 4., 4. )); 106 TestSurfaceMolecule->AddAtom(Walker); 107 108 Walker = World::getInstance().createAtom(); 109 Walker->setType(carbon); 110 Walker->setPosition(Vector(4., 4., 0. )); 109 111 TestSurfaceMolecule->AddAtom(Walker); 110 112 111 113 // add inner atoms 112 114 Walker = World::getInstance().createAtom(); 113 Walker-> type = carbon;114 *Walker->node = Vector(0.5, 0.5, 0.5);115 Walker->setType(carbon); 116 Walker->setPosition(Vector(0.5, 0.5, 0.5 )); 115 117 TestSurfaceMolecule->AddAtom(Walker); 116 118 -
src/unittests/AnalysisPairCorrelationUnitTest.cpp
r5fbaeb rd74077 58 58 TestMolecule = World::getInstance().createMolecule(); 59 59 Walker = World::getInstance().createAtom(); 60 Walker-> type = hydrogen;61 *Walker->node = Vector(1., 0., 1.);60 Walker->setType(hydrogen); 61 Walker->setPosition(Vector(1., 0., 1. )); 62 62 TestMolecule->AddAtom(Walker); 63 63 Walker = World::getInstance().createAtom(); 64 Walker-> type = hydrogen;65 *Walker->node = Vector(0., 1., 1.);64 Walker->setType(hydrogen); 65 Walker->setPosition(Vector(0., 1., 1. )); 66 66 TestMolecule->AddAtom(Walker); 67 67 Walker = World::getInstance().createAtom(); 68 Walker-> type = hydrogen;69 *Walker->node = Vector(1., 1., 0.);68 Walker->setType(hydrogen); 69 Walker->setPosition(Vector(1., 1., 0. )); 70 70 TestMolecule->AddAtom(Walker); 71 71 Walker = World::getInstance().createAtom(); 72 Walker-> type = hydrogen;73 *Walker->node = Vector(0., 0., 0.);72 Walker->setType(hydrogen); 73 Walker->setPosition(Vector(0., 0., 0. )); 74 74 TestMolecule->AddAtom(Walker); 75 75 -
src/unittests/CountBondsUnitTest.cpp
r5fbaeb rd74077 54 54 Walker = World::getInstance().createAtom(); 55 55 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 56 Walker-> type = hydrogen;57 *Walker->node = Vector(-0.2418, 0.9350, 0.);56 Walker->setType(hydrogen); 57 Walker->setPosition(Vector(-0.2418, 0.9350, 0. )); 58 58 TestMolecule1->AddAtom(Walker); 59 59 Walker = World::getInstance().createAtom(); 60 60 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 61 Walker-> type = hydrogen;62 *Walker->node = Vector(0.9658, 0., 0.);61 Walker->setType(hydrogen); 62 Walker->setPosition(Vector(0.9658, 0., 0. )); 63 63 TestMolecule1->AddAtom(Walker); 64 64 Walker = World::getInstance().createAtom(); 65 65 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 66 Walker-> type = oxygen;67 *Walker->node = Vector(0., 0., 0.);66 Walker->setType(oxygen); 67 Walker->setPosition(Vector(0., 0., 0. )); 68 68 TestMolecule1->AddAtom(Walker); 69 69 … … 72 72 Walker = World::getInstance().createAtom(); 73 73 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 74 Walker-> type = hydrogen;75 *Walker->node = Vector(-0.2418, 0.9350, 0.);74 Walker->setType(hydrogen); 75 Walker->setPosition(Vector(-0.2418, 0.9350, 0. )); 76 76 TestMolecule2->AddAtom(Walker); 77 77 Walker = World::getInstance().createAtom(); 78 78 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 79 Walker-> type = hydrogen;80 *Walker->node = Vector(0.9658, 0., 0.);79 Walker->setType(hydrogen); 80 Walker->setPosition(Vector(0.9658, 0., 0. )); 81 81 TestMolecule2->AddAtom(Walker); 82 82 Walker = World::getInstance().createAtom(); 83 83 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 84 Walker-> type = oxygen;85 *Walker->node = Vector(0., 0., 0.);84 Walker->setType(oxygen); 85 Walker->setPosition(Vector(0., 0., 0. )); 86 86 TestMolecule2->AddAtom(Walker); 87 87 -
src/unittests/LinkedCellUnitTest.cpp
r5fbaeb rd74077 50 50 Walker = World::getInstance().createAtom(); 51 51 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 52 Walker-> type = hydrogen;53 *Walker->node = Vector(x, y, z);52 Walker->setType(hydrogen); 53 Walker->setPosition(Vector(x, y, z )); 54 54 TestMolecule->AddAtom(Walker); 55 55 } … … 192 192 atom *newAtom = World::getInstance().createAtom(); 193 193 newAtom->setName("test"); 194 newAtom-> x= Vector(1,1,1);194 newAtom->setPosition(Vector(1,1,1)); 195 195 CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode(newAtom) ); 196 196 World::getInstance().destroyAtom(newAtom); … … 199 199 newAtom = World::getInstance().createAtom(); 200 200 newAtom->setName("test"); 201 newAtom-> x = Vector(0,-1,0);201 newAtom->setPosition(Vector(0,-1,0)); 202 202 CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode(newAtom) ); 203 203 World::getInstance().destroyAtom(newAtom); … … 216 216 for (double z=0.5;z<3;z+=1.) { 217 217 tester = Vector(x,y,z); 218 CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToVector( &tester) );218 CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToVector(tester) ); 219 219 } 220 220 // check corners of each cell … … 224 224 tester= Vector(x,y,z); 225 225 cout << "Tester is at " << tester << "." << endl; 226 CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToVector( &tester) );226 CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToVector(tester) ); 227 227 } 228 228 // check out of bounds … … 232 232 tester = Vector(x,y,z); 233 233 cout << "The following test is supposed to fail and produce an ERROR." << endl; 234 CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToVector( &tester) );234 CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToVector(tester) ); 235 235 } 236 236 // check nonsense vectors 237 237 tester= Vector(-423598,3245978,29349); 238 238 cout << "The following test is supposed to fail and produce an ERROR." << endl; 239 CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToVector( &tester) );239 CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToVector(tester) ); 240 240 }; 241 241 … … 249 249 250 250 tester= Vector(0.5,0.5,0.5); 251 LC->SetIndexToVector( &tester);251 LC->SetIndexToVector(tester); 252 252 LC->GetNeighbourBounds(lower, upper); 253 253 for (int i=0;i<NDIM;i++) … … 268 268 // get all atoms 269 269 tester= Vector(1.5,1.5,1.5); 270 CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector( &tester) );270 CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(tester) ); 271 271 ListOfPoints = LC->GetallNeighbours(); 272 272 size = ListOfPoints->size(); … … 285 285 // get all atoms in one corner 286 286 tester= Vector(0.5, 0.5, 0.5); 287 CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector( &tester) );287 CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(tester) ); 288 288 ListOfPoints = LC->GetallNeighbours(); 289 289 size=ListOfPoints->size(); 290 290 CPPUNIT_ASSERT_EQUAL( (size_t)8, size ); 291 291 for(molecule::iterator iter = TestMolecule->begin(); iter != TestMolecule->end(); ++iter){ 292 if (((*iter)-> x[0] <2) && ((*iter)->x[1] <2) && ((*iter)->x[2]<2)) {292 if (((*iter)->at(0) <2) && ((*iter)->at(1) <2) && ((*iter)->at(2) <2)) { 293 293 ListOfPoints->remove(*iter); 294 294 size--; … … 303 303 // get all atoms from one corner 304 304 tester = Vector(0.5, 0.5, 0.5); 305 CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector( &tester) );305 CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(tester) ); 306 306 ListOfPoints = LC->GetallNeighbours(3); 307 307 size=ListOfPoints->size(); … … 329 329 // get all points around central arom with radius 1. 330 330 tester= Vector(1.5,1.5,1.5); 331 CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector( &tester) );331 CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(tester) ); 332 332 ListOfPoints = LC->GetPointsInsideSphere(1., &tester); 333 333 size = ListOfPoints->size(); 334 334 CPPUNIT_ASSERT_EQUAL( (size_t)7, size ); 335 335 for(molecule::iterator iter = TestMolecule->begin(); iter!=TestMolecule->end();++iter){ 336 if (((*iter)-> x.DistanceSquared(tester) - 1.) < MYEPSILON ) {336 if (((*iter)->DistanceSquared(tester) - 1.) < MYEPSILON ) { 337 337 ListOfPoints->remove(*iter); 338 338 size--; -
src/unittests/Makefile.am
r5fbaeb rd74077 224 224 TesselationUnitTest_LDADD = ${ALLLIBS} 225 225 226 Tesselation_BoundaryTriangleUnitTest_SOURCES = UnitTestMain.cpp tesselation_boundarytriangleunittest.cpp tesselation_boundarytriangleunittest.hpp 226 Tesselation_BoundaryTriangleUnitTest_SOURCES = UnitTestMain.cpp tesselation_boundarytriangleunittest.cpp tesselation_boundarytriangleunittest.hpp Stubs/TesselPoint_stub.cpp Stubs/TesselPoint_stub.hpp 227 227 Tesselation_BoundaryTriangleUnitTest_LDADD = ${ALLLIBS} 228 228 229 Tesselation_InOutsideUnitTest_SOURCES = UnitTestMain.cpp tesselation_insideoutsideunittest.cpp tesselation_insideoutsideunittest.hpp 229 Tesselation_InOutsideUnitTest_SOURCES = UnitTestMain.cpp tesselation_insideoutsideunittest.cpp tesselation_insideoutsideunittest.hpp Stubs/TesselPoint_stub.cpp Stubs/TesselPoint_stub.hpp 230 230 Tesselation_InOutsideUnitTest_LDADD = ${ALLLIBS} 231 231 232 TestRunner_SOURCES = TestRunnerMain.cpp $(TESTSOURCES) $(TESTHEADERS) 232 TestRunner_SOURCES = TestRunnerMain.cpp $(TESTSOURCES) $(TESTHEADERS) Stubs/TesselPoint_stub.cpp Stubs/TesselPoint_stub.hpp 233 233 TestRunner_LDADD = ${ALLLIBS} 234 234 -
src/unittests/ParserUnitTest.cpp
r5fbaeb rd74077 208 208 input << Tremolo_Atomdata2; 209 209 testParser->load(&input); 210 CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))-> x[0]== 3.0);210 CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->at(0) == 3.0); 211 211 input.clear(); 212 212 } … … 219 219 input << Tremolo_velocity; 220 220 testParser->load(&input); 221 CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))-> v[0] == 3.0);221 CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->AtomicVelocity[0] == 3.0); 222 222 input.clear(); 223 223 } … … 271 271 // with the maximum number of fields and minimal information, default values are printed 272 272 atom* newAtom = World::getInstance().createAtom(); 273 newAtom-> type = World::getInstance().getPeriode()->FindElement(1);273 newAtom->setType(1); 274 274 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"); 275 275 testParser->save(&output); … … 304 304 atom *Walker = NULL; 305 305 Walker = World::getInstance().createAtom(); 306 Walker-> type = World::getInstance().getPeriode()->FindElement(8);307 Walker-> x = Vector(0,0,0);306 Walker->setType(8); 307 Walker->setPosition(Vector(0,0,0)); 308 308 Walker = World::getInstance().createAtom(); 309 Walker-> type = World::getInstance().getPeriode()->FindElement(1);310 Walker-> x = Vector(0.758602,0,0.504284);309 Walker->setType(1); 310 Walker->setPosition(Vector(0.758602,0,0.504284)); 311 311 Walker = World::getInstance().createAtom(); 312 Walker-> type = World::getInstance().getPeriode()->FindElement(1);313 Walker-> x = Vector(0.758602,0,-0.504284);312 Walker->setType(1); 313 Walker->setPosition(Vector(0.758602,0,-0.504284)); 314 314 CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms()); 315 315 -
src/unittests/analysisbondsunittest.cpp
r5fbaeb rd74077 16 16 #include <cstring> 17 17 18 #include "World.hpp"19 18 #include "analysis_bonds.hpp" 20 19 #include "analysisbondsunittest.hpp" … … 25 24 #include "molecule.hpp" 26 25 #include "periodentafel.hpp" 26 #include "vector.hpp" 27 27 #include "World.hpp" 28 28 … … 52 52 Walker = World::getInstance().createAtom(); 53 53 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 54 Walker-> type = hydrogen;55 *Walker->node = Vector(1.5, 0., 1.5);54 Walker->setType(hydrogen); 55 Walker->setPosition(Vector(1.5, 0., 1.5 )); 56 56 TestMolecule->AddAtom(Walker); 57 57 Walker = World::getInstance().createAtom(); 58 58 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 59 Walker-> type = hydrogen;60 *Walker->node = Vector(0., 1.5, 1.5);59 Walker->setType(hydrogen); 60 Walker->setPosition(Vector(0., 1.5, 1.5 )); 61 61 TestMolecule->AddAtom(Walker); 62 62 Walker = World::getInstance().createAtom(); 63 63 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 64 Walker-> type = hydrogen;65 *Walker->node = Vector(1.5, 1.5, 0.);64 Walker->setType(hydrogen); 65 Walker->setPosition(Vector(1.5, 1.5, 0. )); 66 66 TestMolecule->AddAtom(Walker); 67 67 Walker = World::getInstance().createAtom(); 68 68 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 69 Walker-> type = hydrogen;70 *Walker->node = Vector(0., 0., 0.);69 Walker->setType(hydrogen); 70 Walker->setPosition(Vector(0., 0., 0. )); 71 71 TestMolecule->AddAtom(Walker); 72 72 Walker = World::getInstance().createAtom(); 73 73 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 74 Walker-> type = carbon;75 *Walker->node = Vector(0.5, 0.5, 0.5);74 Walker->setType(carbon); 75 Walker->setPosition(Vector(0.5, 0.5, 0.5 )); 76 76 TestMolecule->AddAtom(Walker); 77 77 -
src/unittests/bondgraphunittest.cpp
r5fbaeb rd74077 54 54 Walker = World::getInstance().createAtom(); 55 55 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 56 Walker-> type = carbon;57 *Walker->node = Vector(1., 0., 1.);56 Walker->setType(carbon); 57 Walker->setPosition(Vector(1., 0., 1. )); 58 58 TestMolecule->AddAtom(Walker); 59 59 60 60 Walker = World::getInstance().createAtom(); 61 61 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 62 Walker-> type = carbon;63 *Walker->node = Vector(0., 1., 1.);62 Walker->setType(carbon); 63 Walker->setPosition(Vector(0., 1., 1. )); 64 64 TestMolecule->AddAtom(Walker); 65 65 66 66 Walker = World::getInstance().createAtom(); 67 67 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 68 Walker-> type = carbon;69 *Walker->node = Vector(1., 1., 0.);68 Walker->setType(carbon); 69 Walker->setPosition(Vector(1., 1., 0. )); 70 70 TestMolecule->AddAtom(Walker); 71 71 72 72 Walker = World::getInstance().createAtom(); 73 73 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 74 Walker-> type = carbon;75 *Walker->node = Vector(0., 0., 0.);74 Walker->setType(carbon); 75 Walker->setPosition(Vector(0., 0., 0. )); 76 76 TestMolecule->AddAtom(Walker); 77 77 -
src/unittests/listofbondsunittest.cpp
r5fbaeb rd74077 47 47 Walker = World::getInstance().createAtom(); 48 48 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 49 Walker-> type = hydrogen;50 *Walker->node = Vector(1., 0., 1.);51 TestMolecule->AddAtom(Walker); 52 Walker = World::getInstance().createAtom(); 53 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 54 Walker-> type = hydrogen;55 *Walker->node = Vector(0., 1., 1.);56 TestMolecule->AddAtom(Walker); 57 Walker = World::getInstance().createAtom(); 58 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 59 Walker-> type = hydrogen;60 *Walker->node = Vector(1., 1., 0.);61 TestMolecule->AddAtom(Walker); 62 Walker = World::getInstance().createAtom(); 63 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 64 Walker-> type = hydrogen;65 *Walker->node = Vector(0., 0., 0.);49 Walker->setType(hydrogen); 50 Walker->setPosition(Vector(1., 0., 1. )); 51 TestMolecule->AddAtom(Walker); 52 Walker = World::getInstance().createAtom(); 53 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 54 Walker->setType(hydrogen); 55 Walker->setPosition(Vector(0., 1., 1. )); 56 TestMolecule->AddAtom(Walker); 57 Walker = World::getInstance().createAtom(); 58 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 59 Walker->setType(hydrogen); 60 Walker->setPosition(Vector(1., 1., 0. )); 61 TestMolecule->AddAtom(Walker); 62 Walker = World::getInstance().createAtom(); 63 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 64 Walker->setType(hydrogen); 65 Walker->setPosition(Vector(0., 0., 0. )); 66 66 TestMolecule->AddAtom(Walker); 67 67 -
src/unittests/tesselation_boundarytriangleunittest.cpp
r5fbaeb rd74077 13 13 14 14 #include <cstring> 15 #include <iostream> 15 16 16 17 #include "defs.hpp" 17 #include "tesselation.hpp" 18 #include "TesselPoint.hpp" 19 #include "BoundaryPointSet.hpp" 20 #include "BoundaryLineSet.hpp" 21 #include "BoundaryTriangleSet.hpp" 22 #include "CandidateForTesselation.hpp" 18 23 #include "tesselation_boundarytriangleunittest.hpp" 19 24 … … 36 41 // create nodes 37 42 tesselpoints[0] = new TesselPoint; 38 tesselpoints[0]-> node = new Vector(0., 0., 0.);43 tesselpoints[0]->setPosition(Vector(0., 0., 0.)); 39 44 tesselpoints[0]->setName("1"); 40 45 tesselpoints[0]->nr = 1; 41 46 points[0] = new BoundaryPointSet(tesselpoints[0]); 42 47 tesselpoints[1] = new TesselPoint; 43 tesselpoints[1]-> node = new Vector(0., 1., 0.);48 tesselpoints[1]->setPosition(Vector(0., 1., 0.)); 44 49 tesselpoints[1]->setName("2"); 45 50 tesselpoints[1]->nr = 2; 46 51 points[1] = new BoundaryPointSet(tesselpoints[1]); 47 52 tesselpoints[2] = new TesselPoint; 48 tesselpoints[2]-> node = new Vector(1., 0., 0.);53 tesselpoints[2]->setPosition(Vector(1., 0., 0.)); 49 54 tesselpoints[2]->setName("3"); 50 55 tesselpoints[2]->nr = 3; … … 67 72 for (int i=0;i<3;++i) { 68 73 // TesselPoint does not delete its vector as it only got a reference 69 delete tesselpoints[i]->node;70 74 delete tesselpoints[i]; 71 75 } … … 83 87 // simple test on y line 84 88 Point = Vector(-1.,0.5,0.); 85 CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );89 CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 86 90 Point = Vector(0.,0.5,0.); 87 91 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); 88 92 Point = Vector(-4.,0.5,0.); 89 CPPUNIT_ASSERT_EQUAL( 16., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );93 CPPUNIT_ASSERT_EQUAL( 16., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 90 94 Point = Vector(0.,0.5,0.); 91 95 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 93 97 // simple test on x line 94 98 Point = Vector(0.5,-1.,0.); 95 CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );99 CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 96 100 Point = Vector(0.5,0.,0.); 97 101 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); 98 102 Point = Vector(0.5,-6.,0.); 99 CPPUNIT_ASSERT_EQUAL( 36., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );103 CPPUNIT_ASSERT_EQUAL( 36., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 100 104 Point = Vector(0.5,0.,0.); 101 105 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 103 107 // simple test on slanted line 104 108 Point = Vector(1.,1.,0.); 105 CPPUNIT_ASSERT_EQUAL( 0.5, triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );109 CPPUNIT_ASSERT_EQUAL( 0.5, triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 106 110 Point = Vector(0.5,0.5,0.); 107 111 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); 108 112 Point = Vector(5.,5.,0.); 109 CPPUNIT_ASSERT_EQUAL( 40.5, triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );113 CPPUNIT_ASSERT_EQUAL( 40.5, triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 110 114 Point = Vector(0.5,0.5,0.); 111 115 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 113 117 // simple test on first node 114 118 Point = Vector(-1.,-1.,0.); 115 CPPUNIT_ASSERT_EQUAL( 2., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );119 CPPUNIT_ASSERT_EQUAL( 2., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 116 120 Point = Vector(0.,0.,0.); 117 121 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 119 123 // simple test on second node 120 124 Point = Vector(0.,2.,0.); 121 CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );125 CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 122 126 Point = Vector(0.,1.,0.); 123 127 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 125 129 // simple test on third node 126 130 Point = Vector(2.,0.,0.); 127 CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );131 CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 128 132 Point = Vector(1.,0.,0.); 129 133 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 139 143 // straight down/up 140 144 Point = Vector(1./3.,1./3.,+5.); 141 CPPUNIT_ASSERT_EQUAL( 25. , triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );145 CPPUNIT_ASSERT_EQUAL( 25. , triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 142 146 Point = Vector(1./3.,1./3.,0.); 143 147 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); 144 148 Point = Vector(1./3.,1./3.,-5.); 145 CPPUNIT_ASSERT_EQUAL( 25. , triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );149 CPPUNIT_ASSERT_EQUAL( 25. , triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 146 150 Point = Vector(1./3.,1./3.,0.); 147 151 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 149 153 // simple test on y line 150 154 Point = Vector(-1.,0.5,+2.); 151 CPPUNIT_ASSERT_EQUAL( 5., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );155 CPPUNIT_ASSERT_EQUAL( 5., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 152 156 Point = Vector(0.,0.5,0.); 153 157 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); 154 158 Point = Vector(-1.,0.5,-3.); 155 CPPUNIT_ASSERT_EQUAL( 10., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );159 CPPUNIT_ASSERT_EQUAL( 10., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 156 160 Point = Vector(0.,0.5,0.); 157 161 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 159 163 // simple test on x line 160 164 Point = Vector(0.5,-1.,+1.); 161 CPPUNIT_ASSERT_EQUAL( 2., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );165 CPPUNIT_ASSERT_EQUAL( 2., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 162 166 Point = Vector(0.5,0.,0.); 163 167 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); 164 168 Point = Vector(0.5,-1.,-2.); 165 CPPUNIT_ASSERT_EQUAL( 5., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );169 CPPUNIT_ASSERT_EQUAL( 5., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 166 170 Point = Vector(0.5,0.,0.); 167 171 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 169 173 // simple test on slanted line 170 174 Point = Vector(1.,1.,+3.); 171 CPPUNIT_ASSERT_EQUAL( 9.5, triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );175 CPPUNIT_ASSERT_EQUAL( 9.5, triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 172 176 Point = Vector(0.5,0.5,0.); 173 177 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); 174 178 Point = Vector(1.,1.,-4.); 175 CPPUNIT_ASSERT_EQUAL( 16.5, triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );179 CPPUNIT_ASSERT_EQUAL( 16.5, triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 176 180 Point = Vector(0.5,0.5,0.); 177 181 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 179 183 // simple test on first node 180 184 Point = Vector(-1.,-1.,5.); 181 CPPUNIT_ASSERT_EQUAL( 27., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );185 CPPUNIT_ASSERT_EQUAL( 27., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 182 186 Point = Vector(0.,0.,0.); 183 187 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 185 189 // simple test on second node 186 190 Point = Vector(0.,2.,5.); 187 CPPUNIT_ASSERT_EQUAL( 26., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );191 CPPUNIT_ASSERT_EQUAL( 26., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 188 192 Point = Vector(0.,1.,0.); 189 193 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 191 195 // simple test on third node 192 196 Point = Vector(2.,0.,5.); 193 CPPUNIT_ASSERT_EQUAL( 26., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );197 CPPUNIT_ASSERT_EQUAL( 26., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 194 198 Point = Vector(1.,0.,0.); 195 199 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); -
src/unittests/tesselation_boundarytriangleunittest.hpp
r5fbaeb rd74077 15 15 #include "linkedcell.hpp" 16 16 #include "tesselation.hpp" 17 18 class TesselPoint; 17 19 18 20 /********************************************** Test classes **************************************/ -
src/unittests/tesselation_insideoutsideunittest.cpp
r5fbaeb rd74077 13 13 14 14 #include <cstring> 15 #include <iostream> 15 16 16 17 #include "defs.hpp" 17 #include "tesselation.hpp" 18 #include "TesselPoint.hpp" 19 #include "BoundaryLineSet.hpp" 20 #include "BoundaryTriangleSet.hpp" 21 #include "CandidateForTesselation.hpp" 18 22 #include "tesselation_insideoutsideunittest.hpp" 19 23 #include "verbose.hpp" … … 30 34 CPPUNIT_TEST_SUITE_REGISTRATION( TesselationInOutsideTest ); 31 35 32 33 36 void TesselationInOutsideTest::setUp() 34 37 { … … 38 41 class TesselPoint *Walker; 39 42 Walker = new TesselPoint; 40 Walker-> node = new Vector(0., 0., 0.);43 Walker->setPosition(Vector(0., 0., 0.)); 41 44 Walker->setName("1"); 42 45 Walker->nr = 1; 43 46 Corners.push_back(Walker); 44 47 Walker = new TesselPoint; 45 Walker-> node = new Vector(0., 1., 0.);48 Walker->setPosition(Vector(0., 1., 0.)); 46 49 Walker->setName("2"); 47 50 Walker->nr = 2; 48 51 Corners.push_back(Walker); 49 52 Walker = new TesselPoint; 50 Walker-> node = new Vector(1., 0., 0.);53 Walker->setPosition(Vector(1., 0., 0.)); 51 54 Walker->setName("3"); 52 55 Walker->nr = 3; 53 56 Corners.push_back(Walker); 54 57 Walker = new TesselPoint; 55 Walker-> node = new Vector(1., 1., 0.);58 Walker->setPosition(Vector(1., 1., 0.)); 56 59 Walker->setName("4"); 57 60 Walker->nr = 4; 58 61 Corners.push_back(Walker); 59 62 Walker = new TesselPoint; 60 Walker-> node = new Vector(0., 0., 1.);63 Walker->setPosition(Vector(0., 0., 1.)); 61 64 Walker->setName("5"); 62 65 Walker->nr = 5; 63 66 Corners.push_back(Walker); 64 67 Walker = new TesselPoint; 65 Walker-> node = new Vector(0., 1., 1.);68 Walker->setPosition(Vector(0., 1., 1.)); 66 69 Walker->setName("6"); 67 70 Walker->nr = 6; 68 71 Corners.push_back(Walker); 69 72 Walker = new TesselPoint; 70 Walker-> node = new Vector(1., 0., 1.);73 Walker->setPosition(Vector(1., 0., 1.)); 71 74 Walker->setName("7"); 72 75 Walker->nr = 7; 73 76 Corners.push_back(Walker); 74 77 Walker = new TesselPoint; 75 Walker-> node = new Vector(1., 1., 1.);78 Walker->setPosition(Vector(1., 1., 1.)); 76 79 Walker->setName("8"); 77 80 Walker->nr = 8; … … 130 133 delete(LinkedList); 131 134 delete(TesselStruct); 132 for (LinkedCell::LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) { 133 delete((*Runner)->node); 135 for (LinkedCell::LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) 134 136 delete(*Runner); 135 }136 137 Corners.clear(); 137 138 logger::purgeInstance(); -
src/unittests/tesselationunittest.cpp
r5fbaeb rd74077 16 16 17 17 #include "defs.hpp" 18 #include "tesselation.hpp" 18 #include "TesselPoint.hpp" 19 #include "BoundaryLineSet.hpp" 20 #include "BoundaryTriangleSet.hpp" 21 #include "CandidateForTesselation.hpp" 19 22 #include "tesselationunittest.hpp" 20 23 … … 36 39 class TesselPoint *Walker; 37 40 Walker = new TesselPoint; 38 Walker-> node = new Vector(1., 0., -1.);41 Walker->setPosition(Vector(1., 0., -1.)); 39 42 Walker->setName("1"); 40 43 Walker->nr = 1; 41 44 Corners.push_back(Walker); 42 45 Walker = new TesselPoint; 43 Walker-> node = new Vector(-1., 1., -1.);46 Walker->setPosition(Vector(-1., 1., -1.)); 44 47 Walker->setName("2"); 45 48 Walker->nr = 2; 46 49 Corners.push_back(Walker); 47 50 Walker = new TesselPoint; 48 Walker-> node = new Vector(-1., -1., -1.);51 Walker->setPosition(Vector(-1., -1., -1.)); 49 52 Walker->setName("3"); 50 53 Walker->nr = 3; 51 54 Corners.push_back(Walker); 52 55 Walker = new TesselPoint; 53 Walker-> node = new Vector(-1., 0., 1.);56 Walker->setPosition(Vector(-1., 0., 1.)); 54 57 Walker->setName("4"); 55 58 Walker->nr = 4; … … 101 104 delete(LinkedList); 102 105 delete(TesselStruct); 103 for (LinkedCell::LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) { 104 delete((*Runner)->node); 106 for (LinkedCell::LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) 105 107 delete(*Runner); 106 }107 108 Corners.clear(); 108 109 logger::purgeInstance(); -
src/unittests/vectorunittest.cpp
r5fbaeb rd74077 52 52 errorLogger::purgeInstance(); 53 53 }; 54 55 /** UnitTest for Constructors and Vector::IsZero() and Vector::IsOne(). 56 */ 57 void VectorTest::AssignmentTest() 58 { 59 // test with zero 60 zero.at(0) = 0; 61 zero.at(1) = 0; 62 zero.at(2) = 0; 63 double zero_array[3] = {0., 0., 0.}; 64 65 CPPUNIT_ASSERT_EQUAL( zero, Vector(0,0,0)); 66 CPPUNIT_ASSERT_EQUAL( zero, Vector(0.,0.,0.)); 67 CPPUNIT_ASSERT_EQUAL( zero, Vector(zero_array[0], zero_array[1], zero_array[2])); 68 CPPUNIT_ASSERT_EQUAL( zero, Vector(zero_array)); 69 70 // test with unit 71 unit.at(0) = 1; 72 unit.at(1) = 0; 73 unit.at(2) = 0; 74 double unit_array[3] = {1., 0., 0.}; 75 76 CPPUNIT_ASSERT_EQUAL( unit, Vector(1,0,0)); 77 CPPUNIT_ASSERT_EQUAL( unit, Vector(1.,0.,0.)); 78 CPPUNIT_ASSERT_EQUAL( unit, Vector(unit_array[0], unit_array[1], unit_array[2])); 79 CPPUNIT_ASSERT_EQUAL( unit, Vector(unit_array)); 80 81 // test with two 82 two.at(0) = 2; 83 two.at(1) = 1; 84 two.at(2) = 0; 85 double two_array[3] = {2., 1., 0.}; 86 87 CPPUNIT_ASSERT_EQUAL( two, Vector(2,1,0)); 88 CPPUNIT_ASSERT_EQUAL( two, Vector(2.,1.,0.)); 89 CPPUNIT_ASSERT_EQUAL( two, Vector(two_array[0], two_array[1], two_array[2])); 90 CPPUNIT_ASSERT_EQUAL( two, Vector(two_array)); 91 92 // test with three 93 three.at(0) = 1; 94 three.at(1) = 2; 95 three.at(2) = 3; 96 double three_array[3] = {1., 2., 3.}; 97 98 CPPUNIT_ASSERT_EQUAL( three, Vector(1,2,3)); 99 CPPUNIT_ASSERT_EQUAL( three, Vector(1.,2.,3.)); 100 CPPUNIT_ASSERT_EQUAL( three, Vector(three_array[0], three_array[1], three_array[2])); 101 CPPUNIT_ASSERT_EQUAL( three, Vector(three_array)); 102 } 54 103 55 104 /** UnitTest for Constructors and Vector::IsZero() and Vector::IsOne(). -
src/unittests/vectorunittest.hpp
r5fbaeb rd74077 18 18 { 19 19 CPPUNIT_TEST_SUITE( VectorTest) ; 20 CPPUNIT_TEST ( AssignmentTest ); 20 21 CPPUNIT_TEST ( UnityTest ); 21 22 CPPUNIT_TEST ( SimpleAlgebraTest ); … … 33 34 void tearDown(); 34 35 36 void AssignmentTest(); 35 37 void UnityTest(); 36 38 void OperatorAlgebraTest();
Note:
See TracChangeset
for help on using the changeset viewer.