| [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"); | 
|---|
| [d74077] | 52 | Walker->setType(hydrogen); | 
|---|
|  | 53 | Walker->setPosition(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"); | 
|---|
| [d74077] | 194 | newAtom->setPosition(Vector(1,1,1)); | 
|---|
| [a7b761b] | 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"); | 
|---|
| [d74077] | 201 | newAtom->setPosition(Vector(0,-1,0)); | 
|---|
| [a7b761b] | 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); | 
|---|
| [d74077] | 218 | CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToVector(tester) ); | 
|---|
| [4f9e47] | 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; | 
|---|
| [d74077] | 226 | CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToVector(tester) ); | 
|---|
| [4f9e47] | 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; | 
|---|
| [d74077] | 234 | CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToVector(tester) ); | 
|---|
| [4f9e47] | 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; | 
|---|
| [d74077] | 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); | 
|---|
| [d74077] | 251 | LC->SetIndexToVector(tester); | 
|---|
| [4f9e47] | 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 | size_t size = 0; | 
|---|
|  | 267 |  | 
|---|
|  | 268 | // get all atoms | 
|---|
| [8cbb97] | 269 | tester= Vector(1.5,1.5,1.5); | 
|---|
| [d74077] | 270 | CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(tester) ); | 
|---|
| [4f9e47] | 271 | ListOfPoints = LC->GetallNeighbours(); | 
|---|
|  | 272 | size = ListOfPoints->size(); | 
|---|
|  | 273 | CPPUNIT_ASSERT_EQUAL( (size_t)27, size ); | 
|---|
| [a7b761b] | 274 |  | 
|---|
|  | 275 | for(molecule::iterator iter = TestMolecule->begin(); iter != TestMolecule->end(); ++iter){ | 
|---|
|  | 276 | ListOfPoints->remove((*iter)); | 
|---|
| [4f9e47] | 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 | 
|---|
| [8cbb97] | 286 | tester= Vector(0.5, 0.5, 0.5); | 
|---|
| [d74077] | 287 | CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(tester) ); | 
|---|
| [4f9e47] | 288 | ListOfPoints = LC->GetallNeighbours(); | 
|---|
|  | 289 | size=ListOfPoints->size(); | 
|---|
|  | 290 | CPPUNIT_ASSERT_EQUAL( (size_t)8, size ); | 
|---|
| [a7b761b] | 291 | for(molecule::iterator iter = TestMolecule->begin(); iter != TestMolecule->end(); ++iter){ | 
|---|
| [d74077] | 292 | if (((*iter)->at(0) <2) && ((*iter)->at(1) <2) && ((*iter)->at(2) <2)) { | 
|---|
| [a7b761b] | 293 | ListOfPoints->remove(*iter); | 
|---|
| [4f9e47] | 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 | 
|---|
| [8cbb97] | 304 | tester = Vector(0.5, 0.5, 0.5); | 
|---|
| [d74077] | 305 | CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(tester) ); | 
|---|
| [4f9e47] | 306 | ListOfPoints = LC->GetallNeighbours(3); | 
|---|
|  | 307 | size=ListOfPoints->size(); | 
|---|
|  | 308 | CPPUNIT_ASSERT_EQUAL( (size_t)27, size ); | 
|---|
| [a7b761b] | 309 | for(molecule::iterator iter = TestMolecule->begin(); iter!=TestMolecule->end();++iter){ | 
|---|
|  | 310 | ListOfPoints->remove(*iter); | 
|---|
| [4f9e47] | 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); | 
|---|
| [dcea0f] | 318 | }; | 
|---|
|  | 319 |  | 
|---|
|  | 320 |  | 
|---|
|  | 321 | /** UnitTest for LinkedCell::GetPointsInsideSphere(). | 
|---|
|  | 322 | */ | 
|---|
|  | 323 | void LinkedCellTest::GetPointsInsideSphereTest() | 
|---|
|  | 324 | { | 
|---|
| [4f9e47] | 325 | Vector tester; | 
|---|
|  | 326 | LinkedCell::LinkedNodes *ListOfPoints = NULL; | 
|---|
|  | 327 | size_t size = 0; | 
|---|
|  | 328 |  | 
|---|
|  | 329 | // get all points around central arom with radius 1. | 
|---|
| [8cbb97] | 330 | tester= Vector(1.5,1.5,1.5); | 
|---|
| [d74077] | 331 | CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(tester) ); | 
|---|
| [4f9e47] | 332 | ListOfPoints = LC->GetPointsInsideSphere(1., &tester); | 
|---|
|  | 333 | size = ListOfPoints->size(); | 
|---|
|  | 334 | CPPUNIT_ASSERT_EQUAL( (size_t)7, size ); | 
|---|
| [a7b761b] | 335 | for(molecule::iterator iter = TestMolecule->begin(); iter!=TestMolecule->end();++iter){ | 
|---|
| [d74077] | 336 | if (((*iter)->DistanceSquared(tester) - 1.) < MYEPSILON ) { | 
|---|
| [a7b761b] | 337 | ListOfPoints->remove(*iter); | 
|---|
| [4f9e47] | 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); | 
|---|
| [dcea0f] | 346 | }; | 
|---|