Changeset 1259df for src/Descriptors
- Timestamp:
- Jul 24, 2015, 4:44:34 PM (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:
- f01769
- Parents:
- 63fb7a
- git-author:
- Frederik Heber <heber@…> (06/01/15 08:56:36)
- git-committer:
- Frederik Heber <heber@…> (07/24/15 16:44:34)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Descriptors/unittests/MoleculeDescriptorUnitTest.cpp
r63fb7a r1259df 70 70 71 71 // some helper functions 72 static bool hasAllMolecules(std::vector<molecule*> molecules,moleculeId_t ids[MOLECULE_COUNT], std::set<moleculeId_t> excluded = std::set<moleculeId_t>()){ 72 static bool hasAllMolecules( 73 std::vector<const molecule*> &molecules, 74 moleculeId_t ids[MOLECULE_COUNT], 75 std::set<moleculeId_t> excluded = std::set<moleculeId_t>()) 76 { 73 77 for(int i=0;i<MOLECULE_COUNT;++i){ 74 78 moleculeId_t id = ids[i]; 75 79 if(!excluded.count(id)){ 76 std::vector< molecule*>::iterator iter;80 std::vector<const molecule*>::const_iterator iter; 77 81 bool res=false; 78 82 for(iter=molecules.begin();iter!=molecules.end();++iter){ … … 88 92 } 89 93 90 static bool hasNoDuplicateMolecules(std::vector< molecule*>molecules){94 static bool hasNoDuplicateMolecules(std::vector<const molecule*> &molecules){ 91 95 std::set<moleculeId_t> found; 92 std::vector< molecule*>::iterator iter;96 std::vector<const molecule*>::const_iterator iter; 93 97 for(iter=molecules.begin();iter!=molecules.end();++iter){ 94 98 int id = (*iter)->getId(); … … 102 106 103 107 void MoleculeDescriptorTest::MoleculeBaseSetsTest(){ 104 std::vector<molecule*> allMolecules = World::getInstance().getAllMolecules(AllMolecules()); 108 std::vector<const molecule*> allMolecules = 109 const_cast<const World &>(World::getInstance()).getAllMolecules(AllMolecules()); 105 110 CPPUNIT_ASSERT_EQUAL( true , hasAllMolecules(allMolecules,moleculeIds)); 106 111 CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateMolecules(allMolecules)); 107 112 108 std::vector<molecule*> noMolecules = World::getInstance().getAllMolecules(NoMolecules()); 113 std::vector<const molecule*> noMolecules = 114 const_cast<const World &>(World::getInstance()).getAllMolecules(NoMolecules()); 109 115 CPPUNIT_ASSERT_EQUAL( true , noMolecules.empty()); 110 116 } … … 142 148 // test some elementary set operations 143 149 { 144 std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(AllMolecules()||NoMolecules()); 150 std::vector<const molecule*> testMolecules = 151 const_cast<const World &>(World::getInstance()).getAllMolecules(AllMolecules()||NoMolecules()); 145 152 CPPUNIT_ASSERT_EQUAL( true , hasAllMolecules(testMolecules,moleculeIds)); 146 153 CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateMolecules(testMolecules)); … … 148 155 149 156 { 150 std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(NoMolecules()||AllMolecules()); 157 std::vector<const molecule*> testMolecules = 158 const_cast<const World &>(World::getInstance()).getAllMolecules(NoMolecules()||AllMolecules()); 151 159 CPPUNIT_ASSERT_EQUAL( true , hasAllMolecules(testMolecules,moleculeIds)); 152 160 CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateMolecules(testMolecules)); … … 154 162 155 163 { 156 std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(NoMolecules()&&AllMolecules()); 164 std::vector<const molecule*> testMolecules = 165 const_cast<const World &>(World::getInstance()).getAllMolecules(NoMolecules()&&AllMolecules()); 157 166 CPPUNIT_ASSERT_EQUAL( true , testMolecules.empty()); 158 167 } 159 168 160 169 { 161 std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(AllMolecules()&&NoMolecules()); 170 std::vector<const molecule*> testMolecules = 171 const_cast<const World &>(World::getInstance()).getAllMolecules(AllMolecules()&&NoMolecules()); 162 172 CPPUNIT_ASSERT_EQUAL( true , testMolecules.empty()); 163 173 } 164 174 165 175 { 166 std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(!AllMolecules()); 176 std::vector<const molecule*> testMolecules = 177 const_cast<const World &>(World::getInstance()).getAllMolecules(!AllMolecules()); 167 178 CPPUNIT_ASSERT_EQUAL( true , testMolecules.empty()); 168 179 } 169 180 170 181 { 171 std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(!NoMolecules()); 182 std::vector<const molecule*> testMolecules = 183 const_cast<const World &>(World::getInstance()).getAllMolecules(!NoMolecules()); 172 184 CPPUNIT_ASSERT_EQUAL( true , hasAllMolecules(testMolecules,moleculeIds)); 173 185 CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateMolecules(testMolecules)); … … 176 188 // exclude and include some molecules 177 189 { 178 std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(AllMolecules()&&(!MoleculeById(moleculeIds[MOLECULE_COUNT/2]))); 190 std::vector<const molecule*> testMolecules = 191 const_cast<const World &>(World::getInstance()).getAllMolecules(AllMolecules()&&(!MoleculeById(moleculeIds[MOLECULE_COUNT/2]))); 179 192 std::set<moleculeId_t> excluded; 180 193 excluded.insert(moleculeIds[MOLECULE_COUNT/2]); … … 185 198 186 199 { 187 std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(NoMolecules()||(MoleculeById(moleculeIds[MOLECULE_COUNT/2]))); 200 std::vector<const molecule*> testMolecules = 201 const_cast<const World &>(World::getInstance()).getAllMolecules(NoMolecules()||(MoleculeById(moleculeIds[MOLECULE_COUNT/2]))); 188 202 CPPUNIT_ASSERT_EQUAL( (size_t)1, testMolecules.size()); 189 203 CPPUNIT_ASSERT_EQUAL( moleculeIds[MOLECULE_COUNT/2], testMolecules[0]->getId());
Note:
See TracChangeset
for help on using the changeset viewer.