| [bcf653] | 1 | /*
 | 
|---|
 | 2 |  * Project: MoleCuilder
 | 
|---|
 | 3 |  * Description: creates and alters molecular systems
 | 
|---|
| [0aa122] | 4 |  * Copyright (C)  2010-2012 University of Bonn. All rights reserved.
 | 
|---|
| [5aaa43] | 5 |  * Copyright (C)  2013 Frederik Heber. All rights reserved.
 | 
|---|
| [94d5ac6] | 6 |  * 
 | 
|---|
 | 7 |  *
 | 
|---|
 | 8 |  *   This file is part of MoleCuilder.
 | 
|---|
 | 9 |  *
 | 
|---|
 | 10 |  *    MoleCuilder is free software: you can redistribute it and/or modify
 | 
|---|
 | 11 |  *    it under the terms of the GNU General Public License as published by
 | 
|---|
 | 12 |  *    the Free Software Foundation, either version 2 of the License, or
 | 
|---|
 | 13 |  *    (at your option) any later version.
 | 
|---|
 | 14 |  *
 | 
|---|
 | 15 |  *    MoleCuilder is distributed in the hope that it will be useful,
 | 
|---|
 | 16 |  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
|---|
 | 17 |  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
|---|
 | 18 |  *    GNU General Public License for more details.
 | 
|---|
 | 19 |  *
 | 
|---|
 | 20 |  *    You should have received a copy of the GNU General Public License
 | 
|---|
 | 21 |  *    along with MoleCuilder.  If not, see <http://www.gnu.org/licenses/>.
 | 
|---|
| [bcf653] | 22 |  */
 | 
|---|
 | 23 | 
 | 
|---|
| [7a1ce5] | 24 | /*
 | 
|---|
| [d766b5] | 25 |  * AtomDescriptorUnitTest.cpp
 | 
|---|
| [7a1ce5] | 26 |  *
 | 
|---|
 | 27 |  *  Created on: Feb 9, 2010
 | 
|---|
 | 28 |  *      Author: crueger
 | 
|---|
 | 29 |  */
 | 
|---|
 | 30 | 
 | 
|---|
| [bf3817] | 31 | // include config.h
 | 
|---|
 | 32 | #ifdef HAVE_CONFIG_H
 | 
|---|
 | 33 | #include <config.h>
 | 
|---|
 | 34 | #endif
 | 
|---|
 | 35 | 
 | 
|---|
| [d766b5] | 36 | #include "AtomDescriptorUnitTest.hpp"
 | 
|---|
| [7a1ce5] | 37 | 
 | 
|---|
 | 38 | #include <cppunit/CompilerOutputter.h>
 | 
|---|
 | 39 | #include <cppunit/extensions/TestFactoryRegistry.h>
 | 
|---|
 | 40 | #include <cppunit/ui/text/TestRunner.h>
 | 
|---|
 | 41 | #include <iostream>
 | 
|---|
 | 42 | 
 | 
|---|
 | 43 | #include <Descriptors/AtomDescriptor.hpp>
 | 
|---|
 | 44 | #include <Descriptors/AtomIdDescriptor.hpp>
 | 
|---|
| [b49568] | 45 | #include <Descriptors/AtomOfMoleculeDescriptor.hpp>
 | 
|---|
| [61c364] | 46 | #include <Descriptors/AtomOrderDescriptor.hpp>
 | 
|---|
| [bbab87] | 47 | #include <Descriptors/AtomsWithinDistanceOfDescriptor.hpp>
 | 
|---|
| [7a1ce5] | 48 | 
 | 
|---|
 | 49 | #include "World.hpp"
 | 
|---|
| [6f0841] | 50 | #include "Atom/atom.hpp"
 | 
|---|
| [b49568] | 51 | #include "molecule.hpp"
 | 
|---|
| [bbab87] | 52 | #include "LinearAlgebra/Vector.hpp"
 | 
|---|
| [7a1ce5] | 53 | 
 | 
|---|
| [9b6b2f] | 54 | #ifdef HAVE_TESTRUNNER
 | 
|---|
 | 55 | #include "UnitTestMain.hpp"
 | 
|---|
 | 56 | #endif /*HAVE_TESTRUNNER*/
 | 
|---|
 | 57 | 
 | 
|---|
 | 58 | /********************************************** Test classes **************************************/
 | 
|---|
| [7a1ce5] | 59 | // Registers the fixture into the 'registry'
 | 
|---|
| [57adc7] | 60 | CPPUNIT_TEST_SUITE_REGISTRATION( AtomDescriptorTest );
 | 
|---|
| [7a1ce5] | 61 | 
 | 
|---|
 | 62 | // set up and tear down
 | 
|---|
| [bbab87] | 63 | void AtomDescriptorTest::setUp()
 | 
|---|
 | 64 | {
 | 
|---|
| [23b547] | 65 |   World::getInstance();
 | 
|---|
| [7a1ce5] | 66 |   for(int i=0;i<ATOM_COUNT;++i){
 | 
|---|
| [23b547] | 67 |     atoms[i]= World::getInstance().createAtom();
 | 
|---|
| [57adc7] | 68 |     atomIds[i]= atoms[i]->getId();
 | 
|---|
| [7a1ce5] | 69 |   }
 | 
|---|
 | 70 | }
 | 
|---|
| [57adc7] | 71 | 
 | 
|---|
| [bbab87] | 72 | void AtomDescriptorTest::tearDown()
 | 
|---|
 | 73 | {
 | 
|---|
| [23b547] | 74 |   World::purgeInstance();
 | 
|---|
| [7a1ce5] | 75 | }
 | 
|---|
 | 76 | 
 | 
|---|
 | 77 | // some helper functions
 | 
|---|
| [bbab87] | 78 | static bool hasAllAtoms(std::vector<atom*> atoms,atomId_t ids[ATOM_COUNT], std::set<atomId_t> excluded = std::set<atomId_t>())
 | 
|---|
 | 79 | {
 | 
|---|
| [46d958] | 80 |   for(int i=0;i<ATOM_COUNT;++i){
 | 
|---|
| [57adc7] | 81 |     atomId_t id = ids[i];
 | 
|---|
| [46d958] | 82 |     if(!excluded.count(id)){
 | 
|---|
| [7a1ce5] | 83 |       std::vector<atom*>::iterator iter;
 | 
|---|
 | 84 |       bool res=false;
 | 
|---|
 | 85 |       for(iter=atoms.begin();iter!=atoms.end();++iter){
 | 
|---|
| [46d958] | 86 |         res |= (*iter)->getId() == id;
 | 
|---|
| [7a1ce5] | 87 |       }
 | 
|---|
 | 88 |       if(!res) {
 | 
|---|
| [46d958] | 89 |         cout << "Atom " << id << " missing in returned list" << endl;
 | 
|---|
| [7a1ce5] | 90 |         return false;
 | 
|---|
 | 91 |       }
 | 
|---|
 | 92 |     }
 | 
|---|
 | 93 |   }
 | 
|---|
 | 94 |   return true;
 | 
|---|
 | 95 | }
 | 
|---|
 | 96 | 
 | 
|---|
| [bbab87] | 97 | static bool hasNoDuplicateAtoms(std::vector<atom*> atoms)
 | 
|---|
 | 98 | {
 | 
|---|
| [57adc7] | 99 |   std::set<atomId_t> found;
 | 
|---|
| [7a1ce5] | 100 |   std::vector<atom*>::iterator iter;
 | 
|---|
 | 101 |   for(iter=atoms.begin();iter!=atoms.end();++iter){
 | 
|---|
 | 102 |     int id = (*iter)->getId();
 | 
|---|
 | 103 |     if(found.count(id))
 | 
|---|
 | 104 |       return false;
 | 
|---|
 | 105 |     found.insert(id);
 | 
|---|
 | 106 |   }
 | 
|---|
 | 107 |   return true;
 | 
|---|
 | 108 | }
 | 
|---|
 | 109 | 
 | 
|---|
 | 110 | 
 | 
|---|
| [bbab87] | 111 | void AtomDescriptorTest::AtomBaseSetsTest()
 | 
|---|
 | 112 | {
 | 
|---|
| [23b547] | 113 |   std::vector<atom*> allAtoms = World::getInstance().getAllAtoms(AllAtoms());
 | 
|---|
| [57adc7] | 114 |   CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(allAtoms,atomIds));
 | 
|---|
 | 115 |   CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(allAtoms));
 | 
|---|
| [7a1ce5] | 116 | 
 | 
|---|
| [23b547] | 117 |   std::vector<atom*> noAtoms = World::getInstance().getAllAtoms(NoAtoms());
 | 
|---|
| [7a1ce5] | 118 |   CPPUNIT_ASSERT_EQUAL( true , noAtoms.empty());
 | 
|---|
 | 119 | }
 | 
|---|
| [bbab87] | 120 | 
 | 
|---|
 | 121 | void AtomDescriptorTest::AtomIdTest()
 | 
|---|
 | 122 | {
 | 
|---|
| [7a1ce5] | 123 |   // test Atoms from boundaries and middle of the set
 | 
|---|
 | 124 |   atom* testAtom;
 | 
|---|
| [23b547] | 125 |   testAtom = World::getInstance().getAtom(AtomById(atomIds[0]));
 | 
|---|
| [46d958] | 126 |   CPPUNIT_ASSERT(testAtom);
 | 
|---|
 | 127 |   CPPUNIT_ASSERT_EQUAL( atomIds[0], testAtom->getId());
 | 
|---|
| [23b547] | 128 |   testAtom = World::getInstance().getAtom(AtomById(atomIds[ATOM_COUNT/2]));
 | 
|---|
| [46d958] | 129 |   CPPUNIT_ASSERT(testAtom);
 | 
|---|
 | 130 |   CPPUNIT_ASSERT_EQUAL( atomIds[ATOM_COUNT/2], testAtom->getId());
 | 
|---|
| [23b547] | 131 |   testAtom = World::getInstance().getAtom(AtomById(atomIds[ATOM_COUNT-1]));
 | 
|---|
| [46d958] | 132 |   CPPUNIT_ASSERT(testAtom);
 | 
|---|
 | 133 |   CPPUNIT_ASSERT_EQUAL( atomIds[ATOM_COUNT-1], testAtom->getId());
 | 
|---|
 | 134 | 
 | 
|---|
 | 135 |   // find some ID that has not been created
 | 
|---|
| [57adc7] | 136 |   atomId_t outsideId=0;
 | 
|---|
| [46d958] | 137 |   bool res = false;
 | 
|---|
| [57adc7] | 138 |   for(outsideId=0;!res;++outsideId) {
 | 
|---|
| [46d958] | 139 |     res = true;
 | 
|---|
 | 140 |     for(int i = 0; i < ATOM_COUNT; ++i){
 | 
|---|
 | 141 |       res &= atomIds[i]!=outsideId;
 | 
|---|
 | 142 |     }
 | 
|---|
 | 143 |   }
 | 
|---|
| [7a1ce5] | 144 |   // test from outside of set
 | 
|---|
| [23b547] | 145 |   testAtom = World::getInstance().getAtom(AtomById(outsideId));
 | 
|---|
| [7a1ce5] | 146 |   CPPUNIT_ASSERT(!testAtom);
 | 
|---|
 | 147 | }
 | 
|---|
| [bbab87] | 148 | 
 | 
|---|
 | 149 | void AtomDescriptorTest::AtomOfMoleculeTest()
 | 
|---|
 | 150 | {
 | 
|---|
| [b49568] | 151 |   // test Atoms from boundaries and middle of the set
 | 
|---|
 | 152 |   atom* testAtom;
 | 
|---|
 | 153 |   testAtom = World::getInstance().getAtom(AtomById(atomIds[0]));
 | 
|---|
 | 154 |   CPPUNIT_ASSERT(testAtom);
 | 
|---|
 | 155 |   CPPUNIT_ASSERT_EQUAL( atomIds[0], testAtom->getId());
 | 
|---|
 | 156 | 
 | 
|---|
 | 157 |   // create some molecule and associate atom to it
 | 
|---|
 | 158 |   testAtom->setType(1);
 | 
|---|
 | 159 |   molecule * newmol = World::getInstance().createMolecule();
 | 
|---|
 | 160 |   newmol->AddAtom(testAtom);
 | 
|---|
 | 161 |   CPPUNIT_ASSERT_EQUAL(newmol->getId(), testAtom->getMolecule()->getId());
 | 
|---|
 | 162 | 
 | 
|---|
 | 163 |   // get atom by descriptor
 | 
|---|
 | 164 |   World::AtomComposite atoms = World::getInstance().getAllAtoms(AtomOfMolecule(newmol->getId()));
 | 
|---|
 | 165 |   CPPUNIT_ASSERT_EQUAL( (size_t)1, atoms.size() );
 | 
|---|
 | 166 |   CPPUNIT_ASSERT_EQUAL( (*atoms.begin())->getId(), testAtom->getId() );
 | 
|---|
 | 167 | 
 | 
|---|
 | 168 |   // remove molecule again
 | 
|---|
 | 169 |   World::getInstance().destroyMolecule(newmol);
 | 
|---|
 | 170 | }
 | 
|---|
| [bbab87] | 171 | 
 | 
|---|
| [61c364] | 172 | void AtomDescriptorTest::AtomOrderTest()
 | 
|---|
 | 173 | {
 | 
|---|
 | 174 |   atom* testAtom;
 | 
|---|
 | 175 | 
 | 
|---|
 | 176 |   // test in normal order: 1, 2, ...
 | 
|---|
 | 177 |   for(int i=1;i<=ATOM_COUNT;++i){
 | 
|---|
 | 178 |     testAtom = World::getInstance().getAtom(AtomByOrder(i));
 | 
|---|
 | 179 |     CPPUNIT_ASSERT_EQUAL( atomIds[i-1], testAtom->getId());
 | 
|---|
 | 180 |   }
 | 
|---|
 | 181 | 
 | 
|---|
 | 182 |   // test in reverse order: -1, -2, ...
 | 
|---|
 | 183 |   for(int i=1; i<= ATOM_COUNT;++i){
 | 
|---|
 | 184 |     testAtom = World::getInstance().getAtom(AtomByOrder(-i));
 | 
|---|
 | 185 |     CPPUNIT_ASSERT_EQUAL( atomIds[(int)ATOM_COUNT-i], testAtom->getId());
 | 
|---|
 | 186 |   }
 | 
|---|
 | 187 | 
 | 
|---|
 | 188 |   // test from outside of set
 | 
|---|
 | 189 |   testAtom = World::getInstance().getAtom(AtomByOrder(ATOM_COUNT+1));
 | 
|---|
 | 190 |   CPPUNIT_ASSERT(!testAtom);
 | 
|---|
 | 191 |   testAtom = World::getInstance().getAtom(AtomByOrder(-ATOM_COUNT-1));
 | 
|---|
 | 192 |   CPPUNIT_ASSERT(!testAtom);
 | 
|---|
 | 193 | }
 | 
|---|
 | 194 | 
 | 
|---|
 | 195 | 
 | 
|---|
| [bbab87] | 196 | std::set<atomId_t> getDistanceList(const double distance, const Vector &position, atom **list)
 | 
|---|
 | 197 | {
 | 
|---|
 | 198 |   const double distanceSquared = distance*distance;
 | 
|---|
 | 199 |   std::set<atomId_t> reflist;
 | 
|---|
 | 200 |   for (size_t i=0; i<ATOM_COUNT;++i)
 | 
|---|
 | 201 |     if (list[i]->getPosition().DistanceSquared(position) < distanceSquared)
 | 
|---|
 | 202 |       reflist.insert ( list[i]->getId() );
 | 
|---|
 | 203 |   return reflist;
 | 
|---|
 | 204 | }
 | 
|---|
 | 205 | 
 | 
|---|
 | 206 | 
 | 
|---|
 | 207 | std::set<atomId_t> getIdList(const World::AtomComposite &list)
 | 
|---|
 | 208 | {
 | 
|---|
 | 209 |   std::set<atomId_t> testlist;
 | 
|---|
 | 210 |   for (World::AtomComposite::const_iterator iter = list.begin();
 | 
|---|
 | 211 |       iter != list.end(); ++iter)
 | 
|---|
 | 212 |     testlist.insert( (*iter)->getId() );
 | 
|---|
 | 213 |   return testlist;
 | 
|---|
 | 214 | }
 | 
|---|
 | 215 | 
 | 
|---|
| [61c364] | 216 | //void AtomDescriptorTest::AtomsShapeTest()
 | 
|---|
 | 217 | //{
 | 
|---|
 | 218 | //  // align atoms along an axis
 | 
|---|
 | 219 | //  for(int i=0;i<ATOM_COUNT;++i) {
 | 
|---|
 | 220 | //    atoms[i]->setPosition(Vector((double)i, 0., 0.));
 | 
|---|
 | 221 | //    //std::cout << "atoms[" << i << "]: " << atoms[i]->getId() << " at " << atoms[i]->getPosition() << std::endl;
 | 
|---|
 | 222 | //  }
 | 
|---|
 | 223 | //
 | 
|---|
 | 224 | //  // get atom by descriptor ...
 | 
|---|
 | 225 | //  // ... from origin up to 2.5
 | 
|---|
 | 226 | //  {
 | 
|---|
 | 227 | //    const double distance = 1.5;
 | 
|---|
 | 228 | //    Vector position(0.,0.,0.);
 | 
|---|
 | 229 | //    Shape s = Sphere(position, distance);
 | 
|---|
 | 230 | //    World::AtomComposite atomlist = World::getInstance().getAllAtoms(AtomsByShape(s));
 | 
|---|
 | 231 | //    CPPUNIT_ASSERT_EQUAL( (size_t)2, atomlist.size() );
 | 
|---|
 | 232 | //    std::set<atomId_t> reflist = getDistanceList(distance, position, atoms);
 | 
|---|
 | 233 | //    std::set<atomId_t> testlist = getIdList(atomlist);
 | 
|---|
 | 234 | //    CPPUNIT_ASSERT_EQUAL( reflist, testlist );
 | 
|---|
 | 235 | //  }
 | 
|---|
 | 236 | //  // ... from (4,0,0) up to 2.9 (i.e. more shells or different view)
 | 
|---|
 | 237 | //  {
 | 
|---|
 | 238 | //    const double distance = 2.9;
 | 
|---|
 | 239 | //    Vector position(4.,0.,0.);
 | 
|---|
 | 240 | //    Shape s = Sphere(position, distance);
 | 
|---|
 | 241 | //    World::AtomComposite atomlist = World::getInstance().getAllAtoms(AtomsByShape(s));
 | 
|---|
 | 242 | //    CPPUNIT_ASSERT_EQUAL( (size_t)5, atomlist.size() );
 | 
|---|
 | 243 | //    std::set<atomId_t> reflist = getDistanceList(distance, position, atoms);
 | 
|---|
 | 244 | //    std::set<atomId_t> testlist = getIdList(atomlist);
 | 
|---|
 | 245 | //    CPPUNIT_ASSERT_EQUAL( reflist, testlist );
 | 
|---|
 | 246 | //  }
 | 
|---|
 | 247 | //  // ... from (10,0,0) up to 1.5
 | 
|---|
 | 248 | //  {
 | 
|---|
 | 249 | //    const double distance = 1.5;
 | 
|---|
 | 250 | //    Vector *position = new Vector(10.,0.,0.);
 | 
|---|
 | 251 | //    Shape s = Sphere(position, distance);
 | 
|---|
 | 252 | //    World::AtomComposite atomlist = World::getInstance().getAllAtoms(AtomsByShape(s));
 | 
|---|
 | 253 | //    CPPUNIT_ASSERT_EQUAL( (size_t)1, atomlist.size() );
 | 
|---|
 | 254 | //    std::set<atomId_t> reflist = getDistanceList(distance, *position, atoms);
 | 
|---|
 | 255 | //    std::set<atomId_t> testlist = getIdList(atomlist);
 | 
|---|
 | 256 | //    CPPUNIT_ASSERT_EQUAL( reflist, testlist );
 | 
|---|
 | 257 | //    delete position;
 | 
|---|
 | 258 | //  }
 | 
|---|
 | 259 | //}
 | 
|---|
 | 260 | 
 | 
|---|
| [bbab87] | 261 | void AtomDescriptorTest::AtomsWithinDistanceOfTest()
 | 
|---|
 | 262 | {
 | 
|---|
 | 263 |   // align atoms along an axis
 | 
|---|
 | 264 |   for(int i=0;i<ATOM_COUNT;++i) {
 | 
|---|
 | 265 |     atoms[i]->setPosition(Vector((double)i, 0., 0.));
 | 
|---|
 | 266 |     //std::cout << "atoms[" << i << "]: " << atoms[i]->getId() << " at " << atoms[i]->getPosition() << std::endl;
 | 
|---|
 | 267 |   }
 | 
|---|
 | 268 | 
 | 
|---|
 | 269 |   // get atom by descriptor ...
 | 
|---|
 | 270 |   // ... from origin up to 2.5
 | 
|---|
 | 271 |   {
 | 
|---|
 | 272 |     const double distance = 1.5;
 | 
|---|
 | 273 |     Vector position(0.,0.,0.);
 | 
|---|
 | 274 |     World::AtomComposite atomlist = World::getInstance().getAllAtoms(AtomsWithinDistanceOf(distance, position));
 | 
|---|
 | 275 |     CPPUNIT_ASSERT_EQUAL( (size_t)2, atomlist.size() );
 | 
|---|
 | 276 |     std::set<atomId_t> reflist = getDistanceList(distance, position, atoms);
 | 
|---|
 | 277 |     std::set<atomId_t> testlist = getIdList(atomlist);
 | 
|---|
| [87d6bd] | 278 |     CPPUNIT_ASSERT( reflist == testlist );
 | 
|---|
| [bbab87] | 279 |   }
 | 
|---|
 | 280 |   // ... from (4,0,0) up to 2.9 (i.e. more shells or different view)
 | 
|---|
 | 281 |   {
 | 
|---|
 | 282 |     const double distance = 2.9;
 | 
|---|
 | 283 |     World::AtomComposite atomlist = World::getInstance().getAllAtoms(AtomsWithinDistanceOf(distance, Vector(4.,0.,0.)));
 | 
|---|
 | 284 |     CPPUNIT_ASSERT_EQUAL( (size_t)5, atomlist.size() );
 | 
|---|
 | 285 |     std::set<atomId_t> reflist = getDistanceList(distance, Vector(4.,0.,0.), atoms);
 | 
|---|
 | 286 |     std::set<atomId_t> testlist = getIdList(atomlist);
 | 
|---|
| [87d6bd] | 287 |     CPPUNIT_ASSERT( reflist == testlist );
 | 
|---|
| [bbab87] | 288 |   }
 | 
|---|
 | 289 |   // ... from (10,0,0) up to 1.5
 | 
|---|
 | 290 |   {
 | 
|---|
 | 291 |     const double distance = 1.5;
 | 
|---|
 | 292 |     Vector *position = new Vector(10.,0.,0.);
 | 
|---|
 | 293 |     World::AtomComposite atomlist = World::getInstance().getAllAtoms(AtomsWithinDistanceOf(distance, *position));
 | 
|---|
 | 294 |     CPPUNIT_ASSERT_EQUAL( (size_t)1, atomlist.size() );
 | 
|---|
 | 295 |     std::set<atomId_t> reflist = getDistanceList(distance, *position, atoms);
 | 
|---|
 | 296 |     std::set<atomId_t> testlist = getIdList(atomlist);
 | 
|---|
| [87d6bd] | 297 |     CPPUNIT_ASSERT( reflist == testlist );
 | 
|---|
| [bbab87] | 298 |     delete position;
 | 
|---|
 | 299 |   }
 | 
|---|
 | 300 | }
 | 
|---|
 | 301 | 
 | 
|---|
 | 302 | void AtomDescriptorTest::AtomCalcTest()
 | 
|---|
 | 303 | {
 | 
|---|
| [7a1ce5] | 304 |   // test some elementary set operations
 | 
|---|
 | 305 |   {
 | 
|---|
| [23b547] | 306 |     std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(AllAtoms()||NoAtoms());
 | 
|---|
| [57adc7] | 307 |     CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(testAtoms,atomIds));
 | 
|---|
 | 308 |     CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(testAtoms));
 | 
|---|
| [7a1ce5] | 309 |   }
 | 
|---|
 | 310 | 
 | 
|---|
 | 311 |   {
 | 
|---|
| [23b547] | 312 |     std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(NoAtoms()||AllAtoms());
 | 
|---|
| [57adc7] | 313 |     CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(testAtoms,atomIds));
 | 
|---|
 | 314 |     CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(testAtoms));
 | 
|---|
| [7a1ce5] | 315 |   }
 | 
|---|
 | 316 | 
 | 
|---|
 | 317 |   {
 | 
|---|
| [23b547] | 318 |     std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(NoAtoms()&&AllAtoms());
 | 
|---|
| [7a1ce5] | 319 |     CPPUNIT_ASSERT_EQUAL( true , testAtoms.empty());
 | 
|---|
 | 320 |   }
 | 
|---|
 | 321 | 
 | 
|---|
 | 322 |   {
 | 
|---|
| [23b547] | 323 |     std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(AllAtoms()&&NoAtoms());
 | 
|---|
| [7a1ce5] | 324 |     CPPUNIT_ASSERT_EQUAL( true , testAtoms.empty());
 | 
|---|
 | 325 |   }
 | 
|---|
 | 326 | 
 | 
|---|
 | 327 |   {
 | 
|---|
| [23b547] | 328 |     std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(!AllAtoms());
 | 
|---|
| [7a1ce5] | 329 |     CPPUNIT_ASSERT_EQUAL( true , testAtoms.empty());
 | 
|---|
 | 330 |   }
 | 
|---|
 | 331 | 
 | 
|---|
 | 332 |   {
 | 
|---|
| [23b547] | 333 |     std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(!NoAtoms());
 | 
|---|
| [57adc7] | 334 |     CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(testAtoms,atomIds));
 | 
|---|
 | 335 |     CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(testAtoms));
 | 
|---|
| [7a1ce5] | 336 |   }
 | 
|---|
 | 337 |   // exclude and include some atoms
 | 
|---|
 | 338 |   {
 | 
|---|
| [23b547] | 339 |     std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(AllAtoms()&&(!AtomById(atomIds[ATOM_COUNT/2])));
 | 
|---|
| [57adc7] | 340 |     std::set<atomId_t> excluded;
 | 
|---|
| [46d958] | 341 |     excluded.insert(atomIds[ATOM_COUNT/2]);
 | 
|---|
| [57adc7] | 342 |     CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(testAtoms,atomIds,excluded));
 | 
|---|
 | 343 |     CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(testAtoms));
 | 
|---|
| [7a1ce5] | 344 |     CPPUNIT_ASSERT_EQUAL( (size_t)(ATOM_COUNT-1), testAtoms.size());
 | 
|---|
 | 345 |   }
 | 
|---|
 | 346 | 
 | 
|---|
 | 347 |   {
 | 
|---|
| [23b547] | 348 |     std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(NoAtoms()||(AtomById(atomIds[ATOM_COUNT/2])));
 | 
|---|
| [7a1ce5] | 349 |     CPPUNIT_ASSERT_EQUAL( (size_t)1, testAtoms.size());
 | 
|---|
| [46d958] | 350 |     CPPUNIT_ASSERT_EQUAL( atomIds[ATOM_COUNT/2], testAtoms[0]->getId());
 | 
|---|
| [7a1ce5] | 351 |   }
 | 
|---|
 | 352 | }
 | 
|---|