Changeset 63fb7a for src/Descriptors


Ignore:
Timestamp:
Jul 24, 2015, 4:44:34 PM (9 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:
1259df
Parents:
795c0f
git-author:
Frederik Heber <heber@…> (06/01/15 08:48:35)
git-committer:
Frederik Heber <heber@…> (07/24/15 16:44:34)
Message:

Replaced getMolecule() by const access version where possible.

  • so far this is done done via const_casting the World.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Descriptors/unittests/MoleculeDescriptorUnitTest.cpp

    r795c0f r63fb7a  
    111111void MoleculeDescriptorTest::MoleculeIdTest(){
    112112  // test Molecules from boundaries and middle of the set
    113   molecule* testMolecule;
    114   testMolecule = World::getInstance().getMolecule(MoleculeById(moleculeIds[0]));
     113  const molecule* testMolecule;
     114  testMolecule = const_cast<const World &>(World::getInstance()).
     115      getMolecule(MoleculeById(moleculeIds[0]));
    115116  CPPUNIT_ASSERT(testMolecule);
    116117  CPPUNIT_ASSERT_EQUAL( moleculeIds[0], testMolecule->getId());
    117   testMolecule = World::getInstance().getMolecule(MoleculeById(moleculeIds[MOLECULE_COUNT/2]));
     118  testMolecule = const_cast<const World &>(World::getInstance()).
     119      getMolecule(MoleculeById(moleculeIds[MOLECULE_COUNT/2]));
    118120  CPPUNIT_ASSERT(testMolecule);
    119121  CPPUNIT_ASSERT_EQUAL( moleculeIds[MOLECULE_COUNT/2], testMolecule->getId());
    120   testMolecule = World::getInstance().getMolecule(MoleculeById(moleculeIds[MOLECULE_COUNT-1]));
     122  testMolecule = const_cast<const World &>(World::getInstance()).
     123      getMolecule(MoleculeById(moleculeIds[MOLECULE_COUNT-1]));
    121124  CPPUNIT_ASSERT(testMolecule);
    122125  CPPUNIT_ASSERT_EQUAL( moleculeIds[MOLECULE_COUNT-1], testMolecule->getId());
     
    132135  }
    133136  // test from outside of set
    134   testMolecule = World::getInstance().getMolecule(MoleculeById(outsideId));
     137  testMolecule = const_cast<const World &>(World::getInstance()).
     138      getMolecule(MoleculeById(outsideId));
    135139  CPPUNIT_ASSERT(!testMolecule);
    136140}
     
    189193void MoleculeDescriptorTest::MoleculeNameTest()
    190194{
    191   molecule* testMolecule;
     195  const molecule* testMolecule;
    192196
    193197  // name each molecule
     
    197201  // retrieve each
    198202  for(int i=1;i<=MOLECULE_COUNT;++i) {
    199     testMolecule = World::getInstance().getMolecule(MoleculeByName(toString(i)));
     203    testMolecule = const_cast<const World &>(World::getInstance()).
     204        getMolecule(MoleculeByName(toString(i)));
    200205    CPPUNIT_ASSERT_EQUAL( moleculeIds[i-1], testMolecule->getId());
    201206  }
    202207
    203208  // check for non-present name
    204   testMolecule = World::getInstance().getMolecule(MoleculeByName("not present"));
     209  testMolecule = const_cast<const World &>(World::getInstance()).
     210      getMolecule(MoleculeByName("not present"));
    205211  CPPUNIT_ASSERT(!testMolecule);
    206212}
     
    209215void MoleculeDescriptorTest::MoleculeOrderTest()
    210216{
    211   molecule* testMolecule;
     217  const molecule* testMolecule;
    212218
    213219  // test in normal order: 1, 2, ...
    214220  for(int i=1;i<=MOLECULE_COUNT;++i){
    215     testMolecule = World::getInstance().getMolecule(MoleculeByOrder(i));
     221    testMolecule = const_cast<const World &>(World::getInstance()).
     222        getMolecule(MoleculeByOrder(i));
    216223    CPPUNIT_ASSERT_EQUAL( moleculeIds[i-1], testMolecule->getId());
    217224  }
     
    219226  // test in reverse order: -1, -2, ...
    220227  for(int i=1; i<= MOLECULE_COUNT;++i){
    221     testMolecule = World::getInstance().getMolecule(MoleculeByOrder(-i));
     228    testMolecule = const_cast<const World &>(World::getInstance()).
     229        getMolecule(MoleculeByOrder(-i));
    222230    CPPUNIT_ASSERT_EQUAL( moleculeIds[(int)MOLECULE_COUNT-i], testMolecule->getId());
    223231  }
    224232
    225233  // test from outside of set
    226   testMolecule = World::getInstance().getMolecule(MoleculeByOrder(MOLECULE_COUNT+1));
    227   CPPUNIT_ASSERT(!testMolecule);
    228   testMolecule = World::getInstance().getMolecule(MoleculeByOrder(-MOLECULE_COUNT-1));
    229   CPPUNIT_ASSERT(!testMolecule);
    230 }
     234  testMolecule = const_cast<const World &>(World::getInstance()).
     235      getMolecule(MoleculeByOrder(MOLECULE_COUNT+1));
     236  CPPUNIT_ASSERT(!testMolecule);
     237  testMolecule = const_cast<const World &>(World::getInstance()).
     238      getMolecule(MoleculeByOrder(-MOLECULE_COUNT-1));
     239  CPPUNIT_ASSERT(!testMolecule);
     240}
Note: See TracChangeset for help on using the changeset viewer.