| [bcf653] | 1 | /*
 | 
|---|
 | 2 |  * Project: MoleCuilder
 | 
|---|
 | 3 |  * Description: creates and alters molecular systems
 | 
|---|
 | 4 |  * Copyright (C)  2010 University of Bonn. All rights reserved.
 | 
|---|
 | 5 |  * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
 | 
|---|
 | 6 |  */
 | 
|---|
 | 7 | 
 | 
|---|
| [dcea0f] | 8 | /*
 | 
|---|
 | 9 |  * LinkedCellUnitTest.cpp
 | 
|---|
 | 10 |  *
 | 
|---|
 | 11 |  *  Created on: Apr 9, 2010
 | 
|---|
 | 12 |  *      Author: heber
 | 
|---|
 | 13 |  */
 | 
|---|
 | 14 | 
 | 
|---|
| [bf3817] | 15 | // include config.h
 | 
|---|
 | 16 | #ifdef HAVE_CONFIG_H
 | 
|---|
 | 17 | #include <config.h>
 | 
|---|
 | 18 | #endif
 | 
|---|
 | 19 | 
 | 
|---|
| [dcea0f] | 20 | using namespace std;
 | 
|---|
 | 21 | 
 | 
|---|
 | 22 | #include <cppunit/CompilerOutputter.h>
 | 
|---|
 | 23 | #include <cppunit/extensions/TestFactoryRegistry.h>
 | 
|---|
 | 24 | #include <cppunit/ui/text/TestRunner.h>
 | 
|---|
 | 25 | 
 | 
|---|
 | 26 | #include <iostream>
 | 
|---|
 | 27 | #include <stdio.h>
 | 
|---|
 | 28 | #include <cstring>
 | 
|---|
 | 29 | 
 | 
|---|
 | 30 | #include "atom.hpp"
 | 
|---|
| [34c43a] | 31 | #include "Descriptors/MoleculeDescriptor.hpp"
 | 
|---|
| [dcea0f] | 32 | #include "element.hpp"
 | 
|---|
 | 33 | #include "linkedcell.hpp"
 | 
|---|
 | 34 | #include "molecule.hpp"
 | 
|---|
 | 35 | #include "periodentafel.hpp"
 | 
|---|
| [34c43a] | 36 | #include "PointCloudAdaptor.hpp"
 | 
|---|
| [5f612ee] | 37 | #include "World.hpp"
 | 
|---|
 | 38 | 
 | 
|---|
| [f844ef] | 39 | #include "LinkedCellUnitTest.hpp"
 | 
|---|
 | 40 | 
 | 
|---|
| [5f612ee] | 41 | #ifdef HAVE_TESTRUNNER
 | 
|---|
 | 42 | #include "UnitTestMain.hpp"
 | 
|---|
 | 43 | #endif /*HAVE_TESTRUNNER*/
 | 
|---|
| [dcea0f] | 44 | 
 | 
|---|
 | 45 | /********************************************** Test classes **************************************/
 | 
|---|
 | 46 | 
 | 
|---|
 | 47 | // Registers the fixture into the 'registry'
 | 
|---|
 | 48 | CPPUNIT_TEST_SUITE_REGISTRATION( LinkedCellTest );
 | 
|---|
 | 49 | 
 | 
|---|
 | 50 | 
 | 
|---|
 | 51 | void LinkedCellTest::setUp()
 | 
|---|
 | 52 | {
 | 
|---|
 | 53 |   atom *Walker = NULL;
 | 
|---|
 | 54 | 
 | 
|---|
 | 55 |   // construct element
 | 
|---|
| [4eb4fe] | 56 |   hydrogen = World::getInstance().getPeriode()->FindElement(1);
 | 
|---|
 | 57 |   CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen");
 | 
|---|
| [dcea0f] | 58 | 
 | 
|---|
 | 59 |   // construct molecule (water molecule)
 | 
|---|
| [5f612ee] | 60 |   TestMolecule = World::getInstance().createMolecule();
 | 
|---|
| [4eb4fe] | 61 |   CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule");
 | 
|---|
| [4f9e47] | 62 |   for (double x=0.5;x<3;x+=1.)
 | 
|---|
 | 63 |     for (double y=0.5;y<3;y+=1.)
 | 
|---|
 | 64 |       for (double z=0.5;z<3;z+=1.) {
 | 
|---|
| [5f612ee] | 65 |         Walker = World::getInstance().createAtom();
 | 
|---|
| [4eb4fe] | 66 |         CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
 | 
|---|
| [d74077] | 67 |         Walker->setType(hydrogen);
 | 
|---|
 | 68 |         Walker->setPosition(Vector(x, y, z ));
 | 
|---|
| [4f9e47] | 69 |         TestMolecule->AddAtom(Walker);
 | 
|---|
 | 70 |       }
 | 
|---|
 | 71 | 
 | 
|---|
 | 72 |   // construct linked cell
 | 
|---|
| [caa06ef] | 73 |   PointCloudAdaptor<molecule> cloud(TestMolecule, TestMolecule->name);
 | 
|---|
| [34c43a] | 74 |   LC = new LinkedCell (cloud, 1.);
 | 
|---|
| [4eb4fe] | 75 |   CPPUNIT_ASSERT(LC != NULL && "could not create LinkedCell");
 | 
|---|
| [dcea0f] | 76 | 
 | 
|---|
 | 77 |   // check that TestMolecule was correctly constructed
 | 
|---|
| [a7b761b] | 78 |   CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 3*3*3 );
 | 
|---|
| [dcea0f] | 79 | };
 | 
|---|
 | 80 | 
 | 
|---|
 | 81 | 
 | 
|---|
 | 82 | void LinkedCellTest::tearDown()
 | 
|---|
 | 83 | {
 | 
|---|
 | 84 |   delete(LC);
 | 
|---|
| [5f612ee] | 85 |   World::purgeInstance();
 | 
|---|
| [dcea0f] | 86 | };
 | 
|---|
 | 87 | 
 | 
|---|
 | 88 | 
 | 
|---|
| [4f9e47] | 89 | /** UnitTest for LinkedCell::CheckBounds().
 | 
|---|
 | 90 |  */
 | 
|---|
 | 91 | void LinkedCellTest::CheckBoundsTest()
 | 
|---|
 | 92 | {
 | 
|---|
 | 93 |   // check for within bounds
 | 
|---|
 | 94 |   LC->n[0] = LC->n[1] = LC->n[2] = 0;
 | 
|---|
 | 95 |   CPPUNIT_ASSERT_EQUAL( true, LC->CheckBounds() );
 | 
|---|
 | 96 |   LC->n[0] = LC->n[1] = LC->n[2] = 1;
 | 
|---|
 | 97 |   CPPUNIT_ASSERT_EQUAL( true, LC->CheckBounds() );
 | 
|---|
 | 98 |   LC->n[0] = LC->n[1] = LC->n[2] = 2;
 | 
|---|
 | 99 |   CPPUNIT_ASSERT_EQUAL( true, LC->CheckBounds() );
 | 
|---|
 | 100 | 
 | 
|---|
 | 101 |   // check for out of bounds
 | 
|---|
 | 102 |   cout << "The following test is supposed to fail and produce an ERROR." << endl;
 | 
|---|
 | 103 |   LC->n[0] = 404040;
 | 
|---|
 | 104 |   CPPUNIT_ASSERT_EQUAL( false, LC->CheckBounds() );
 | 
|---|
 | 105 |   cout << "The following test is supposed to fail and produce an ERROR." << endl;
 | 
|---|
 | 106 |   LC->n[0] = 0;
 | 
|---|
 | 107 |   LC->n[1] = 5000;
 | 
|---|
 | 108 |   CPPUNIT_ASSERT_EQUAL( false, LC->CheckBounds() );
 | 
|---|
 | 109 |   cout << "The following test is supposed to fail and produce an ERROR." << endl;
 | 
|---|
 | 110 |   LC->n[1] = 0;
 | 
|---|
 | 111 |   LC->n[2] = -70;
 | 
|---|
 | 112 |   CPPUNIT_ASSERT_EQUAL( false, LC->CheckBounds() );
 | 
|---|
 | 113 |   cout << "The following test is supposed to fail and produce an ERROR." << endl;
 | 
|---|
 | 114 |   LC->n[0] = LC->n[1] = LC->n[2] = 3;
 | 
|---|
 | 115 |   CPPUNIT_ASSERT_EQUAL( false, LC->CheckBounds() );
 | 
|---|
 | 116 | };
 | 
|---|
 | 117 | 
 | 
|---|
 | 118 | 
 | 
|---|
| [dcea0f] | 119 | /** UnitTest for LinkedCell::GetCurrentCell().
 | 
|---|
| [4f9e47] | 120 |  * Note that CheckBounds() is used and has to be tested already.
 | 
|---|
| [dcea0f] | 121 |  */
 | 
|---|
 | 122 | void LinkedCellTest::GetCurrentCellTest()
 | 
|---|
 | 123 | {
 | 
|---|
| [4f9e47] | 124 |   // within bounds
 | 
|---|
 | 125 |   LC->n[0] = LC->n[1] = LC->n[2] = 0;
 | 
|---|
| [34c43a] | 126 |   CPPUNIT_ASSERT_EQUAL( (const TesselPointSTLList*)&LC->LC[0 * 3*3 + 0 * 3 + 0], LC->GetCurrentCell() );
 | 
|---|
| [4f9e47] | 127 |   LC->n[0] = LC->n[1] = LC->n[2] = 1;
 | 
|---|
| [34c43a] | 128 |   CPPUNIT_ASSERT_EQUAL( (const TesselPointSTLList*)&LC->LC[1 * 3*3 + 1 * 3 + 1], LC->GetCurrentCell() );
 | 
|---|
| [4f9e47] | 129 |   LC->n[0] = LC->n[1] = LC->n[2] = 2;
 | 
|---|
| [34c43a] | 130 |   CPPUNIT_ASSERT_EQUAL( (const TesselPointSTLList*)&LC->LC[2 * 3*3 + 2 * 3 + 2], LC->GetCurrentCell() );
 | 
|---|
| [4f9e47] | 131 | 
 | 
|---|
 | 132 |   // out of bounds
 | 
|---|
 | 133 |   LC->n[0] = LC->n[1] = LC->n[2] = 3;
 | 
|---|
 | 134 |   cout << "The following test is supposed to fail and produce an ERROR." << endl;
 | 
|---|
| [34c43a] | 135 |   CPPUNIT_ASSERT_EQUAL( (const TesselPointSTLList*)NULL, LC->GetCurrentCell() );
 | 
|---|
| [4f9e47] | 136 |   LC->n[0] = LC->n[1] = LC->n[2] = -1;
 | 
|---|
 | 137 |   cout << "The following test is supposed to fail and produce an ERROR." << endl;
 | 
|---|
| [34c43a] | 138 |   CPPUNIT_ASSERT_EQUAL( (const TesselPointSTLList*)NULL, LC->GetCurrentCell() );
 | 
|---|
| [dcea0f] | 139 | };
 | 
|---|
 | 140 | 
 | 
|---|
 | 141 | /** UnitTest for LinkedCell::GetRelativeToCurrentCell().
 | 
|---|
 | 142 |  */
 | 
|---|
 | 143 | void LinkedCellTest::GetRelativeToCurrentCellTest()
 | 
|---|
 | 144 | {
 | 
|---|
| [4f9e47] | 145 |   int offset[3];
 | 
|---|
 | 146 | 
 | 
|---|
 | 147 |   // offset to (0,0,0) always
 | 
|---|
 | 148 |   offset[0] = offset[1] = offset[2] = 0;
 | 
|---|
 | 149 |   LC->n[0] = LC->n[1] = LC->n[2] = 0;
 | 
|---|
| [34c43a] | 150 |   CPPUNIT_ASSERT_EQUAL( (const TesselPointSTLList*)&LC->LC[0], LC->GetRelativeToCurrentCell(offset) );
 | 
|---|
| [4f9e47] | 151 |   offset[0] = offset[1] = offset[2] = -1;
 | 
|---|
 | 152 |   LC->n[0] = LC->n[1] = LC->n[2] = 1;
 | 
|---|
| [34c43a] | 153 |   CPPUNIT_ASSERT_EQUAL( (const TesselPointSTLList*)&LC->LC[0], LC->GetRelativeToCurrentCell(offset) );
 | 
|---|
| [4f9e47] | 154 |   offset[0] = offset[1] = offset[2] = -2;
 | 
|---|
 | 155 |   LC->n[0] = LC->n[1] = LC->n[2] = 2;
 | 
|---|
| [34c43a] | 156 |   CPPUNIT_ASSERT_EQUAL( (const TesselPointSTLList*)&LC->LC[0], LC->GetRelativeToCurrentCell(offset) );
 | 
|---|
| [4f9e47] | 157 | 
 | 
|---|
 | 158 |   // offset to (0,0,0) - 1.*(x/y/z) out of bounds
 | 
|---|
 | 159 |   offset[0] = offset[1] = offset[2] = 0;
 | 
|---|
 | 160 |   offset[0] = -1;
 | 
|---|
 | 161 |   LC->n[0] = LC->n[1] = LC->n[2] = 0;
 | 
|---|
 | 162 |   cout << "The following test is supposed to fail and produce an ERROR." << endl;
 | 
|---|
| [34c43a] | 163 |   CPPUNIT_ASSERT_EQUAL( (const TesselPointSTLList*)NULL, LC->GetRelativeToCurrentCell(offset) );
 | 
|---|
| [4f9e47] | 164 |   offset[0] = offset[1] = offset[2] = 0;
 | 
|---|
 | 165 |   offset[1] = -1;
 | 
|---|
 | 166 |   LC->n[0] = LC->n[1] = LC->n[2] = 0;
 | 
|---|
 | 167 |   cout << "The following test is supposed to fail and produce an ERROR." << endl;
 | 
|---|
| [34c43a] | 168 |   CPPUNIT_ASSERT_EQUAL( (const TesselPointSTLList*)NULL, LC->GetRelativeToCurrentCell(offset) );
 | 
|---|
| [4f9e47] | 169 |   offset[0] = offset[1] = offset[2] = 0;
 | 
|---|
 | 170 |   offset[2] = -1;
 | 
|---|
 | 171 |   LC->n[0] = LC->n[1] = LC->n[2] = 0;
 | 
|---|
 | 172 |   cout << "The following test is supposed to fail and produce an ERROR." << endl;
 | 
|---|
| [34c43a] | 173 |   CPPUNIT_ASSERT_EQUAL( (const TesselPointSTLList*)NULL, LC->GetRelativeToCurrentCell(offset) );
 | 
|---|
| [4f9e47] | 174 | 
 | 
|---|
 | 175 |   // out of bounds
 | 
|---|
 | 176 |   offset[0] = offset[1] = offset[2] = -5054932;
 | 
|---|
 | 177 |   LC->n[0] = LC->n[1] = LC->n[2] = 1;
 | 
|---|
 | 178 |   cout << "The following test is supposed to fail and produce an ERROR." << endl;
 | 
|---|
| [34c43a] | 179 |   CPPUNIT_ASSERT_EQUAL( (const TesselPointSTLList*)NULL, LC->GetRelativeToCurrentCell(offset) );
 | 
|---|
| [4f9e47] | 180 |   offset[0] = offset[1] = offset[2] = 192345;
 | 
|---|
 | 181 |   LC->n[0] = LC->n[1] = LC->n[2] = 1;
 | 
|---|
 | 182 |   cout << "The following test is supposed to fail and produce an ERROR." << endl;
 | 
|---|
| [34c43a] | 183 |   CPPUNIT_ASSERT_EQUAL( (const TesselPointSTLList*)NULL, LC->GetRelativeToCurrentCell(offset) );
 | 
|---|
| [4f9e47] | 184 | 
 | 
|---|
 | 185 |   // index is out of bounds, offset points within
 | 
|---|
 | 186 |   offset[0] = offset[1] = offset[2] = -2;
 | 
|---|
 | 187 |   LC->n[0] = LC->n[1] = LC->n[2] = 4;
 | 
|---|
| [34c43a] | 188 |   CPPUNIT_ASSERT_EQUAL( (const TesselPointSTLList*)&LC->LC[2 * 3*3 + 2 * 3 + 2], LC->GetRelativeToCurrentCell(offset) );
 | 
|---|
| [4f9e47] | 189 | 
 | 
|---|
 | 190 |   // index is within bounds, offset points out
 | 
|---|
 | 191 |   offset[0] = offset[1] = offset[2] = 2;
 | 
|---|
 | 192 |   LC->n[0] = LC->n[1] = LC->n[2] = 2;
 | 
|---|
 | 193 |   cout << "The following test is supposed to fail and produce an ERROR." << endl;
 | 
|---|
| [34c43a] | 194 |   CPPUNIT_ASSERT_EQUAL( (const TesselPointSTLList*)NULL, LC->GetRelativeToCurrentCell(offset) );
 | 
|---|
| [dcea0f] | 195 | };
 | 
|---|
 | 196 | 
 | 
|---|
 | 197 | 
 | 
|---|
 | 198 | /** UnitTest for LinkedCell::SetIndexToNode().
 | 
|---|
 | 199 |  */
 | 
|---|
 | 200 | void LinkedCellTest::SetIndexToNodeTest()
 | 
|---|
 | 201 | {
 | 
|---|
| [4f9e47] | 202 |   // check all atoms
 | 
|---|
| [a7b761b] | 203 |   for(molecule::iterator iter = TestMolecule->begin(); iter != TestMolecule->end();++iter){
 | 
|---|
 | 204 |     CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToNode(*iter) );
 | 
|---|
| [4f9e47] | 205 |   }
 | 
|---|
 | 206 | 
 | 
|---|
 | 207 |   // check internal vectors, returns false, because this atom is not in LC-list!
 | 
|---|
| [a7b761b] | 208 |   atom *newAtom = World::getInstance().createAtom();
 | 
|---|
 | 209 |   newAtom->setName("test");
 | 
|---|
| [d74077] | 210 |   newAtom->setPosition(Vector(1,1,1));
 | 
|---|
| [a7b761b] | 211 |   CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode(newAtom) );
 | 
|---|
 | 212 |   World::getInstance().destroyAtom(newAtom);
 | 
|---|
| [4f9e47] | 213 | 
 | 
|---|
 | 214 |   // check out of bounds vectors
 | 
|---|
| [a7b761b] | 215 |   newAtom = World::getInstance().createAtom();
 | 
|---|
 | 216 |   newAtom->setName("test");
 | 
|---|
| [d74077] | 217 |   newAtom->setPosition(Vector(0,-1,0));
 | 
|---|
| [a7b761b] | 218 |   CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode(newAtom) );
 | 
|---|
 | 219 |   World::getInstance().destroyAtom(newAtom);
 | 
|---|
| [dcea0f] | 220 | };
 | 
|---|
 | 221 | 
 | 
|---|
 | 222 | 
 | 
|---|
 | 223 | /** UnitTest for LinkedCell::SetIndexToVector().
 | 
|---|
 | 224 |  */
 | 
|---|
 | 225 | void LinkedCellTest::SetIndexToVectorTest()
 | 
|---|
 | 226 | {
 | 
|---|
| [4f9e47] | 227 |   Vector tester;
 | 
|---|
 | 228 | 
 | 
|---|
 | 229 |   // check center of each cell
 | 
|---|
 | 230 |   for (double x=0.5;x<3;x+=1.)
 | 
|---|
 | 231 |     for (double y=0.5;y<3;y+=1.)
 | 
|---|
 | 232 |       for (double z=0.5;z<3;z+=1.) {
 | 
|---|
| [8cbb97] | 233 |         tester = Vector(x,y,z);
 | 
|---|
| [d74077] | 234 |         CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToVector(tester) );
 | 
|---|
| [4f9e47] | 235 |       }
 | 
|---|
 | 236 |   // check corners of each cell
 | 
|---|
 | 237 |   for (double x=1.;x<4;x+=1.)
 | 
|---|
 | 238 |     for (double y=1.;y<4;y+=1.)
 | 
|---|
 | 239 |       for (double z=1.;z<4;z+=1.) {
 | 
|---|
| [8cbb97] | 240 |         tester= Vector(x,y,z);
 | 
|---|
| [4f9e47] | 241 |         cout << "Tester is at " << tester << "." << endl;
 | 
|---|
| [d74077] | 242 |         CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToVector(tester) );
 | 
|---|
| [4f9e47] | 243 |       }
 | 
|---|
 | 244 |   // check out of bounds
 | 
|---|
 | 245 |   for (double x=0.5-1e-10;x<5;x+=3.1)
 | 
|---|
 | 246 |     for (double y=0.5-1e-10;y<5;y+=3.1)
 | 
|---|
 | 247 |       for (double z=0.5-1e-10;z<5;z+=3.1) {
 | 
|---|
| [8cbb97] | 248 |         tester = Vector(x,y,z);
 | 
|---|
| [4f9e47] | 249 |         cout << "The following test is supposed to fail and produce an ERROR." << endl;
 | 
|---|
| [d74077] | 250 |         CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToVector(tester) );
 | 
|---|
| [4f9e47] | 251 |       }
 | 
|---|
 | 252 |   // check nonsense vectors
 | 
|---|
| [8cbb97] | 253 |   tester= Vector(-423598,3245978,29349);
 | 
|---|
| [4f9e47] | 254 |   cout << "The following test is supposed to fail and produce an ERROR." << endl;
 | 
|---|
| [d74077] | 255 |   CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToVector(tester) );
 | 
|---|
| [dcea0f] | 256 | };
 | 
|---|
 | 257 | 
 | 
|---|
 | 258 | 
 | 
|---|
 | 259 | /** UnitTest for LinkedCell::GetNeighbourBounds().
 | 
|---|
 | 260 |  */
 | 
|---|
 | 261 | void LinkedCellTest::GetNeighbourBoundsTest()
 | 
|---|
 | 262 | {
 | 
|---|
| [4f9e47] | 263 |   Vector tester;
 | 
|---|
 | 264 |   int lower[NDIM], upper[NDIM];
 | 
|---|
 | 265 | 
 | 
|---|
| [8cbb97] | 266 |   tester= Vector(0.5,0.5,0.5);
 | 
|---|
| [d74077] | 267 |   LC->SetIndexToVector(tester);
 | 
|---|
| [4f9e47] | 268 |   LC->GetNeighbourBounds(lower, upper);
 | 
|---|
 | 269 |   for (int i=0;i<NDIM;i++)
 | 
|---|
 | 270 |     CPPUNIT_ASSERT_EQUAL( 0, lower[i]);
 | 
|---|
 | 271 |   for (int i=0;i<NDIM;i++)
 | 
|---|
 | 272 |     CPPUNIT_ASSERT_EQUAL( 1, upper[i]);
 | 
|---|
| [dcea0f] | 273 | };
 | 
|---|
 | 274 | 
 | 
|---|
 | 275 | 
 | 
|---|
 | 276 | /** UnitTest for LinkedCell::GetallNeighbours().
 | 
|---|
 | 277 |  */
 | 
|---|
 | 278 | void LinkedCellTest::GetallNeighboursTest()
 | 
|---|
 | 279 | {
 | 
|---|
| [4f9e47] | 280 |   Vector tester;
 | 
|---|
| [34c43a] | 281 |   TesselPointSTLList *ListOfPoints = NULL;
 | 
|---|
| [4f9e47] | 282 |   size_t size = 0;
 | 
|---|
 | 283 | 
 | 
|---|
 | 284 |   // get all atoms
 | 
|---|
| [8cbb97] | 285 |   tester= Vector(1.5,1.5,1.5);
 | 
|---|
| [d74077] | 286 |   CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(tester) );
 | 
|---|
| [4f9e47] | 287 |   ListOfPoints = LC->GetallNeighbours();
 | 
|---|
 | 288 |   size = ListOfPoints->size();
 | 
|---|
 | 289 |   CPPUNIT_ASSERT_EQUAL( (size_t)27, size );
 | 
|---|
| [a7b761b] | 290 | 
 | 
|---|
 | 291 |   for(molecule::iterator iter = TestMolecule->begin(); iter != TestMolecule->end(); ++iter){
 | 
|---|
 | 292 |     ListOfPoints->remove((*iter));
 | 
|---|
| [4f9e47] | 293 |     size--;
 | 
|---|
 | 294 |     CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() );
 | 
|---|
 | 295 |   }
 | 
|---|
 | 296 |   CPPUNIT_ASSERT_EQUAL( (size_t)0, size );
 | 
|---|
 | 297 |   CPPUNIT_ASSERT_EQUAL( (size_t)0, ListOfPoints->size() );
 | 
|---|
 | 298 |   CPPUNIT_ASSERT_EQUAL( true, ListOfPoints->empty() );
 | 
|---|
 | 299 |   delete(ListOfPoints);
 | 
|---|
 | 300 | 
 | 
|---|
 | 301 |   // get all atoms in one corner
 | 
|---|
| [8cbb97] | 302 |   tester= Vector(0.5, 0.5, 0.5);
 | 
|---|
| [d74077] | 303 |   CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(tester) );
 | 
|---|
| [4f9e47] | 304 |   ListOfPoints = LC->GetallNeighbours();
 | 
|---|
 | 305 |   size=ListOfPoints->size();
 | 
|---|
 | 306 |   CPPUNIT_ASSERT_EQUAL( (size_t)8, size );
 | 
|---|
| [a7b761b] | 307 |   for(molecule::iterator iter = TestMolecule->begin(); iter != TestMolecule->end(); ++iter){
 | 
|---|
| [d74077] | 308 |     if (((*iter)->at(0) <2) && ((*iter)->at(1) <2) && ((*iter)->at(2) <2)) {
 | 
|---|
| [a7b761b] | 309 |       ListOfPoints->remove(*iter);
 | 
|---|
| [4f9e47] | 310 |       size--;
 | 
|---|
 | 311 |       CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() );
 | 
|---|
 | 312 |     }
 | 
|---|
 | 313 |   }
 | 
|---|
 | 314 |   CPPUNIT_ASSERT_EQUAL( (size_t)0, size );
 | 
|---|
 | 315 |   CPPUNIT_ASSERT_EQUAL( (size_t)0, ListOfPoints->size() );
 | 
|---|
 | 316 |   CPPUNIT_ASSERT_EQUAL( true, ListOfPoints->empty() );
 | 
|---|
 | 317 |   delete(ListOfPoints);
 | 
|---|
 | 318 | 
 | 
|---|
 | 319 |   // get all atoms from one corner
 | 
|---|
| [8cbb97] | 320 |   tester = Vector(0.5, 0.5, 0.5);
 | 
|---|
| [d74077] | 321 |   CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(tester) );
 | 
|---|
| [4f9e47] | 322 |   ListOfPoints = LC->GetallNeighbours(3);
 | 
|---|
 | 323 |   size=ListOfPoints->size();
 | 
|---|
 | 324 |   CPPUNIT_ASSERT_EQUAL( (size_t)27, size );
 | 
|---|
| [a7b761b] | 325 |   for(molecule::iterator iter = TestMolecule->begin(); iter!=TestMolecule->end();++iter){
 | 
|---|
 | 326 |     ListOfPoints->remove(*iter);
 | 
|---|
| [4f9e47] | 327 |     size--;
 | 
|---|
 | 328 |     CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() );
 | 
|---|
 | 329 |   }
 | 
|---|
 | 330 |   CPPUNIT_ASSERT_EQUAL( (size_t)0, size );
 | 
|---|
 | 331 |   CPPUNIT_ASSERT_EQUAL( (size_t)0, ListOfPoints->size() );
 | 
|---|
 | 332 |   CPPUNIT_ASSERT_EQUAL( true, ListOfPoints->empty() );
 | 
|---|
 | 333 |   delete(ListOfPoints);
 | 
|---|
| [dcea0f] | 334 | };
 | 
|---|
 | 335 | 
 | 
|---|
 | 336 | 
 | 
|---|
 | 337 | /** UnitTest for LinkedCell::GetPointsInsideSphere().
 | 
|---|
 | 338 |  */
 | 
|---|
 | 339 | void LinkedCellTest::GetPointsInsideSphereTest()
 | 
|---|
 | 340 | {
 | 
|---|
| [4f9e47] | 341 |   Vector tester;
 | 
|---|
| [34c43a] | 342 |   TesselPointSTLList *ListOfPoints = NULL;
 | 
|---|
| [4f9e47] | 343 |   size_t size = 0;
 | 
|---|
 | 344 | 
 | 
|---|
 | 345 |   // get all points around central arom with radius 1.
 | 
|---|
| [8cbb97] | 346 |   tester= Vector(1.5,1.5,1.5);
 | 
|---|
| [d74077] | 347 |   CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(tester) );
 | 
|---|
| [4f9e47] | 348 |   ListOfPoints = LC->GetPointsInsideSphere(1., &tester);
 | 
|---|
 | 349 |   size = ListOfPoints->size();
 | 
|---|
 | 350 |   CPPUNIT_ASSERT_EQUAL( (size_t)7, size );
 | 
|---|
| [a7b761b] | 351 |   for(molecule::iterator iter = TestMolecule->begin(); iter!=TestMolecule->end();++iter){
 | 
|---|
| [d74077] | 352 |     if (((*iter)->DistanceSquared(tester) - 1.) < MYEPSILON ) {
 | 
|---|
| [a7b761b] | 353 |       ListOfPoints->remove(*iter);
 | 
|---|
| [4f9e47] | 354 |       size--;
 | 
|---|
 | 355 |       CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() );
 | 
|---|
 | 356 |     }
 | 
|---|
 | 357 |   }
 | 
|---|
 | 358 |   CPPUNIT_ASSERT_EQUAL( (size_t)0, size );
 | 
|---|
 | 359 |   CPPUNIT_ASSERT_EQUAL( (size_t)0, ListOfPoints->size() );
 | 
|---|
 | 360 |   CPPUNIT_ASSERT_EQUAL( true, ListOfPoints->empty() );
 | 
|---|
 | 361 |   delete(ListOfPoints);
 | 
|---|
| [dcea0f] | 362 | };
 | 
|---|