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