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