Changeset 10aee4 for src/Actions/unittests
- Timestamp:
- Aug 5, 2015, 7:12:24 AM (9 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:
- c307ba
- Parents:
- 94232b
- git-author:
- Frederik Heber <heber@…> (08/03/15 09:25:02)
- git-committer:
- Frederik Heber <heber@…> (08/05/15 07:12:24)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/unittests/ActionSequenceUnitTest.cpp
r94232b r10aee4 239 239 { 240 240 ActionSequence *sequence = new ActionSequence(); 241 sequence->addAction(positive1 );242 sequence->addAction(positive2 );241 sequence->addAction(positive1->clone()); 242 sequence->addAction(positive2->clone()); 243 243 CPPUNIT_ASSERT_EQUAL( true, sequence->canUndo() ); 244 244 delete sequence; … … 246 246 { 247 247 ActionSequence *sequence = new ActionSequence(); 248 sequence->addAction(positive1 );249 sequence->addAction(negative2 );248 sequence->addAction(positive1->clone()); 249 sequence->addAction(negative2->clone()); 250 250 CPPUNIT_ASSERT_EQUAL( false, sequence->canUndo() ); 251 251 delete sequence; … … 253 253 { 254 254 ActionSequence *sequence = new ActionSequence(); 255 sequence->addAction(negative1 );256 sequence->addAction(positive2 );255 sequence->addAction(negative1->clone()); 256 sequence->addAction(positive2->clone()); 257 257 CPPUNIT_ASSERT_EQUAL( false, sequence->canUndo() ); 258 258 delete sequence; … … 260 260 { 261 261 ActionSequence *sequence = new ActionSequence(); 262 sequence->addAction(negative1 );263 sequence->addAction(negative2 );262 sequence->addAction(negative1->clone()); 263 sequence->addAction(negative2->clone()); 264 264 CPPUNIT_ASSERT_EQUAL( false, sequence->canUndo() ); 265 265 delete sequence; … … 273 273 CPPUNIT_ASSERT_EQUAL( true, sequence->canUndo() ); 274 274 // if only a positive action is contained it can be undone 275 sequence->addAction(positive1 );275 sequence->addAction(positive1->clone()); 276 276 CPPUNIT_ASSERT_EQUAL( true, sequence->canUndo() ); 277 277 // the single negative action should block the process 278 sequence->addAction(negative1 );278 sequence->addAction(negative1->clone()); 279 279 CPPUNIT_ASSERT_EQUAL( false, sequence->canUndo() ); 280 280 // after removing the negative action all is well again 281 sequence->removeLastAction();281 delete sequence->removeLastAction(); 282 282 CPPUNIT_ASSERT_EQUAL( true, sequence->canUndo() ); 283 283 delete sequence; … … 287 287 void ActionSequenceTest::doesCallTest(){ 288 288 ActionSequence *sequence = new ActionSequence(); 289 sequence->addAction(shouldCall1 );290 sequence->addAction(shouldCall2 );291 sequence->addAction(shouldNotCall1 );292 sequence->addAction(shouldNotCall2 );293 sequence->removeLastAction();294 sequence->removeLastAction();289 sequence->addAction(shouldCall1->clone()); 290 sequence->addAction(shouldCall2->clone()); 291 sequence->addAction(shouldNotCall1->clone()); 292 sequence->addAction(shouldNotCall2->clone()); 293 delete sequence->removeLastAction(); 294 delete sequence->removeLastAction(); 295 295 296 296 sequence->callAll(); 297 297 298 CPPUNIT_ASSERT_EQUAL(true,shouldCall1->wasCalled());299 CPPUNIT_ASSERT_EQUAL(true, shouldCall2->wasCalled());300 CPPUNIT_ASSERT_EQUAL( false,shouldNotCall1->wasCalled());301 CPPUNIT_ASSERT _EQUAL(false,shouldNotCall2->wasCalled());298 ActionSequence::actionSet::const_iterator iter = sequence->actions.begin(); 299 CPPUNIT_ASSERT_EQUAL(true,dynamic_cast<wasCalledActionStub *>(*iter++)->wasCalled()); 300 CPPUNIT_ASSERT_EQUAL(true,dynamic_cast<wasCalledActionStub *>(*iter++)->wasCalled()); 301 CPPUNIT_ASSERT( iter == sequence->actions.end() ); 302 302 303 303 delete sequence;
Note:
See TracChangeset
for help on using the changeset viewer.