Changeset 55240c4 for src/unittests


Ignore:
Timestamp:
Jun 21, 2010, 7:56:00 AM (15 years ago)
Author:
Frederik Heber <heber@…>
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:
2f40c0e
Parents:
1b2d30 (diff), da3024 (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 'stable' into PcpAndMpqcParser

Conflicts:

molecuilder/src/Makefile.am

  • a single space after a "\"
Location:
src/unittests
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • src/unittests/CacheableTest.cpp

    r1b2d30 r55240c4  
    5555
    5656  threeNumbers(int _x,int _y, int _z) :
     57    Observable("threeNumbers"),
    5758    x(_x),y(_y),z(_z),
    58     sum(this,boost::bind(&threeNumbers::calcSum,this)),
     59    sum(this,boost::bind(&threeNumbers::calcSum,this),"sum"),
    5960    hasRecalced(false)
    6061  {}
     
    8182  CPPUNIT_ASSERT_EQUAL( 9, *(numbers->sum));
    8283  CPPUNIT_ASSERT_EQUAL( true, numbers->hasRecalced);
     84  numbers->hasRecalced=false;
     85  CPPUNIT_ASSERT_EQUAL( 9, *(numbers->sum));
     86#ifndef NO_CACHING
     87  CPPUNIT_ASSERT_EQUAL( false, numbers->hasRecalced);
     88#else
     89  CPPUNIT_ASSERT_EQUAL( true, numbers->hasRecalced);
     90#endif
    8391}
  • src/unittests/Makefile.am

    r1b2d30 r55240c4  
    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/ObserverTest.cpp

    r1b2d30 r55240c4  
    3333public:
    3434  UpdateCountObserver() :
     35    Observer("UpdateCountObserver"),
    3536    updates(0)
    3637  {};
     
    4546class SimpleObservable : public Observable {
    4647public:
     48  SimpleObservable() :
     49    Observable("SimpleObservable")
     50  {}
     51
    4752  void changeMethod() {
    4853    OBSERVE;
     
    5459class CallObservable : public Observable {
    5560public:
     61  CallObservable() :
     62    Observable("CallObservable")
     63  {}
     64
    5665  void changeMethod1() {
    5766    OBSERVE;
     
    7079class BlockObservable : public Observable {
    7180public:
     81  BlockObservable() :
     82    Observable("BlockObservable")
     83  {}
     84
    7285  void changeMethod1(){
    7386    OBSERVE;
     
    104117class SuperObservable : public Observable {
    105118public:
    106   SuperObservable(){
     119  SuperObservable():
     120    Observable("SuperObservable")
     121  {
    107122    subObservable = new SimpleObservable();
    108123    subObservable->signOn(this);
     
    123138public:
    124139  NotificationObservable() :
    125       notification1(new Notification(this)),
    126       notification2(new Notification(this))
     140    Observable("NotificationObservable"),
     141    notification1(new Notification(this)),
     142    notification2(new Notification(this))
    127143  {}
    128144
     
    149165public:
    150166  NotificationObserver(Notification_ptr notification) :
     167    Observer("NotificationObserver"),
    151168    requestedNotification(notification),
    152169    wasNotified(false)
     
    172189
    173190  ObservableCollection(int _num) :
    174   num(_num)
     191    Observable("ObservableCollection"),
     192    num(_num)
    175193  {
    176194    for(int i=0; i<num; ++i){
  • src/unittests/PlaneUnittest.cpp

    r1b2d30 r55240c4  
    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

    r1b2d30 r55240c4  
    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/listofbondsunittest.cpp

    r1b2d30 r55240c4  
    249249void ListOfBondsTest::DeleteAtomTest()
    250250{
    251   bond *Binder = NULL;
    252   molecule::iterator iter = TestMolecule->begin();
    253   atom *atom1 = *iter;
    254   iter++;
    255   atom *atom2 = *iter;
    256   CPPUNIT_ASSERT( atom1 != NULL );
    257   CPPUNIT_ASSERT( atom2 != NULL );
    258 
    259   // add bond
    260   Binder = TestMolecule->AddBond(atom1, atom2, 1);
    261   CPPUNIT_ASSERT( Binder != NULL );
     251  atom *atom1 = NULL;
     252  atom *atom2 = NULL;
     253  bond *Binder = NULL;
     254  {
     255    molecule::iterator iter = TestMolecule->begin();
     256    atom1 = *iter;
     257    iter++;
     258    atom2 = *iter;
     259  }
     260  CPPUNIT_ASSERT( atom1 != NULL );
     261  CPPUNIT_ASSERT( atom2 != NULL );
     262
     263  // add bond
     264  Binder = TestMolecule->AddBond(atom1, atom2, 1);
     265  CPPUNIT_ASSERT( Binder != NULL );
     266
     267  CPPUNIT_ASSERT_EQUAL( (size_t) 1, atom1->ListOfBonds.size() );
     268  CPPUNIT_ASSERT_EQUAL( (size_t) 1, atom2->ListOfBonds.size() );
     269
     270  CPPUNIT_ASSERT_EQUAL( true, TestMolecule->hasBondStructure() );
    262271
    263272  // remove atom2
     
    268277
    269278  // check if removed from molecule
    270   CPPUNIT_ASSERT_EQUAL( true, TestMolecule->hasBondStructure() );
    271 };
     279  CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() );
     280};
  • src/unittests/manipulateAtomsTest.cpp

    r1b2d30 r55240c4  
    5555public:
    5656  countObserver() :
     57    Observer("countObserver"),
    5758    count(0)
    5859    {}
  • src/unittests/vectorunittest.cpp

    r1b2d30 r55240c4  
    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

    r1b2d30 r55240c4  
    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.