Changeset a58c16 for src/Descriptors
- Timestamp:
- Jul 24, 2015, 4:44:35 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:
- 99db9b
- Parents:
- f01769
- git-author:
- Frederik Heber <heber@…> (06/01/15 19:16:02)
- git-committer:
- Frederik Heber <heber@…> (07/24/15 16:44:35)
- Location:
- src/Descriptors
- Files:
-
- 3 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Descriptors/unittests/AtomDescriptorUnitTest.cpp
rf01769 ra58c16 76 76 77 77 // some helper functions 78 static bool hasAllAtoms(std::vector<atom*> atoms,atomId_t ids[ATOM_COUNT], std::set<atomId_t> excluded = std::set<atomId_t>()) 78 static bool hasAllAtoms( 79 std::vector<const atom*> atoms, 80 atomId_t ids[ATOM_COUNT], 81 std::set<atomId_t> excluded = std::set<atomId_t>()) 79 82 { 80 83 for(int i=0;i<ATOM_COUNT;++i){ 81 84 atomId_t id = ids[i]; 82 85 if(!excluded.count(id)){ 83 std::vector< atom*>::iterator iter;86 std::vector<const atom*>::const_iterator iter; 84 87 bool res=false; 85 88 for(iter=atoms.begin();iter!=atoms.end();++iter){ … … 95 98 } 96 99 97 static bool hasNoDuplicateAtoms(std::vector< atom*> atoms)100 static bool hasNoDuplicateAtoms(std::vector<const atom*> atoms) 98 101 { 99 102 std::set<atomId_t> found; 100 std::vector< atom*>::iterator iter;103 std::vector<const atom*>::const_iterator iter; 101 104 for(iter=atoms.begin();iter!=atoms.end();++iter){ 102 105 int id = (*iter)->getId(); … … 111 114 void AtomDescriptorTest::AtomBaseSetsTest() 112 115 { 113 std::vector<atom*> allAtoms = World::getInstance().getAllAtoms(AllAtoms()); 116 std::vector<const atom*> allAtoms = const_cast<const World &>(World::getInstance()). 117 getAllAtoms(AllAtoms()); 114 118 CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(allAtoms,atomIds)); 115 119 CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(allAtoms)); 116 120 117 std::vector<atom*> noAtoms = World::getInstance().getAllAtoms(NoAtoms()); 121 std::vector<const atom*> noAtoms = const_cast<const World &>(World::getInstance()). 122 getAllAtoms(NoAtoms()); 118 123 CPPUNIT_ASSERT_EQUAL( true , noAtoms.empty()); 119 124 } … … 166 171 167 172 // get atom by descriptor 168 World::AtomComposite atoms = World::getInstance().getAllAtoms(AtomOfMolecule(newmol->getId())); 173 World::ConstAtomComposite atoms = const_cast<const World &>(World::getInstance()). 174 getAllAtoms(AtomOfMolecule(newmol->getId())); 169 175 CPPUNIT_ASSERT_EQUAL( (size_t)1, atoms.size() ); 170 176 CPPUNIT_ASSERT_EQUAL( (*atoms.begin())->getId(), testAtom->getId() ); … … 213 219 214 220 215 std::set<atomId_t> getIdList(const World:: AtomComposite &list)221 std::set<atomId_t> getIdList(const World::ConstAtomComposite &list) 216 222 { 217 223 std::set<atomId_t> testlist; 218 for (World:: AtomComposite::const_iterator iter = list.begin();224 for (World::ConstAtomComposite::const_iterator iter = list.begin(); 219 225 iter != list.end(); ++iter) 220 226 testlist.insert( (*iter)->getId() ); … … 236 242 // Vector position(0.,0.,0.); 237 243 // Shape s = Sphere(position, distance); 238 // World::AtomComposite atomlist = World::getInstance().getAllAtoms(AtomsByShape(s)); 244 // World::ConstAtomComposite atomlist = const_cast<const World &>(World::getInstance()). 245 // getAllAtoms(AtomsByShape(s)); 239 246 // CPPUNIT_ASSERT_EQUAL( (size_t)2, atomlist.size() ); 240 247 // std::set<atomId_t> reflist = getDistanceList(distance, position, atoms); … … 247 254 // Vector position(4.,0.,0.); 248 255 // Shape s = Sphere(position, distance); 249 // World::AtomComposite atomlist = World::getInstance().getAllAtoms(AtomsByShape(s)); 256 // World::ConstAtomComposite atomlist = const_cast<const World &>(World::getInstance()). 257 // getAllAtoms(AtomsByShape(s)); 250 258 // CPPUNIT_ASSERT_EQUAL( (size_t)5, atomlist.size() ); 251 259 // std::set<atomId_t> reflist = getDistanceList(distance, position, atoms); … … 258 266 // Vector *position = new Vector(10.,0.,0.); 259 267 // Shape s = Sphere(position, distance); 260 // World::AtomComposite atomlist = World::getInstance().getAllAtoms(AtomsByShape(s)); 268 // World::ConstAtomComposite atomlist = const_cast<const World &>(World::getInstance()). 269 // getAllAtoms(AtomsByShape(s)); 261 270 // CPPUNIT_ASSERT_EQUAL( (size_t)1, atomlist.size() ); 262 271 // std::set<atomId_t> reflist = getDistanceList(distance, *position, atoms); … … 280 289 const double distance = 1.5; 281 290 Vector position(0.,0.,0.); 282 World::AtomComposite atomlist = World::getInstance().getAllAtoms(AtomsWithinDistanceOf(distance, position)); 291 World::ConstAtomComposite atomlist = const_cast<const World &>(World::getInstance()). 292 getAllAtoms(AtomsWithinDistanceOf(distance, position)); 283 293 CPPUNIT_ASSERT_EQUAL( (size_t)2, atomlist.size() ); 284 294 std::set<atomId_t> reflist = getDistanceList(distance, position, atoms); … … 289 299 { 290 300 const double distance = 2.9; 291 World::AtomComposite atomlist = World::getInstance().getAllAtoms(AtomsWithinDistanceOf(distance, Vector(4.,0.,0.))); 301 World::ConstAtomComposite atomlist = const_cast<const World &>(World::getInstance()). 302 getAllAtoms(AtomsWithinDistanceOf(distance, Vector(4.,0.,0.))); 292 303 CPPUNIT_ASSERT_EQUAL( (size_t)5, atomlist.size() ); 293 304 std::set<atomId_t> reflist = getDistanceList(distance, Vector(4.,0.,0.), atoms); … … 299 310 const double distance = 1.5; 300 311 Vector *position = new Vector(10.,0.,0.); 301 World::AtomComposite atomlist = World::getInstance().getAllAtoms(AtomsWithinDistanceOf(distance, *position)); 312 World::ConstAtomComposite atomlist = const_cast<const World &>(World::getInstance()). 313 getAllAtoms(AtomsWithinDistanceOf(distance, *position)); 302 314 CPPUNIT_ASSERT_EQUAL( (size_t)1, atomlist.size() ); 303 315 std::set<atomId_t> reflist = getDistanceList(distance, *position, atoms); … … 312 324 // test some elementary set operations 313 325 { 314 std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(AllAtoms()||NoAtoms()); 326 std::vector<const atom*> testAtoms = const_cast<const World &>(World::getInstance()). 327 getAllAtoms(AllAtoms()||NoAtoms()); 315 328 CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(testAtoms,atomIds)); 316 329 CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(testAtoms)); … … 318 331 319 332 { 320 std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(NoAtoms()||AllAtoms()); 333 std::vector<const atom*> testAtoms = const_cast<const World &>(World::getInstance()). 334 getAllAtoms(NoAtoms()||AllAtoms()); 321 335 CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(testAtoms,atomIds)); 322 336 CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(testAtoms)); … … 324 338 325 339 { 326 std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(NoAtoms()&&AllAtoms()); 340 std::vector<const atom*> testAtoms = const_cast<const World &>(World::getInstance()). 341 getAllAtoms(NoAtoms()&&AllAtoms()); 327 342 CPPUNIT_ASSERT_EQUAL( true , testAtoms.empty()); 328 343 } 329 344 330 345 { 331 std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(AllAtoms()&&NoAtoms()); 346 std::vector<const atom*> testAtoms = const_cast<const World &>(World::getInstance()). 347 getAllAtoms(AllAtoms()&&NoAtoms()); 332 348 CPPUNIT_ASSERT_EQUAL( true , testAtoms.empty()); 333 349 } 334 350 335 351 { 336 std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(!AllAtoms()); 352 std::vector<const atom*> testAtoms = const_cast<const World &>(World::getInstance()). 353 getAllAtoms(!AllAtoms()); 337 354 CPPUNIT_ASSERT_EQUAL( true , testAtoms.empty()); 338 355 } 339 356 340 357 { 341 std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(!NoAtoms()); 358 std::vector<const atom*> testAtoms = const_cast<const World &>(World::getInstance()). 359 getAllAtoms(!NoAtoms()); 342 360 CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(testAtoms,atomIds)); 343 361 CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(testAtoms)); … … 345 363 // exclude and include some atoms 346 364 { 347 std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(AllAtoms()&&(!AtomById(atomIds[ATOM_COUNT/2]))); 365 std::vector<const atom*> testAtoms = const_cast<const World &>(World::getInstance()). 366 getAllAtoms(AllAtoms()&&(!AtomById(atomIds[ATOM_COUNT/2]))); 348 367 std::set<atomId_t> excluded; 349 368 excluded.insert(atomIds[ATOM_COUNT/2]); … … 354 373 355 374 { 356 std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(NoAtoms()||(AtomById(atomIds[ATOM_COUNT/2]))); 375 std::vector<const atom*> testAtoms = const_cast<const World &>(World::getInstance()). 376 getAllAtoms(NoAtoms()||(AtomById(atomIds[ATOM_COUNT/2]))); 357 377 CPPUNIT_ASSERT_EQUAL( (size_t)1, testAtoms.size()); 358 378 CPPUNIT_ASSERT_EQUAL( atomIds[ATOM_COUNT/2], testAtoms[0]->getId());
Note:
See TracChangeset
for help on using the changeset viewer.