Changeset 0229f9 for src/unittests/ActionSequenceTest.cpp
- Timestamp:
- Dec 29, 2009, 11:47:57 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:
- 77675f
- Parents:
- 147339
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/unittests/ActionSequenceTest.cpp
r147339 r0229f9 49 49 }; 50 50 51 void ActionSequenceTest::setUp(){} 52 void ActionSequenceTest::tearDown(){} 51 class wasCalledActionStub : public Action 52 { 53 public: 54 wasCalledActionStub() : 55 called(false) 56 {} 57 virtual ~wasCalledActionStub(){} 58 59 virtual void call(){ 60 called = true; 61 } 62 virtual void undo(){ 63 called = false; 64 } 65 virtual bool canUndo(){ 66 return true; 67 } 68 bool wasCalled(){ 69 return called; 70 } 71 private: 72 bool called; 73 }; 74 75 void ActionSequenceTest::setUp(){ 76 // create some necessary stubs used in this test 77 positive1 = new canUndoActionStub(); 78 positive2 = new canUndoActionStub(); 79 negative1 = new cannotUndoActionStub(); 80 negative2 = new cannotUndoActionStub(); 81 82 shouldCall1 = new wasCalledActionStub(); 83 shouldCall2 = new wasCalledActionStub(); 84 shouldNotCall1 = new wasCalledActionStub(); 85 shouldNotCall2 = new wasCalledActionStub(); 86 87 } 88 89 void ActionSequenceTest::tearDown(){ 90 delete positive1; 91 delete positive2; 92 delete negative1; 93 delete negative2; 94 95 delete shouldCall1; 96 delete shouldCall2; 97 delete shouldNotCall1; 98 delete shouldNotCall2; 99 100 } 53 101 54 102 void ActionSequenceTest::canUndoTest(){ 55 56 // create some necessary stubs used in this test57 Action *positive1 = new canUndoActionStub();58 Action *positive2 = new canUndoActionStub();59 Action *negative1 = new cannotUndoActionStub();60 Action *negative2 = new cannotUndoActionStub();61 62 103 // first section: 63 104 { … … 109 150 delete sequence; 110 151 } 111 112 delete positive1; 113 delete positive2; 114 delete negative1; 115 delete negative2; 152 } 153 154 void ActionSequenceTest::doesCallTest(){ 155 ActionSequence *sequence = new ActionSequence(); 156 sequence->addAction(shouldCall1); 157 sequence->addAction(shouldCall2); 158 sequence->addAction(shouldNotCall1); 159 sequence->addAction(shouldNotCall2); 160 sequence->removeLastAction(); 161 sequence->removeLastAction(); 162 163 sequence->callAll(); 164 165 CPPUNIT_ASSERT_EQUAL(true,shouldCall1->wasCalled()); 166 CPPUNIT_ASSERT_EQUAL(true,shouldCall2->wasCalled()); 167 CPPUNIT_ASSERT_EQUAL(false,shouldNotCall1->wasCalled()); 168 CPPUNIT_ASSERT_EQUAL(false,shouldNotCall2->wasCalled()); 169 170 } 171 172 void ActionSequenceTest::doesUndoTest(){ 173 ActionSequence *sequence = new ActionSequence(); 174 sequence->addAction(shouldNotCall1); 175 sequence->addAction(shouldNotCall2); 176 sequence->addAction(shouldCall1); 177 sequence->addAction(shouldCall2); 178 179 sequence->callAll(); 180 181 sequence->removeLastAction(); 182 sequence->removeLastAction(); 183 184 sequence->undoAll(); 185 186 CPPUNIT_ASSERT_EQUAL(true,shouldCall1->wasCalled()); 187 CPPUNIT_ASSERT_EQUAL(true,shouldCall2->wasCalled()); 188 CPPUNIT_ASSERT_EQUAL(false,shouldNotCall1->wasCalled()); 189 CPPUNIT_ASSERT_EQUAL(false,shouldNotCall2->wasCalled()); 116 190 117 191 }
Note:
See TracChangeset
for help on using the changeset viewer.