Changeset 99f4ee for src/unittests
- Timestamp:
- Jan 2, 2012, 1:34:58 PM (13 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:
- 4a8169
- Parents:
- 9ed706
- git-author:
- Frederik Heber <heber@…> (12/21/11 18:02:07)
- git-committer:
- Frederik Heber <heber@…> (01/02/12 13:34:58)
- Location:
- src/unittests
- Files:
-
- 3 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
src/unittests/BoxUnitTest.cpp
r9ed706 r99f4ee 28 28 29 29 #include "BoxUnitTest.hpp" 30 31 #include "stubs/ObserverStub.hpp" 30 32 31 33 #ifdef HAVE_TESTRUNNER … … 1617 1619 1618 1620 } 1621 1622 /** Unit test on whether observer is working. 1623 * 1624 */ 1625 void BoxUnittest::ObserverTest() 1626 { 1627 // create some observers 1628 UpdateCountObserver *observer_general = new UpdateCountObserver(); 1629 NotificationObserver *observer_matrix = new NotificationObserver( 1630 unitBox->getChannel(Box::MatrixChanged)); 1631 NotificationObserver *observer_bc = new NotificationObserver( 1632 unitBox->getChannel(Box::BoundaryConditionsChanged)); 1633 CPPUNIT_ASSERT_EQUAL((int)0, observer_general->updates); 1634 CPPUNIT_ASSERT_EQUAL(false, observer_matrix->wasNotified); 1635 CPPUNIT_ASSERT_EQUAL(false, observer_bc->wasNotified); 1636 unitBox->signOn(observer_general); 1637 unitBox->signOn(observer_matrix, Box::MatrixChanged); 1638 unitBox->signOn(observer_bc, Box::BoundaryConditionsChanged); 1639 1640 // create update MatrixChanged 1641 unitBox->setM(*unit); 1642 CPPUNIT_ASSERT_EQUAL((int)1, observer_general->updates); 1643 CPPUNIT_ASSERT_EQUAL(true, observer_matrix->wasNotified); 1644 CPPUNIT_ASSERT_EQUAL(false, observer_bc->wasNotified); 1645 observer_matrix->wasNotified = false; 1646 1647 // create update BoundaryConditionsChanged 1648 unitBox->setCondition(0, Box::Wrap); 1649 CPPUNIT_ASSERT_EQUAL((int)2, observer_general->updates); 1650 CPPUNIT_ASSERT_EQUAL(false, observer_matrix->wasNotified); 1651 CPPUNIT_ASSERT_EQUAL(true, observer_bc->wasNotified); 1652 1653 // remove observers again 1654 unitBox->signOff(observer_general); 1655 unitBox->signOff(observer_matrix, Box::MatrixChanged); 1656 unitBox->signOff(observer_bc, Box::BoundaryConditionsChanged); 1657 delete observer_general; 1658 delete observer_matrix; 1659 delete observer_bc; 1660 } -
src/unittests/BoxUnitTest.hpp
r9ed706 r99f4ee 30 30 CPPUNIT_TEST ( BoundaryIgnoreTest ); 31 31 CPPUNIT_TEST ( BoundaryMixedTest ); 32 CPPUNIT_TEST ( ObserverTest ); 32 33 CPPUNIT_TEST_SUITE_END(); 33 34 … … 43 44 void BoundaryIgnoreTest(); 44 45 void BoundaryMixedTest(); 46 void ObserverTest(); 45 47 46 48 RealSpaceMatrix *unit; -
src/unittests/Makefile.am
r9ed706 r99f4ee 73 73 $(UIELEMENTSCOMMANDLINEPARSERTESTSSOURCES) \ 74 74 ${UIELEMENTSMENUTESTSSOURCES} \ 75 stubs/ObserverStub.cpp \ 75 76 BoxUnitTest.cpp \ 76 77 FormulaUnitTest.cpp \ … … 93 94 $(UIELEMENTSCOMMANDLINEPARSERTESTSHEADERS) \ 94 95 ${UIELEMENTSMENUTESTSHEADERS} \ 96 stubs/ObserverStub.hpp \ 95 97 BoxUnitTest.hpp \ 96 98 FormulaUnitTest.hpp \ … … 101 103 BoxUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \ 102 104 BoxUnitTest.cpp \ 103 BoxUnitTest.hpp 105 BoxUnitTest.hpp \ 106 stubs/ObserverStub.cpp \ 107 stubs/ObserverStub.hpp 104 108 BoxUnitTest_LDADD = \ 105 109 ../libMolecuilder.la \ -
src/unittests/stubs/ObserverStub.cpp
r9ed706 r99f4ee 43 43 } 44 44 45 /*********** NotificationObserver **************/ 46 45 47 NotificationObserver::NotificationObserver(Notification_ptr notification) : 46 48 Observer("NotificationObserver"), … … 48 50 wasNotified(false) 49 51 {} 50 51 /*********** NotificationObserver **************/52 52 53 53 NotificationObserver::~NotificationObserver()
Note:
See TracChangeset
for help on using the changeset viewer.