Changeset a7c344 for src/unittests
- Timestamp:
- Jun 19, 2010, 4:06:59 PM (15 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:
- c39cc4
- Parents:
- b32dbb (diff), 27ac00 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src/unittests
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/unittests/Makefile.am
rb32dbb ra7c344 23 23 InfoUnitTest \ 24 24 LinearSystemOfEquationsUnitTest \ 25 LineUnittest \ 25 26 LinkedCellUnitTest \ 26 27 ListOfBondsUnitTest \ … … 64 65 infounittest.cpp \ 65 66 linearsystemofequationsunittest.cpp \ 67 LineUnittest.cpp \ 66 68 LinkedCellUnitTest.cpp \ 67 69 listofbondsunittest.cpp \ … … 97 99 infounittest.hpp \ 98 100 linearsystemofequationsunittest.hpp \ 101 LineUnittest.hpp \ 99 102 LinkedCellUnitTest.hpp \ 100 103 listofbondsunittest.hpp \ … … 153 156 LinearSystemOfEquationsUnitTest_LDADD = ${ALLLIBS} 154 157 158 LineUnittest_SOURCES = UnitTestMain.cpp LineUnittest.cpp LineUnittest.hpp 159 LineUnittest_LDADD = ${ALLLIBS} 160 155 161 LinkedCellUnitTest_SOURCES = UnitTestMain.cpp LinkedCellUnitTest.cpp LinkedCellUnitTest.hpp 156 162 LinkedCellUnitTest_LDADD = ${ALLLIBS} -
src/unittests/PlaneUnittest.cpp
rb32dbb ra7c344 17 17 18 18 #include "vector.hpp" 19 #include "Line.hpp" 19 20 20 21 CPPUNIT_TEST_SUITE_REGISTRATION( PlaneUnittest ); … … 153 154 CPPUNIT_ASSERT(fabs(p4->distance(e1)-1) < MYEPSILON); 154 155 CPPUNIT_ASSERT_EQUAL(zeroVec,p4->getClosestPoint(e1)); 155 156 157 } 156 } 157 158 void PlaneUnittest::mirrorTest(){ 159 Vector fixture; 160 161 // some Vectors that lie on the planes 162 fixture = p1->mirrorVector(e1); 163 CPPUNIT_ASSERT_EQUAL(fixture,e1); 164 fixture = p1->mirrorVector(e2); 165 CPPUNIT_ASSERT_EQUAL(fixture,e2); 166 fixture = p1->mirrorVector(e3); 167 CPPUNIT_ASSERT_EQUAL(fixture,e3); 168 169 fixture = p2->mirrorVector(zeroVec); 170 CPPUNIT_ASSERT_EQUAL(fixture,zeroVec); 171 fixture = p2->mirrorVector(e1); 172 CPPUNIT_ASSERT_EQUAL(fixture,e1); 173 fixture = p2->mirrorVector(e2); 174 CPPUNIT_ASSERT_EQUAL(fixture,e2); 175 176 fixture = p3->mirrorVector(zeroVec); 177 CPPUNIT_ASSERT_EQUAL(fixture,zeroVec); 178 fixture = p3->mirrorVector(e1); 179 CPPUNIT_ASSERT_EQUAL(fixture,e1); 180 fixture = p3->mirrorVector(e3); 181 CPPUNIT_ASSERT_EQUAL(fixture,e3); 182 183 fixture = p4->mirrorVector(zeroVec); 184 CPPUNIT_ASSERT_EQUAL(fixture,zeroVec); 185 fixture = p4->mirrorVector(e2); 186 CPPUNIT_ASSERT_EQUAL(fixture,e2); 187 fixture = p4->mirrorVector(e3); 188 CPPUNIT_ASSERT_EQUAL(fixture,e3); 189 190 // some Vectors outside of the planes 191 { 192 Vector t = (2./3.)*(e1+e2+e3); 193 fixture = p1->mirrorVector(zeroVec); 194 CPPUNIT_ASSERT_EQUAL(fixture,t); 195 } 196 197 fixture = p2->mirrorVector(e3); 198 CPPUNIT_ASSERT_EQUAL(fixture,-1*e3); 199 fixture = p3->mirrorVector(e2); 200 CPPUNIT_ASSERT_EQUAL(fixture,-1*e2); 201 fixture = p4->mirrorVector(e1); 202 CPPUNIT_ASSERT_EQUAL(fixture,-1*e1); 203 } 204 205 void PlaneUnittest::LineIntersectionTest(){ 206 Vector fixture; 207 // plane at (0,0,0) normal to (1,0,0) cuts line from (0,0,0) to (2,1,0) at ??? 208 Line l1 = makeLineThrough(zeroVec,Vector(2,1,0)); 209 CPPUNIT_ASSERT_NO_THROW(fixture = Plane(e1, zeroVec).GetIntersection(l1) ); 210 CPPUNIT_ASSERT_EQUAL( zeroVec, fixture ); 211 212 // plane at (2,1,0) normal to (0,1,0) cuts line from (1,0,0) to (0,1,1) at ??? 213 Line l2 = makeLineThrough(e1,Vector(0,1,1)); 214 CPPUNIT_ASSERT_NO_THROW(fixture = Plane(e2, Vector(2,1,0)).GetIntersection(l2) ); 215 CPPUNIT_ASSERT_EQUAL( Vector(0., 1., 1.), fixture ); 216 } -
src/unittests/PlaneUnittest.hpp
rb32dbb ra7c344 20 20 CPPUNIT_TEST ( pointsTest ); 21 21 CPPUNIT_TEST ( operationsTest ); 22 CPPUNIT_TEST ( mirrorTest ); 23 CPPUNIT_TEST ( LineIntersectionTest ); 22 24 CPPUNIT_TEST_SUITE_END(); 23 25 … … 30 32 void pointsTest(); 31 33 void operationsTest(); 34 void mirrorTest(); 35 void LineIntersectionTest(); 32 36 33 37 private: -
src/unittests/vectorunittest.cpp
rb32dbb ra7c344 216 216 } 217 217 218 /** UnitTest for line intersections.219 */220 void VectorTest::LineIntersectionTest()221 {222 // plane at (0,0,0) normal to (1,0,0) cuts line from (0,0,0) to (2,1,0) at ???223 CPPUNIT_ASSERT_NO_THROW(fixture = Plane(unit, zero).GetIntersection(zero, two) );224 CPPUNIT_ASSERT_EQUAL( zero, fixture );225 226 // plane at (2,1,0) normal to (0,1,0) cuts line from (1,0,0) to (0,1,1) at ???227 CPPUNIT_ASSERT_NO_THROW(fixture = Plane(otherunit, two).GetIntersection( unit, notunit) );228 CPPUNIT_ASSERT_EQUAL( Vector(0., 1., 1.), fixture );229 230 // four vectors equal to zero231 CPPUNIT_ASSERT_THROW(fixture = GetIntersectionOfTwoLinesOnPlane(zero, zero, zero, zero), LinearDependenceException);232 //CPPUNIT_ASSERT_EQUAL( zero, fixture );233 234 // four vectors equal to unit235 CPPUNIT_ASSERT_THROW(fixture = GetIntersectionOfTwoLinesOnPlane(unit, unit, unit, unit), LinearDependenceException);236 //CPPUNIT_ASSERT_EQUAL( zero, fixture );237 238 // two equal lines239 CPPUNIT_ASSERT_NO_THROW(fixture = GetIntersectionOfTwoLinesOnPlane(unit, two, unit, two));240 CPPUNIT_ASSERT_EQUAL( unit, fixture );241 242 // line from (1,0,0) to (2,1,0) cuts line from (1,0,0) to (0,1,0) at ???243 CPPUNIT_ASSERT_NO_THROW( fixture = GetIntersectionOfTwoLinesOnPlane(unit, two, unit, otherunit) );244 CPPUNIT_ASSERT_EQUAL( unit, fixture );245 246 // line from (1,0,0) to (0,0,0) cuts line from (0,0,0) to (2,1,0) at ???247 CPPUNIT_ASSERT_NO_THROW( fixture = GetIntersectionOfTwoLinesOnPlane(unit, zero, zero, two) );248 CPPUNIT_ASSERT_EQUAL( zero, fixture );249 250 // line from (1,0,0) to (2,1,0) cuts line from (0,0,0) to (0,1,0) at ???251 CPPUNIT_ASSERT_NO_THROW(fixture = GetIntersectionOfTwoLinesOnPlane(unit, two, zero, otherunit) );252 CPPUNIT_ASSERT_EQUAL( Vector(0., -1., 0.), fixture );253 };254 255 /** UnitTest for vector rotations.256 */257 void VectorTest::VectorRotationTest()258 {259 fixture = Vector(-1.,0.,0.);260 261 // zero vector does not change262 fixture = RotateVector(zero,unit, 1.);263 CPPUNIT_ASSERT_EQUAL( zero, fixture );264 265 fixture = RotateVector(zero, two, 1.);266 CPPUNIT_ASSERT_EQUAL( zero, fixture);267 268 // vector on axis does not change269 fixture = RotateVector(unit,unit, 1.);270 CPPUNIT_ASSERT_EQUAL( unit, fixture );271 272 // rotations273 fixture = RotateVector(otherunit, unit, M_PI);274 CPPUNIT_ASSERT_EQUAL( Vector(0.,-1.,0.), fixture );275 276 fixture = RotateVector(otherunit, unit, 2. * M_PI);277 CPPUNIT_ASSERT_EQUAL( otherunit, fixture );278 279 fixture = RotateVector(otherunit,unit, 0);280 CPPUNIT_ASSERT_EQUAL( otherunit, fixture );281 282 fixture = RotateVector(Vector(0.,0.,1.), notunit, M_PI);283 CPPUNIT_ASSERT_EQUAL( otherunit, fixture );284 }285 218 286 219 /** -
src/unittests/vectorunittest.hpp
rb32dbb ra7c344 27 27 CPPUNIT_TEST ( ProjectionTest ); 28 28 CPPUNIT_TEST ( NormalsTest ); 29 CPPUNIT_TEST ( LineIntersectionTest );30 CPPUNIT_TEST ( VectorRotationTest );31 29 CPPUNIT_TEST ( IsInParallelepipedTest ); 32 30 CPPUNIT_TEST_SUITE_END();
Note:
See TracChangeset
for help on using the changeset viewer.