Ignore:
Timestamp:
Nov 8, 2012, 1:13:13 PM (12 years ago)
Author:
Frederik Heber <heber@…>
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:
c508fea
Parents:
7bed4e
git-author:
Frederik Heber <heber@…> (07/04/12 15:31:42)
git-committer:
Frederik Heber <heber@…> (11/08/12 13:13:13)
Message:

SetValue now has a contribution along with its value.

  • contribution is Cacheable and new function calcSum() which is called when contribution is accessed.
  • operator+=/-=() are now OBSERVEd, too.
  • adapted unit test to check whether contribution is working.
  • added two mocks for SubsetMap and SetValueMap.
Location:
src/Fragmentation/Summation/unittests
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/Summation/unittests/Makefile.am

    r7bed4e r30abdc  
    5252        unittests/SetValueUnitTest.cpp \
    5353        unittests/SetValueUnitTest.hpp \
     54        unittests/stubs/SetValueMap_Mock.hpp \
     55        unittests/stubs/SubsetMap_Mock.hpp \
     56        IndexSet.cpp \
     57        IndexSet.hpp \
     58        IndexSetContainer.hpp \
    5459        SetValue.hpp
    5560SetValueUnitTest_LDADD = ${FRAGMENTATIONSUMMATIONLIBS}
  • src/Fragmentation/Summation/unittests/SetValueUnitTest.cpp

    r7bed4e r30abdc  
    3939#include <cppunit/ui/text/TestRunner.h>
    4040
     41#include "Fragmentation/Summation/IndexSet.hpp"
     42#include "Fragmentation/Summation/IndexSetContainer.hpp"
    4143#include "Fragmentation/Summation/SetValue.hpp"
    4244
    4345#include "SetValueUnitTest.hpp"
     46#include "stubs/SetValueMap_Mock.hpp"
     47#include "stubs/SubsetMap_Mock.hpp"
    4448
    4549#include <boost/assign.hpp>
     
    5862CPPUNIT_TEST_SUITE_REGISTRATION( SetValueTest );
    5963
     64LookupValue LV;
     65LookupSubset LS;
     66
    6067
    6168void SetValueTest::setUp()
     
    6370  IndexSet set;
    6471  set += 1,2,3,4;
    65   indices = new IndexSet( set );
    66   value = new SetValue<int>(*indices, VALUE);
     72  indices.reset(new IndexSet( set ));
     73  value.reset(new SetValue<int>(indices, VALUE));
     74  SetValue<int>::lookupSubset =
     75      boost::bind(&LookupSubset::getSubsets, boost::ref(LS), _1);
     76  SetValue<int>::lookupValue =
     77      boost::bind(&LookupValue::getValue, boost::ref(LV), _1);
     78  LV.LookupMap.insert( std::make_pair(indices, value) );
     79  //IndexSet_ptr emptyset(new IndexSet);
     80  //LS.LookupMap.insert( std::make_pair(indices, IndexSetContainer::ptr( new IndexSetContainer(emptyset) )) );
    6781};
    6882
     
    7084void SetValueTest::tearDown()
    7185{
    72   delete value;
    73   delete indices;
    7486};
    7587
     
    8799void SetValueTest::operatorTest()
    88100{
    89   SetValue<int> other(*indices, OTHER);
     101  SetValue<int> other(indices, OTHER);
    90102
    91103  // operator-=
     
    99111  CPPUNIT_ASSERT_EQUAL( (int)VALUE - ((int)OTHER - (int)VALUE), value->getValue() );
    100112};
     113
     114void SetValueTest::getContributiontest()
     115{
     116  IndexSet set;
     117  set += 1,2,3;
     118  IndexSet_ptr otherindices(new IndexSet(set));
     119  SetValue<int>::ptr othervalue(new SetValue<int>(otherindices, OTHER));
     120  LV.LookupMap.insert( std::make_pair(otherindices, othervalue) );
     121
     122  // connect as subset
     123  LS.LookupMap[indices].reset(new IndexSetContainer(otherindices));
     124
     125  std::cout << "The following error is intended and does not constitute a failure of the test." << std::endl;
     126  CPPUNIT_ASSERT_EQUAL( (int)OTHER, othervalue->getContribution() );
     127  CPPUNIT_ASSERT_EQUAL( 2, value->getContribution() );
     128
     129  LS.LookupMap.erase( indices );
     130}
  • src/Fragmentation/Summation/unittests/SetValueUnitTest.hpp

    r7bed4e r30abdc  
    1717#include <cppunit/extensions/HelperMacros.h>
    1818
     19#include "Fragmentation/Summation/IndexSet.hpp"
    1920#include "Fragmentation/Summation/SetValue.hpp"
    20 
    21 class IndexSet;
    2221
    2322/********************************************** Test classes **************************************/
     
    2827    CPPUNIT_TEST ( constructorTest );
    2928    CPPUNIT_TEST ( operatorTest );
     29    CPPUNIT_TEST ( getContributiontest );
    3030    CPPUNIT_TEST_SUITE_END();
    3131
     
    3535      void constructorTest();
    3636      void operatorTest();
     37      void getContributiontest();
    3738
    3839private:
    39       IndexSet *indices;
    40       SetValue<int> *value;
     40      IndexSet::ptr indices;
     41      SetValue<int>::ptr value;
    4142
    4243};
Note: See TracChangeset for help on using the changeset viewer.