Changeset 12c4cb


Ignore:
Timestamp:
Mar 27, 2012, 3:53:36 PM (13 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:
64b197
Parents:
4824045
git-author:
Frederik Heber <heber@…> (03/22/12 17:37:28)
git-committer:
Frederik Heber <heber@…> (03/27/12 15:53:36)
Message:

FIX: MoleculeOrderDescriptor was not working correctly.

Location:
src/Descriptors
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/Descriptors/MoleculeOrderDescriptor.cpp

    r4824045 r12c4cb  
    6161    for (; res != molecules.end_internal(); ++res) { // when iterator is normal, ++ goes forward!
    6262      ++i;
    63       if (id == i)
     63      if (id == i) {
     64        mol = res->second;
    6465        break;
     66      }
    6567    }
    66     mol = res->second;
    6768  } else {
    6869    World::MoleculeSet::reverse_internal_iterator res = molecules.rbegin_internal();
    69     for (; res != molecules.rend_internal(); --res) {  // when iterator is reverse, ++ goes backward!
     70    for (; res != molecules.rend_internal(); ++res) {  // when iterator is reverse, ++ goes backward!
    7071      --i;
    71       if (id == i)
     72      if (id == i) {
     73        mol = res->second;
    7274        break;
     75      }
    7376    }
    74     mol = res->second;
    7577  }
    7678
  • src/Descriptors/unittests/MoleculeDescriptorUnitTest.cpp

    r4824045 r12c4cb  
    2525#include <Descriptors/MoleculeDescriptor.hpp>
    2626#include <Descriptors/MoleculeIdDescriptor.hpp>
     27#include <Descriptors/MoleculeNameDescriptor.hpp>
     28#include <Descriptors/MoleculeOrderDescriptor.hpp>
    2729
    2830#include "World.hpp"
     
    169171  }
    170172}
     173
     174void MoleculeDescriptorTest::MoleculeNameTest()
     175{
     176  molecule* testMolecule;
     177
     178  // name each molecule
     179  for(int i=1;i<=MOLECULE_COUNT;++i)
     180    molecules[i-1]->setName(toString(i));
     181
     182  // retrieve each
     183  for(int i=1;i<=MOLECULE_COUNT;++i) {
     184    testMolecule = World::getInstance().getMolecule(MoleculeByName(toString(i)));
     185    CPPUNIT_ASSERT_EQUAL( moleculeIds[i-1], testMolecule->getId());
     186  }
     187
     188  // check for non-present name
     189  testMolecule = World::getInstance().getMolecule(MoleculeByName("not present"));
     190  CPPUNIT_ASSERT(!testMolecule);
     191}
     192
     193
     194void MoleculeDescriptorTest::MoleculeOrderTest()
     195{
     196  molecule* testMolecule;
     197
     198  // test in normal order: 1, 2, ...
     199  for(int i=1;i<=MOLECULE_COUNT;++i){
     200    testMolecule = World::getInstance().getMolecule(MoleculeByOrder(i));
     201    CPPUNIT_ASSERT_EQUAL( moleculeIds[i-1], testMolecule->getId());
     202  }
     203
     204  // test in reverse order: -1, -2, ...
     205  for(int i=1; i<= MOLECULE_COUNT;++i){
     206    testMolecule = World::getInstance().getMolecule(MoleculeByOrder(-i));
     207    CPPUNIT_ASSERT_EQUAL( moleculeIds[(int)MOLECULE_COUNT-i], testMolecule->getId());
     208  }
     209
     210  // test from outside of set
     211  testMolecule = World::getInstance().getMolecule(MoleculeByOrder(MOLECULE_COUNT+1));
     212  CPPUNIT_ASSERT(!testMolecule);
     213  testMolecule = World::getInstance().getMolecule(MoleculeByOrder(-MOLECULE_COUNT-1));
     214  CPPUNIT_ASSERT(!testMolecule);
     215}
  • src/Descriptors/unittests/MoleculeDescriptorUnitTest.hpp

    r4824045 r12c4cb  
    3030  CPPUNIT_TEST ( MoleculeIdTest );
    3131  CPPUNIT_TEST ( MoleculeCalcTest );
     32  CPPUNIT_TEST ( MoleculeOrderTest );
     33  CPPUNIT_TEST ( MoleculeNameTest );
    3234  CPPUNIT_TEST_SUITE_END();
    3335
     
    3941  void MoleculeIdTest();
    4042  void MoleculeCalcTest();
     43  void MoleculeOrderTest();
     44  void MoleculeNameTest();
    4145
    4246private:
Note: See TracChangeset for help on using the changeset viewer.