Changeset d5f216 for src/unittests
- Timestamp:
- Feb 2, 2010, 12:00:19 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:
- bfce50
- Parents:
- 63c1f6
- git-author:
- Tillmann Crueger <crueger@…> (01/21/10 14:01:16)
- git-committer:
- Tillmann Crueger <crueger@…> (02/02/10 12:00:19)
- Location:
- src/unittests
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/unittests/ObserverTest.cpp
r63c1f6 rd5f216 86 86 87 87 void ObserverTest::setUp() { 88 simpleObservable = new SimpleObservable(); 88 simpleObservable1 = new SimpleObservable(); 89 simpleObservable2 = new SimpleObservable(); 89 90 callObservable = new CallObservable(); 90 91 superObservable = new SuperObservable(); … … 93 94 observer2 = new UpdateCountObserver(); 94 95 observer3 = new UpdateCountObserver(); 96 observer4 = new UpdateCountObserver(); 95 97 } 96 98 97 99 void ObserverTest::tearDown() { 98 delete simpleObservable; 100 delete simpleObservable1; 101 delete simpleObservable2; 99 102 delete callObservable; 100 103 delete superObservable; … … 103 106 delete observer2; 104 107 delete observer3; 108 delete observer4; 105 109 } 106 110 107 111 void ObserverTest::doesUpdateTest() 108 112 { 109 simpleObservable->signOn(observer1); 110 simpleObservable->signOn(observer2); 111 simpleObservable->signOn(observer3); 112 113 simpleObservable->changeMethod(); 113 simpleObservable1->signOn(observer1); 114 simpleObservable1->signOn(observer2); 115 simpleObservable1->signOn(observer3); 116 simpleObservable2->signOn(observer2); 117 simpleObservable2->signOn(observer4); 118 119 simpleObservable1->changeMethod(); 114 120 CPPUNIT_ASSERT_EQUAL( 1, observer1->updates ); 115 121 CPPUNIT_ASSERT_EQUAL( 1, observer2->updates ); 116 122 CPPUNIT_ASSERT_EQUAL( 1, observer3->updates ); 117 118 simpleObservable->signOff(observer3); 119 120 simpleObservable->changeMethod(); 123 CPPUNIT_ASSERT_EQUAL( 0, observer4->updates ); 124 125 simpleObservable1->signOff(observer3); 126 127 simpleObservable1->changeMethod(); 121 128 CPPUNIT_ASSERT_EQUAL( 2, observer1->updates ); 122 129 CPPUNIT_ASSERT_EQUAL( 2, observer2->updates ); 123 130 CPPUNIT_ASSERT_EQUAL( 1, observer3->updates ); 131 CPPUNIT_ASSERT_EQUAL( 0, observer4->updates ); 132 133 simpleObservable2->changeMethod(); 134 CPPUNIT_ASSERT_EQUAL( 2, observer1->updates ); 135 CPPUNIT_ASSERT_EQUAL( 3, observer2->updates ); 136 CPPUNIT_ASSERT_EQUAL( 1, observer3->updates ); 137 CPPUNIT_ASSERT_EQUAL( 1, observer4->updates ); 124 138 } 125 139 … … 155 169 cout << "If this test does not complete in a few seconds, kill the test-suite and fix the Error in the circle detection mechanism" << endl; 156 170 157 cout << endl << endl << "The following error displayed by the observer framwork can be ignored" << endl;171 cout << endl << endl << "The following errors displayed by the observer framework can be ignored" << endl; 158 172 159 173 // make this Observable its own subject. NEVER DO THIS IN ACTUAL CODE 160 simpleObservable->signOn(simpleObservable); 161 simpleObservable->changeMethod(); 174 simpleObservable1->signOn(simpleObservable1); 175 simpleObservable1->changeMethod(); 176 177 // more complex test 178 simpleObservable1->signOff(simpleObservable1); 179 simpleObservable1->signOn(simpleObservable2); 180 simpleObservable2->signOn(simpleObservable1); 181 simpleObservable1->changeMethod(); 182 simpleObservable1->signOff(simpleObservable2); 183 simpleObservable2->signOff(simpleObservable1); 162 184 // when we reach this line, although we broke the DAG assumption the circle check works fine 163 185 CPPUNIT_ASSERT(true); -
src/unittests/ObserverTest.hpp
r63c1f6 rd5f216 40 40 UpdateCountObserver *observer2; 41 41 UpdateCountObserver *observer3; 42 UpdateCountObserver *observer4; 42 43 43 SimpleObservable *simpleObservable; 44 SimpleObservable *simpleObservable1; 45 SimpleObservable *simpleObservable2; 44 46 CallObservable *callObservable; 45 47 SuperObservable *superObservable;
Note:
See TracChangeset
for help on using the changeset viewer.