Changeset 76c0d6 for src/unittests


Ignore:
Timestamp:
Jun 4, 2010, 9:28:46 AM (15 years ago)
Author:
Tillmann Crueger <crueger@…>
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:
2c8934
Parents:
e05826 (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.
Message:

Merge branch 'StructureRefactoring' into stable

Conflicts:

molecuilder/src/Makefile.am
molecuilder/src/periodentafel.cpp

Location:
src/unittests
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • src/unittests/Makefile.am

    re05826 r76c0d6  
    2626  InfoUnitTest \
    2727  LinearSystemOfEquationsUnitTest \
     28  LineUnittest \
    2829  LinkedCellUnitTest \
    2930  ListOfBondsUnitTest \
     
    6970  infounittest.cpp \
    7071  linearsystemofequationsunittest.cpp \
     72  LineUnittest.cpp \
    7173  LinkedCellUnitTest.cpp \
    7274  listofbondsunittest.cpp \
     
    104106  infounittest.hpp \
    105107  linearsystemofequationsunittest.hpp \
     108  LineUnittest.hpp \
    106109  LinkedCellUnitTest.hpp \
    107110  listofbondsunittest.hpp \
     
    170173LinearSystemOfEquationsUnitTest_LDADD = ${ALLLIBS}
    171174
     175LineUnittest_SOURCES = UnitTestMain.cpp LineUnittest.cpp LineUnittest.hpp
     176LineUnittest_LDADD = ${ALLLIBS}
     177
    172178LinkedCellUnitTest_SOURCES = UnitTestMain.cpp LinkedCellUnitTest.cpp LinkedCellUnitTest.hpp
    173179LinkedCellUnitTest_LDADD = ${ALLLIBS}
  • src/unittests/PlaneUnittest.cpp

    re05826 r76c0d6  
    1717
    1818#include "vector.hpp"
     19#include "Line.hpp"
    1920
    2021CPPUNIT_TEST_SUITE_REGISTRATION( PlaneUnittest );
     
    153154  CPPUNIT_ASSERT(fabs(p4->distance(e1)-1) < MYEPSILON);
    154155  CPPUNIT_ASSERT_EQUAL(zeroVec,p4->getClosestPoint(e1));
    155 
    156 
    157 }
     156}
     157
     158void 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
     205void 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

    re05826 r76c0d6  
    2020  CPPUNIT_TEST ( pointsTest );
    2121  CPPUNIT_TEST ( operationsTest );
     22  CPPUNIT_TEST ( mirrorTest );
     23  CPPUNIT_TEST ( LineIntersectionTest );
    2224  CPPUNIT_TEST_SUITE_END();
    2325
     
    3032  void pointsTest();
    3133  void operationsTest();
     34  void mirrorTest();
     35  void LineIntersectionTest();
    3236
    3337private:
  • src/unittests/vectorunittest.cpp

    re05826 r76c0d6  
    215215}
    216216
    217 /** UnitTest for line intersections.
    218  */
    219 void VectorTest::LineIntersectionTest()
    220 {
    221   // plane at (0,0,0) normal to (1,0,0) cuts line from (0,0,0) to (2,1,0) at ???
    222   CPPUNIT_ASSERT_NO_THROW(fixture = Plane(unit, zero).GetIntersection(zero, two) );
    223   CPPUNIT_ASSERT_EQUAL( zero, fixture );
    224 
    225   // plane at (2,1,0) normal to (0,1,0) cuts line from (1,0,0) to (0,1,1) at ???
    226   CPPUNIT_ASSERT_NO_THROW(fixture = Plane(otherunit, two).GetIntersection( unit, notunit) );
    227   CPPUNIT_ASSERT_EQUAL( Vector(0., 1., 1.), fixture );
    228 
    229   // four vectors equal to zero
    230   CPPUNIT_ASSERT_THROW(fixture = GetIntersectionOfTwoLinesOnPlane(zero, zero, zero, zero), LinearDependenceException);
    231   //CPPUNIT_ASSERT_EQUAL( zero, fixture );
    232 
    233   // four vectors equal to unit
    234   CPPUNIT_ASSERT_THROW(fixture = GetIntersectionOfTwoLinesOnPlane(unit, unit, unit, unit), LinearDependenceException);
    235   //CPPUNIT_ASSERT_EQUAL( zero, fixture );
    236 
    237   // two equal lines
    238   CPPUNIT_ASSERT_NO_THROW(fixture = GetIntersectionOfTwoLinesOnPlane(unit, two, unit, two));
    239   CPPUNIT_ASSERT_EQUAL( unit, fixture );
    240 
    241   // line from (1,0,0) to (2,1,0) cuts line from (1,0,0) to (0,1,0) at ???
    242   CPPUNIT_ASSERT_NO_THROW( fixture = GetIntersectionOfTwoLinesOnPlane(unit, two, unit, otherunit) );
    243   CPPUNIT_ASSERT_EQUAL( unit, fixture );
    244 
    245   // line from (1,0,0) to (0,0,0) cuts line from (0,0,0) to (2,1,0) at ???
    246   CPPUNIT_ASSERT_NO_THROW( fixture = GetIntersectionOfTwoLinesOnPlane(unit, zero, zero, two) );
    247   CPPUNIT_ASSERT_EQUAL( zero, fixture );
    248 
    249   // line from (1,0,0) to (2,1,0) cuts line from (0,0,0) to (0,1,0) at ???
    250   CPPUNIT_ASSERT_NO_THROW(fixture = GetIntersectionOfTwoLinesOnPlane(unit, two, zero, otherunit) );
    251   CPPUNIT_ASSERT_EQUAL( Vector(0., -1., 0.), fixture );
    252 };
    253 
    254 /** UnitTest for vector rotations.
    255  */
    256 void VectorTest::VectorRotationTest()
    257 {
    258   fixture = Vector(-1.,0.,0.);
    259 
    260   // zero vector does not change
    261   fixture = RotateVector(zero,unit, 1.);
    262   CPPUNIT_ASSERT_EQUAL( zero, fixture );
    263 
    264   fixture = RotateVector(zero, two, 1.);
    265   CPPUNIT_ASSERT_EQUAL( zero,  fixture);
    266 
    267   // vector on axis does not change
    268   fixture = RotateVector(unit,unit, 1.);
    269   CPPUNIT_ASSERT_EQUAL( unit, fixture );
    270 
    271   // rotations
    272   fixture = RotateVector(otherunit, unit, M_PI);
    273   CPPUNIT_ASSERT_EQUAL( Vector(0.,-1.,0.), fixture );
    274 
    275   fixture = RotateVector(otherunit, unit, 2. * M_PI);
    276   CPPUNIT_ASSERT_EQUAL( otherunit, fixture );
    277 
    278   fixture = RotateVector(otherunit,unit, 0);
    279   CPPUNIT_ASSERT_EQUAL( otherunit, fixture );
    280 
    281   fixture = RotateVector(Vector(0.,0.,1.), notunit, M_PI);
    282   CPPUNIT_ASSERT_EQUAL( otherunit, fixture );
    283 }
    284217
    285218/**
  • src/unittests/vectorunittest.hpp

    re05826 r76c0d6  
    2727    CPPUNIT_TEST ( ProjectionTest );
    2828    CPPUNIT_TEST ( NormalsTest );
    29     CPPUNIT_TEST ( LineIntersectionTest );
    30     CPPUNIT_TEST ( VectorRotationTest );
    3129    CPPUNIT_TEST ( IsInParallelepipedTest );
    3230    CPPUNIT_TEST_SUITE_END();
Note: See TracChangeset for help on using the changeset viewer.