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