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