| 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"
 | 
|---|
| 24 | #include "World.hpp"
 | 
|---|
| 25 | 
 | 
|---|
| 26 | #ifdef HAVE_TESTRUNNER
 | 
|---|
| 27 | #include "UnitTestMain.hpp"
 | 
|---|
| 28 | #endif /*HAVE_TESTRUNNER*/
 | 
|---|
| 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
 | 
|---|
| 41 |   hydrogen = World::getInstance().getPeriode()->FindElement(1);
 | 
|---|
| 42 |   CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen");
 | 
|---|
| 43 | 
 | 
|---|
| 44 |   // construct molecule (water molecule)
 | 
|---|
| 45 |   TestMolecule = World::getInstance().createMolecule();
 | 
|---|
| 46 |   CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule");
 | 
|---|
| 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.) {
 | 
|---|
| 50 |         Walker = World::getInstance().createAtom();
 | 
|---|
| 51 |         CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
 | 
|---|
| 52 |         Walker->type = hydrogen;
 | 
|---|
| 53 |         *Walker->node = Vector(x, y, z );
 | 
|---|
| 54 |         TestMolecule->AddAtom(Walker);
 | 
|---|
| 55 |       }
 | 
|---|
| 56 | 
 | 
|---|
| 57 |   // construct linked cell
 | 
|---|
| 58 |   LC = new LinkedCell (TestMolecule, 1.);
 | 
|---|
| 59 |   CPPUNIT_ASSERT(LC != NULL && "could not create LinkedCell");
 | 
|---|
| 60 | 
 | 
|---|
| 61 |   // check that TestMolecule was correctly constructed
 | 
|---|
| 62 |   CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 3*3*3 );
 | 
|---|
| 63 | };
 | 
|---|
| 64 | 
 | 
|---|
| 65 | 
 | 
|---|
| 66 | void LinkedCellTest::tearDown()
 | 
|---|
| 67 | {
 | 
|---|
| 68 |   delete(LC);
 | 
|---|
| 69 |   World::purgeInstance();
 | 
|---|
| 70 | };
 | 
|---|
| 71 | 
 | 
|---|
| 72 | 
 | 
|---|
| 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 | 
 | 
|---|
| 103 | /** UnitTest for LinkedCell::GetCurrentCell().
 | 
|---|
| 104 |  * Note that CheckBounds() is used and has to be tested already.
 | 
|---|
| 105 |  */
 | 
|---|
| 106 | void LinkedCellTest::GetCurrentCellTest()
 | 
|---|
| 107 | {
 | 
|---|
| 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() );
 | 
|---|
| 123 | };
 | 
|---|
| 124 | 
 | 
|---|
| 125 | /** UnitTest for LinkedCell::GetRelativeToCurrentCell().
 | 
|---|
| 126 |  */
 | 
|---|
| 127 | void LinkedCellTest::GetRelativeToCurrentCellTest()
 | 
|---|
| 128 | {
 | 
|---|
| 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) );
 | 
|---|
| 179 | };
 | 
|---|
| 180 | 
 | 
|---|
| 181 | 
 | 
|---|
| 182 | /** UnitTest for LinkedCell::SetIndexToNode().
 | 
|---|
| 183 |  */
 | 
|---|
| 184 | void LinkedCellTest::SetIndexToNodeTest()
 | 
|---|
| 185 | {
 | 
|---|
| 186 |   // check all atoms
 | 
|---|
| 187 |   for(molecule::iterator iter = TestMolecule->begin(); iter != TestMolecule->end();++iter){
 | 
|---|
| 188 |     CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToNode(*iter) );
 | 
|---|
| 189 |   }
 | 
|---|
| 190 | 
 | 
|---|
| 191 |   // check internal vectors, returns false, because this atom is not in LC-list!
 | 
|---|
| 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);
 | 
|---|
| 197 | 
 | 
|---|
| 198 |   // check out of bounds vectors
 | 
|---|
| 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);
 | 
|---|
| 204 | };
 | 
|---|
| 205 | 
 | 
|---|
| 206 | 
 | 
|---|
| 207 | /** UnitTest for LinkedCell::SetIndexToVector().
 | 
|---|
| 208 |  */
 | 
|---|
| 209 | void LinkedCellTest::SetIndexToVectorTest()
 | 
|---|
| 210 | {
 | 
|---|
| 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.) {
 | 
|---|
| 217 |         tester = Vector(x,y,z);
 | 
|---|
| 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.) {
 | 
|---|
| 224 |         tester= Vector(x,y,z);
 | 
|---|
| 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) {
 | 
|---|
| 232 |         tester = Vector(x,y,z);
 | 
|---|
| 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
 | 
|---|
| 237 |   tester= Vector(-423598,3245978,29349);
 | 
|---|
| 238 |   cout << "The following test is supposed to fail and produce an ERROR." << endl;
 | 
|---|
| 239 |   CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToVector(&tester) );
 | 
|---|
| 240 | };
 | 
|---|
| 241 | 
 | 
|---|
| 242 | 
 | 
|---|
| 243 | /** UnitTest for LinkedCell::GetNeighbourBounds().
 | 
|---|
| 244 |  */
 | 
|---|
| 245 | void LinkedCellTest::GetNeighbourBoundsTest()
 | 
|---|
| 246 | {
 | 
|---|
| 247 |   Vector tester;
 | 
|---|
| 248 |   int lower[NDIM], upper[NDIM];
 | 
|---|
| 249 | 
 | 
|---|
| 250 |   tester= Vector(0.5,0.5,0.5);
 | 
|---|
| 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]);
 | 
|---|
| 257 | };
 | 
|---|
| 258 | 
 | 
|---|
| 259 | 
 | 
|---|
| 260 | /** UnitTest for LinkedCell::GetallNeighbours().
 | 
|---|
| 261 |  */
 | 
|---|
| 262 | void LinkedCellTest::GetallNeighboursTest()
 | 
|---|
| 263 | {
 | 
|---|
| 264 |   Vector tester;
 | 
|---|
| 265 |   LinkedCell::LinkedNodes *ListOfPoints = NULL;
 | 
|---|
| 266 |   size_t size = 0;
 | 
|---|
| 267 | 
 | 
|---|
| 268 |   // get all atoms
 | 
|---|
| 269 |   tester= Vector(1.5,1.5,1.5);
 | 
|---|
| 270 |   CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(&tester) );
 | 
|---|
| 271 |   ListOfPoints = LC->GetallNeighbours();
 | 
|---|
| 272 |   size = ListOfPoints->size();
 | 
|---|
| 273 |   CPPUNIT_ASSERT_EQUAL( (size_t)27, size );
 | 
|---|
| 274 | 
 | 
|---|
| 275 |   for(molecule::iterator iter = TestMolecule->begin(); iter != TestMolecule->end(); ++iter){
 | 
|---|
| 276 |     ListOfPoints->remove((*iter));
 | 
|---|
| 277 |     size--;
 | 
|---|
| 278 |     CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() );
 | 
|---|
| 279 |   }
 | 
|---|
| 280 |   CPPUNIT_ASSERT_EQUAL( (size_t)0, size );
 | 
|---|
| 281 |   CPPUNIT_ASSERT_EQUAL( (size_t)0, ListOfPoints->size() );
 | 
|---|
| 282 |   CPPUNIT_ASSERT_EQUAL( true, ListOfPoints->empty() );
 | 
|---|
| 283 |   delete(ListOfPoints);
 | 
|---|
| 284 | 
 | 
|---|
| 285 |   // get all atoms in one corner
 | 
|---|
| 286 |   tester= Vector(0.5, 0.5, 0.5);
 | 
|---|
| 287 |   CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(&tester) );
 | 
|---|
| 288 |   ListOfPoints = LC->GetallNeighbours();
 | 
|---|
| 289 |   size=ListOfPoints->size();
 | 
|---|
| 290 |   CPPUNIT_ASSERT_EQUAL( (size_t)8, size );
 | 
|---|
| 291 |   for(molecule::iterator iter = TestMolecule->begin(); iter != TestMolecule->end(); ++iter){
 | 
|---|
| 292 |     if (((*iter)->x[0] <2) && ((*iter)->x[1] <2) && ((*iter)->x[2] <2)) {
 | 
|---|
| 293 |       ListOfPoints->remove(*iter);
 | 
|---|
| 294 |       size--;
 | 
|---|
| 295 |       CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() );
 | 
|---|
| 296 |     }
 | 
|---|
| 297 |   }
 | 
|---|
| 298 |   CPPUNIT_ASSERT_EQUAL( (size_t)0, size );
 | 
|---|
| 299 |   CPPUNIT_ASSERT_EQUAL( (size_t)0, ListOfPoints->size() );
 | 
|---|
| 300 |   CPPUNIT_ASSERT_EQUAL( true, ListOfPoints->empty() );
 | 
|---|
| 301 |   delete(ListOfPoints);
 | 
|---|
| 302 | 
 | 
|---|
| 303 |   // get all atoms from one corner
 | 
|---|
| 304 |   tester = Vector(0.5, 0.5, 0.5);
 | 
|---|
| 305 |   CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(&tester) );
 | 
|---|
| 306 |   ListOfPoints = LC->GetallNeighbours(3);
 | 
|---|
| 307 |   size=ListOfPoints->size();
 | 
|---|
| 308 |   CPPUNIT_ASSERT_EQUAL( (size_t)27, size );
 | 
|---|
| 309 |   for(molecule::iterator iter = TestMolecule->begin(); iter!=TestMolecule->end();++iter){
 | 
|---|
| 310 |     ListOfPoints->remove(*iter);
 | 
|---|
| 311 |     size--;
 | 
|---|
| 312 |     CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() );
 | 
|---|
| 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 | 
 | 
|---|
| 320 | 
 | 
|---|
| 321 | /** UnitTest for LinkedCell::GetPointsInsideSphere().
 | 
|---|
| 322 |  */
 | 
|---|
| 323 | void LinkedCellTest::GetPointsInsideSphereTest()
 | 
|---|
| 324 | {
 | 
|---|
| 325 |   Vector tester;
 | 
|---|
| 326 |   LinkedCell::LinkedNodes *ListOfPoints = NULL;
 | 
|---|
| 327 |   size_t size = 0;
 | 
|---|
| 328 | 
 | 
|---|
| 329 |   // get all points around central arom with radius 1.
 | 
|---|
| 330 |   tester= Vector(1.5,1.5,1.5);
 | 
|---|
| 331 |   CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(&tester) );
 | 
|---|
| 332 |   ListOfPoints = LC->GetPointsInsideSphere(1., &tester);
 | 
|---|
| 333 |   size = ListOfPoints->size();
 | 
|---|
| 334 |   CPPUNIT_ASSERT_EQUAL( (size_t)7, size );
 | 
|---|
| 335 |   for(molecule::iterator iter = TestMolecule->begin(); iter!=TestMolecule->end();++iter){
 | 
|---|
| 336 |     if (((*iter)->x.DistanceSquared(tester) - 1.) < MYEPSILON ) {
 | 
|---|
| 337 |       ListOfPoints->remove(*iter);
 | 
|---|
| 338 |       size--;
 | 
|---|
| 339 |       CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() );
 | 
|---|
| 340 |     }
 | 
|---|
| 341 |   }
 | 
|---|
| 342 |   CPPUNIT_ASSERT_EQUAL( (size_t)0, size );
 | 
|---|
| 343 |   CPPUNIT_ASSERT_EQUAL( (size_t)0, ListOfPoints->size() );
 | 
|---|
| 344 |   CPPUNIT_ASSERT_EQUAL( true, ListOfPoints->empty() );
 | 
|---|
| 345 |   delete(ListOfPoints);
 | 
|---|
| 346 | };
 | 
|---|