| [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 |   // init private all pointers to zero
 | 
|---|
 | 41 |   TestMolecule = NULL;
 | 
|---|
 | 42 |   hydrogen = NULL;
 | 
|---|
 | 43 |   tafel = NULL;
 | 
|---|
 | 44 | 
 | 
|---|
 | 45 |   // construct element
 | 
|---|
 | 46 |   hydrogen = new element;
 | 
|---|
 | 47 |   hydrogen->Z = 1;
 | 
|---|
 | 48 |   hydrogen->CovalentRadius = 0.23;
 | 
|---|
 | 49 |   strcpy(hydrogen->name, "hydrogen");
 | 
|---|
 | 50 |   strcpy(hydrogen->symbol, "H");
 | 
|---|
 | 51 | 
 | 
|---|
 | 52 |   // construct periodentafel
 | 
|---|
| [5f612ee] | 53 |   tafel = World::getInstance().getPeriode();
 | 
|---|
| [dcea0f] | 54 |   tafel->AddElement(hydrogen);
 | 
|---|
 | 55 | 
 | 
|---|
 | 56 |   // construct molecule (water molecule)
 | 
|---|
| [5f612ee] | 57 |   TestMolecule = World::getInstance().createMolecule();
 | 
|---|
| [4f9e47] | 58 |   for (double x=0.5;x<3;x+=1.)
 | 
|---|
 | 59 |     for (double y=0.5;y<3;y+=1.)
 | 
|---|
 | 60 |       for (double z=0.5;z<3;z+=1.) {
 | 
|---|
| [5f612ee] | 61 |         Walker = World::getInstance().createAtom();
 | 
|---|
| [4f9e47] | 62 |         Walker->type = hydrogen;
 | 
|---|
| [8cbb97] | 63 |         *Walker->node = Vector(x, y, z );
 | 
|---|
| [4f9e47] | 64 |         TestMolecule->AddAtom(Walker);
 | 
|---|
 | 65 |       }
 | 
|---|
 | 66 | 
 | 
|---|
 | 67 |   // construct linked cell
 | 
|---|
 | 68 |   LC = new LinkedCell (TestMolecule, 1.);
 | 
|---|
| [dcea0f] | 69 | 
 | 
|---|
 | 70 |   // check that TestMolecule was correctly constructed
 | 
|---|
| [4f9e47] | 71 |   CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 3*3*3 );
 | 
|---|
| [dcea0f] | 72 |   Walker = TestMolecule->start->next;
 | 
|---|
 | 73 |   CPPUNIT_ASSERT( TestMolecule->end != Walker );
 | 
|---|
 | 74 | };
 | 
|---|
 | 75 | 
 | 
|---|
 | 76 | 
 | 
|---|
 | 77 | void LinkedCellTest::tearDown()
 | 
|---|
 | 78 | {
 | 
|---|
 | 79 |   delete(LC);
 | 
|---|
| [5f612ee] | 80 |   World::purgeInstance();
 | 
|---|
 | 81 |   MemoryUsageObserver::purgeInstance();
 | 
|---|
| [dcea0f] | 82 | };
 | 
|---|
 | 83 | 
 | 
|---|
 | 84 | 
 | 
|---|
| [4f9e47] | 85 | /** UnitTest for LinkedCell::CheckBounds().
 | 
|---|
 | 86 |  */
 | 
|---|
 | 87 | void LinkedCellTest::CheckBoundsTest()
 | 
|---|
 | 88 | {
 | 
|---|
 | 89 |   // check for within bounds
 | 
|---|
 | 90 |   LC->n[0] = LC->n[1] = LC->n[2] = 0;
 | 
|---|
 | 91 |   CPPUNIT_ASSERT_EQUAL( true, LC->CheckBounds() );
 | 
|---|
 | 92 |   LC->n[0] = LC->n[1] = LC->n[2] = 1;
 | 
|---|
 | 93 |   CPPUNIT_ASSERT_EQUAL( true, LC->CheckBounds() );
 | 
|---|
 | 94 |   LC->n[0] = LC->n[1] = LC->n[2] = 2;
 | 
|---|
 | 95 |   CPPUNIT_ASSERT_EQUAL( true, LC->CheckBounds() );
 | 
|---|
 | 96 | 
 | 
|---|
 | 97 |   // check for out of bounds
 | 
|---|
 | 98 |   cout << "The following test is supposed to fail and produce an ERROR." << endl;
 | 
|---|
 | 99 |   LC->n[0] = 404040;
 | 
|---|
 | 100 |   CPPUNIT_ASSERT_EQUAL( false, LC->CheckBounds() );
 | 
|---|
 | 101 |   cout << "The following test is supposed to fail and produce an ERROR." << endl;
 | 
|---|
 | 102 |   LC->n[0] = 0;
 | 
|---|
 | 103 |   LC->n[1] = 5000;
 | 
|---|
 | 104 |   CPPUNIT_ASSERT_EQUAL( false, LC->CheckBounds() );
 | 
|---|
 | 105 |   cout << "The following test is supposed to fail and produce an ERROR." << endl;
 | 
|---|
 | 106 |   LC->n[1] = 0;
 | 
|---|
 | 107 |   LC->n[2] = -70;
 | 
|---|
 | 108 |   CPPUNIT_ASSERT_EQUAL( false, LC->CheckBounds() );
 | 
|---|
 | 109 |   cout << "The following test is supposed to fail and produce an ERROR." << endl;
 | 
|---|
 | 110 |   LC->n[0] = LC->n[1] = LC->n[2] = 3;
 | 
|---|
 | 111 |   CPPUNIT_ASSERT_EQUAL( false, LC->CheckBounds() );
 | 
|---|
 | 112 | };
 | 
|---|
 | 113 | 
 | 
|---|
 | 114 | 
 | 
|---|
| [dcea0f] | 115 | /** UnitTest for LinkedCell::GetCurrentCell().
 | 
|---|
| [4f9e47] | 116 |  * Note that CheckBounds() is used and has to be tested already.
 | 
|---|
| [dcea0f] | 117 |  */
 | 
|---|
 | 118 | void LinkedCellTest::GetCurrentCellTest()
 | 
|---|
 | 119 | {
 | 
|---|
| [4f9e47] | 120 |   // within bounds
 | 
|---|
 | 121 |   LC->n[0] = LC->n[1] = LC->n[2] = 0;
 | 
|---|
 | 122 |   CPPUNIT_ASSERT_EQUAL( (const LinkedCell::LinkedNodes*)&LC->LC[0 * 3*3 + 0 * 3 + 0], LC->GetCurrentCell() );
 | 
|---|
 | 123 |   LC->n[0] = LC->n[1] = LC->n[2] = 1;
 | 
|---|
 | 124 |   CPPUNIT_ASSERT_EQUAL( (const LinkedCell::LinkedNodes*)&LC->LC[1 * 3*3 + 1 * 3 + 1], LC->GetCurrentCell() );
 | 
|---|
 | 125 |   LC->n[0] = LC->n[1] = LC->n[2] = 2;
 | 
|---|
 | 126 |   CPPUNIT_ASSERT_EQUAL( (const LinkedCell::LinkedNodes*)&LC->LC[2 * 3*3 + 2 * 3 + 2], LC->GetCurrentCell() );
 | 
|---|
 | 127 | 
 | 
|---|
 | 128 |   // out of bounds
 | 
|---|
 | 129 |   LC->n[0] = LC->n[1] = LC->n[2] = 3;
 | 
|---|
 | 130 |   cout << "The following test is supposed to fail and produce an ERROR." << endl;
 | 
|---|
 | 131 |   CPPUNIT_ASSERT_EQUAL( (const LinkedCell::LinkedNodes*)NULL, LC->GetCurrentCell() );
 | 
|---|
 | 132 |   LC->n[0] = LC->n[1] = LC->n[2] = -1;
 | 
|---|
 | 133 |   cout << "The following test is supposed to fail and produce an ERROR." << endl;
 | 
|---|
 | 134 |   CPPUNIT_ASSERT_EQUAL( (const LinkedCell::LinkedNodes*)NULL, LC->GetCurrentCell() );
 | 
|---|
| [dcea0f] | 135 | };
 | 
|---|
 | 136 | 
 | 
|---|
 | 137 | /** UnitTest for LinkedCell::GetRelativeToCurrentCell().
 | 
|---|
 | 138 |  */
 | 
|---|
 | 139 | void LinkedCellTest::GetRelativeToCurrentCellTest()
 | 
|---|
 | 140 | {
 | 
|---|
| [4f9e47] | 141 |   int offset[3];
 | 
|---|
 | 142 | 
 | 
|---|
 | 143 |   // offset to (0,0,0) always
 | 
|---|
 | 144 |   offset[0] = offset[1] = offset[2] = 0;
 | 
|---|
 | 145 |   LC->n[0] = LC->n[1] = LC->n[2] = 0;
 | 
|---|
 | 146 |   CPPUNIT_ASSERT_EQUAL( (const LinkedCell::LinkedNodes*)&LC->LC[0], LC->GetRelativeToCurrentCell(offset) );
 | 
|---|
 | 147 |   offset[0] = offset[1] = offset[2] = -1;
 | 
|---|
 | 148 |   LC->n[0] = LC->n[1] = LC->n[2] = 1;
 | 
|---|
 | 149 |   CPPUNIT_ASSERT_EQUAL( (const LinkedCell::LinkedNodes*)&LC->LC[0], LC->GetRelativeToCurrentCell(offset) );
 | 
|---|
 | 150 |   offset[0] = offset[1] = offset[2] = -2;
 | 
|---|
 | 151 |   LC->n[0] = LC->n[1] = LC->n[2] = 2;
 | 
|---|
 | 152 |   CPPUNIT_ASSERT_EQUAL( (const LinkedCell::LinkedNodes*)&LC->LC[0], LC->GetRelativeToCurrentCell(offset) );
 | 
|---|
 | 153 | 
 | 
|---|
 | 154 |   // offset to (0,0,0) - 1.*(x/y/z) out of bounds
 | 
|---|
 | 155 |   offset[0] = offset[1] = offset[2] = 0;
 | 
|---|
 | 156 |   offset[0] = -1;
 | 
|---|
 | 157 |   LC->n[0] = LC->n[1] = LC->n[2] = 0;
 | 
|---|
 | 158 |   cout << "The following test is supposed to fail and produce an ERROR." << endl;
 | 
|---|
 | 159 |   CPPUNIT_ASSERT_EQUAL( (const LinkedCell::LinkedNodes*)NULL, LC->GetRelativeToCurrentCell(offset) );
 | 
|---|
 | 160 |   offset[0] = offset[1] = offset[2] = 0;
 | 
|---|
 | 161 |   offset[1] = -1;
 | 
|---|
 | 162 |   LC->n[0] = LC->n[1] = LC->n[2] = 0;
 | 
|---|
 | 163 |   cout << "The following test is supposed to fail and produce an ERROR." << endl;
 | 
|---|
 | 164 |   CPPUNIT_ASSERT_EQUAL( (const LinkedCell::LinkedNodes*)NULL, LC->GetRelativeToCurrentCell(offset) );
 | 
|---|
 | 165 |   offset[0] = offset[1] = offset[2] = 0;
 | 
|---|
 | 166 |   offset[2] = -1;
 | 
|---|
 | 167 |   LC->n[0] = LC->n[1] = LC->n[2] = 0;
 | 
|---|
 | 168 |   cout << "The following test is supposed to fail and produce an ERROR." << endl;
 | 
|---|
 | 169 |   CPPUNIT_ASSERT_EQUAL( (const LinkedCell::LinkedNodes*)NULL, LC->GetRelativeToCurrentCell(offset) );
 | 
|---|
 | 170 | 
 | 
|---|
 | 171 |   // out of bounds
 | 
|---|
 | 172 |   offset[0] = offset[1] = offset[2] = -5054932;
 | 
|---|
 | 173 |   LC->n[0] = LC->n[1] = LC->n[2] = 1;
 | 
|---|
 | 174 |   cout << "The following test is supposed to fail and produce an ERROR." << endl;
 | 
|---|
 | 175 |   CPPUNIT_ASSERT_EQUAL( (const LinkedCell::LinkedNodes*)NULL, LC->GetRelativeToCurrentCell(offset) );
 | 
|---|
 | 176 |   offset[0] = offset[1] = offset[2] = 192345;
 | 
|---|
 | 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;
 | 
|---|
 | 179 |   CPPUNIT_ASSERT_EQUAL( (const LinkedCell::LinkedNodes*)NULL, LC->GetRelativeToCurrentCell(offset) );
 | 
|---|
 | 180 | 
 | 
|---|
 | 181 |   // index is out of bounds, offset points within
 | 
|---|
 | 182 |   offset[0] = offset[1] = offset[2] = -2;
 | 
|---|
 | 183 |   LC->n[0] = LC->n[1] = LC->n[2] = 4;
 | 
|---|
 | 184 |   CPPUNIT_ASSERT_EQUAL( (const LinkedCell::LinkedNodes*)&LC->LC[2 * 3*3 + 2 * 3 + 2], LC->GetRelativeToCurrentCell(offset) );
 | 
|---|
 | 185 | 
 | 
|---|
 | 186 |   // index is within bounds, offset points out
 | 
|---|
 | 187 |   offset[0] = offset[1] = offset[2] = 2;
 | 
|---|
 | 188 |   LC->n[0] = LC->n[1] = LC->n[2] = 2;
 | 
|---|
 | 189 |   cout << "The following test is supposed to fail and produce an ERROR." << endl;
 | 
|---|
 | 190 |   CPPUNIT_ASSERT_EQUAL( (const LinkedCell::LinkedNodes*)NULL, LC->GetRelativeToCurrentCell(offset) );
 | 
|---|
| [dcea0f] | 191 | };
 | 
|---|
 | 192 | 
 | 
|---|
 | 193 | 
 | 
|---|
 | 194 | /** UnitTest for LinkedCell::SetIndexToNode().
 | 
|---|
 | 195 |  */
 | 
|---|
 | 196 | void LinkedCellTest::SetIndexToNodeTest()
 | 
|---|
 | 197 | {
 | 
|---|
| [4f9e47] | 198 |   // check all atoms
 | 
|---|
 | 199 |   atom *Walker = TestMolecule->start;
 | 
|---|
 | 200 |   while (Walker->next != TestMolecule->end) {
 | 
|---|
 | 201 |     Walker = Walker->next;
 | 
|---|
 | 202 |     CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToNode(Walker) );
 | 
|---|
 | 203 |   }
 | 
|---|
 | 204 | 
 | 
|---|
 | 205 |   // check internal vectors, returns false, because this atom is not in LC-list!
 | 
|---|
| [5f612ee] | 206 |   Walker = World::getInstance().createAtom();
 | 
|---|
| [4f9e47] | 207 |   Walker->Name = Malloc<char>(6, "LinkedCellTest::SetIndexToNodeTest - Walker");
 | 
|---|
 | 208 |   strcpy(Walker->Name, "test");
 | 
|---|
| [8cbb97] | 209 |   Walker->x= Vector(1,1,1);
 | 
|---|
| [4f9e47] | 210 |   CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode(Walker) );
 | 
|---|
| [5f612ee] | 211 |   World::getInstance().destroyAtom(Walker);
 | 
|---|
| [4f9e47] | 212 | 
 | 
|---|
 | 213 |   // check out of bounds vectors
 | 
|---|
| [5f612ee] | 214 |   Walker = World::getInstance().createAtom();
 | 
|---|
| [4f9e47] | 215 |   Walker->Name = Malloc<char>(6, "LinkedCellTest::SetIndexToNodeTest - Walker");
 | 
|---|
 | 216 |   strcpy(Walker->Name, "test");
 | 
|---|
| [8cbb97] | 217 |   Walker->x = Vector(0,-1,0);
 | 
|---|
| [4f9e47] | 218 |   CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode(Walker) );
 | 
|---|
| [5f612ee] | 219 |   World::getInstance().destroyAtom(Walker);
 | 
|---|
| [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);
 | 
|---|
| [4f9e47] | 234 |         CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToVector(&tester) );
 | 
|---|
 | 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;
 | 
|---|
 | 242 |         CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToVector(&tester) );
 | 
|---|
 | 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;
 | 
|---|
 | 250 |         CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToVector(&tester) );
 | 
|---|
 | 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;
 | 
|---|
 | 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);
 | 
|---|
| [4f9e47] | 267 |   LC->SetIndexToVector(&tester);
 | 
|---|
 | 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;
 | 
|---|
 | 281 |   LinkedCell::LinkedNodes *ListOfPoints = NULL;
 | 
|---|
 | 282 |   atom *Walker = NULL;
 | 
|---|
 | 283 |   size_t size = 0;
 | 
|---|
 | 284 | 
 | 
|---|
 | 285 |   // get all atoms
 | 
|---|
| [8cbb97] | 286 |   tester= Vector(1.5,1.5,1.5);
 | 
|---|
| [4f9e47] | 287 |   CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(&tester) );
 | 
|---|
 | 288 |   ListOfPoints = LC->GetallNeighbours();
 | 
|---|
 | 289 |   size = ListOfPoints->size();
 | 
|---|
 | 290 |   CPPUNIT_ASSERT_EQUAL( (size_t)27, size );
 | 
|---|
 | 291 |   Walker = TestMolecule->start;
 | 
|---|
 | 292 |   Walker = TestMolecule->start;
 | 
|---|
 | 293 |   while (Walker->next != TestMolecule->end) {
 | 
|---|
 | 294 |     Walker = Walker->next;
 | 
|---|
 | 295 |     ListOfPoints->remove(Walker);
 | 
|---|
 | 296 |     size--;
 | 
|---|
 | 297 |     CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() );
 | 
|---|
 | 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 in 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();
 | 
|---|
 | 308 |   size=ListOfPoints->size();
 | 
|---|
 | 309 |   CPPUNIT_ASSERT_EQUAL( (size_t)8, size );
 | 
|---|
 | 310 |   Walker = TestMolecule->start;
 | 
|---|
 | 311 |   while (Walker->next != TestMolecule->end) {
 | 
|---|
 | 312 |     Walker = Walker->next;
 | 
|---|
| [8cbb97] | 313 |     if ((Walker->x[0] <2) && (Walker->x[1] <2) && (Walker->x[2] <2)) {
 | 
|---|
| [4f9e47] | 314 |       ListOfPoints->remove(Walker);
 | 
|---|
 | 315 |       size--;
 | 
|---|
 | 316 |       CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() );
 | 
|---|
 | 317 |     }
 | 
|---|
 | 318 |   }
 | 
|---|
 | 319 |   CPPUNIT_ASSERT_EQUAL( (size_t)0, size );
 | 
|---|
 | 320 |   CPPUNIT_ASSERT_EQUAL( (size_t)0, ListOfPoints->size() );
 | 
|---|
 | 321 |   CPPUNIT_ASSERT_EQUAL( true, ListOfPoints->empty() );
 | 
|---|
 | 322 |   delete(ListOfPoints);
 | 
|---|
 | 323 | 
 | 
|---|
 | 324 |   // get all atoms from one corner
 | 
|---|
| [8cbb97] | 325 |   tester = Vector(0.5, 0.5, 0.5);
 | 
|---|
| [4f9e47] | 326 |   CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(&tester) );
 | 
|---|
 | 327 |   ListOfPoints = LC->GetallNeighbours(3);
 | 
|---|
 | 328 |   size=ListOfPoints->size();
 | 
|---|
 | 329 |   CPPUNIT_ASSERT_EQUAL( (size_t)27, size );
 | 
|---|
 | 330 |   Walker = TestMolecule->start;
 | 
|---|
 | 331 |   while (Walker->next != TestMolecule->end) {
 | 
|---|
 | 332 |     Walker = Walker->next;
 | 
|---|
 | 333 |     ListOfPoints->remove(Walker);
 | 
|---|
 | 334 |     size--;
 | 
|---|
 | 335 |     CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() );
 | 
|---|
 | 336 |   }
 | 
|---|
 | 337 |   CPPUNIT_ASSERT_EQUAL( (size_t)0, size );
 | 
|---|
 | 338 |   CPPUNIT_ASSERT_EQUAL( (size_t)0, ListOfPoints->size() );
 | 
|---|
 | 339 |   CPPUNIT_ASSERT_EQUAL( true, ListOfPoints->empty() );
 | 
|---|
 | 340 |   delete(ListOfPoints);
 | 
|---|
| [dcea0f] | 341 | };
 | 
|---|
 | 342 | 
 | 
|---|
 | 343 | 
 | 
|---|
 | 344 | /** UnitTest for LinkedCell::GetPointsInsideSphere().
 | 
|---|
 | 345 |  */
 | 
|---|
 | 346 | void LinkedCellTest::GetPointsInsideSphereTest()
 | 
|---|
 | 347 | {
 | 
|---|
| [4f9e47] | 348 |   Vector tester;
 | 
|---|
 | 349 |   LinkedCell::LinkedNodes *ListOfPoints = NULL;
 | 
|---|
 | 350 |   atom *Walker = NULL;
 | 
|---|
 | 351 |   size_t size = 0;
 | 
|---|
 | 352 | 
 | 
|---|
 | 353 |   // get all points around central arom with radius 1.
 | 
|---|
| [8cbb97] | 354 |   tester= Vector(1.5,1.5,1.5);
 | 
|---|
| [4f9e47] | 355 |   CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(&tester) );
 | 
|---|
 | 356 |   ListOfPoints = LC->GetPointsInsideSphere(1., &tester);
 | 
|---|
 | 357 |   size = ListOfPoints->size();
 | 
|---|
 | 358 |   CPPUNIT_ASSERT_EQUAL( (size_t)7, size );
 | 
|---|
 | 359 |   Walker = TestMolecule->start;
 | 
|---|
 | 360 |   while (Walker->next != TestMolecule->end) {
 | 
|---|
 | 361 |     Walker = Walker->next;
 | 
|---|
| [8cbb97] | 362 |     if ((Walker->x.DistanceSquared(tester) - 1.) < MYEPSILON ) {
 | 
|---|
| [4f9e47] | 363 |       ListOfPoints->remove(Walker);
 | 
|---|
 | 364 |       size--;
 | 
|---|
 | 365 |       CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() );
 | 
|---|
 | 366 |     }
 | 
|---|
 | 367 |   }
 | 
|---|
 | 368 |   CPPUNIT_ASSERT_EQUAL( (size_t)0, size );
 | 
|---|
 | 369 |   CPPUNIT_ASSERT_EQUAL( (size_t)0, ListOfPoints->size() );
 | 
|---|
 | 370 |   CPPUNIT_ASSERT_EQUAL( true, ListOfPoints->empty() );
 | 
|---|
 | 371 |   delete(ListOfPoints);
 | 
|---|
| [dcea0f] | 372 | };
 | 
|---|