Changeset 55240c4 for src/unittests
- Timestamp:
- Jun 21, 2010, 7:56:00 AM (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:
- 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. - Location:
- src/unittests
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
src/unittests/CacheableTest.cpp
r1b2d30 r55240c4 55 55 56 56 threeNumbers(int _x,int _y, int _z) : 57 Observable("threeNumbers"), 57 58 x(_x),y(_y),z(_z), 58 sum(this,boost::bind(&threeNumbers::calcSum,this) ),59 sum(this,boost::bind(&threeNumbers::calcSum,this),"sum"), 59 60 hasRecalced(false) 60 61 {} … … 81 82 CPPUNIT_ASSERT_EQUAL( 9, *(numbers->sum)); 82 83 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 83 91 } -
src/unittests/Makefile.am
r1b2d30 r55240c4 26 26 InfoUnitTest \ 27 27 LinearSystemOfEquationsUnitTest \ 28 LineUnittest \ 28 29 LinkedCellUnitTest \ 29 30 ListOfBondsUnitTest \ … … 69 70 infounittest.cpp \ 70 71 linearsystemofequationsunittest.cpp \ 72 LineUnittest.cpp \ 71 73 LinkedCellUnitTest.cpp \ 72 74 listofbondsunittest.cpp \ … … 104 106 infounittest.hpp \ 105 107 linearsystemofequationsunittest.hpp \ 108 LineUnittest.hpp \ 106 109 LinkedCellUnitTest.hpp \ 107 110 listofbondsunittest.hpp \ … … 170 173 LinearSystemOfEquationsUnitTest_LDADD = ${ALLLIBS} 171 174 175 LineUnittest_SOURCES = UnitTestMain.cpp LineUnittest.cpp LineUnittest.hpp 176 LineUnittest_LDADD = ${ALLLIBS} 177 172 178 LinkedCellUnitTest_SOURCES = UnitTestMain.cpp LinkedCellUnitTest.cpp LinkedCellUnitTest.hpp 173 179 LinkedCellUnitTest_LDADD = ${ALLLIBS} -
src/unittests/ObserverTest.cpp
r1b2d30 r55240c4 33 33 public: 34 34 UpdateCountObserver() : 35 Observer("UpdateCountObserver"), 35 36 updates(0) 36 37 {}; … … 45 46 class SimpleObservable : public Observable { 46 47 public: 48 SimpleObservable() : 49 Observable("SimpleObservable") 50 {} 51 47 52 void changeMethod() { 48 53 OBSERVE; … … 54 59 class CallObservable : public Observable { 55 60 public: 61 CallObservable() : 62 Observable("CallObservable") 63 {} 64 56 65 void changeMethod1() { 57 66 OBSERVE; … … 70 79 class BlockObservable : public Observable { 71 80 public: 81 BlockObservable() : 82 Observable("BlockObservable") 83 {} 84 72 85 void changeMethod1(){ 73 86 OBSERVE; … … 104 117 class SuperObservable : public Observable { 105 118 public: 106 SuperObservable(){ 119 SuperObservable(): 120 Observable("SuperObservable") 121 { 107 122 subObservable = new SimpleObservable(); 108 123 subObservable->signOn(this); … … 123 138 public: 124 139 NotificationObservable() : 125 notification1(new Notification(this)), 126 notification2(new Notification(this)) 140 Observable("NotificationObservable"), 141 notification1(new Notification(this)), 142 notification2(new Notification(this)) 127 143 {} 128 144 … … 149 165 public: 150 166 NotificationObserver(Notification_ptr notification) : 167 Observer("NotificationObserver"), 151 168 requestedNotification(notification), 152 169 wasNotified(false) … … 172 189 173 190 ObservableCollection(int _num) : 174 num(_num) 191 Observable("ObservableCollection"), 192 num(_num) 175 193 { 176 194 for(int i=0; i<num; ++i){ -
src/unittests/PlaneUnittest.cpp
r1b2d30 r55240c4 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
r1b2d30 r55240c4 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/listofbondsunittest.cpp
r1b2d30 r55240c4 249 249 void ListOfBondsTest::DeleteAtomTest() 250 250 { 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() ); 262 271 263 272 // remove atom2 … … 268 277 269 278 // 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 55 55 public: 56 56 countObserver() : 57 Observer("countObserver"), 57 58 count(0) 58 59 {} -
src/unittests/vectorunittest.cpp
r1b2d30 r55240c4 215 215 } 216 216 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 zero230 CPPUNIT_ASSERT_THROW(fixture = GetIntersectionOfTwoLinesOnPlane(zero, zero, zero, zero), LinearDependenceException);231 //CPPUNIT_ASSERT_EQUAL( zero, fixture );232 233 // four vectors equal to unit234 CPPUNIT_ASSERT_THROW(fixture = GetIntersectionOfTwoLinesOnPlane(unit, unit, unit, unit), LinearDependenceException);235 //CPPUNIT_ASSERT_EQUAL( zero, fixture );236 237 // two equal lines238 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 change261 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 change268 fixture = RotateVector(unit,unit, 1.);269 CPPUNIT_ASSERT_EQUAL( unit, fixture );270 271 // rotations272 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 }284 217 285 218 /** -
src/unittests/vectorunittest.hpp
r1b2d30 r55240c4 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.