| [bcf653] | 1 | /* | 
|---|
|  | 2 | * Project: MoleCuilder | 
|---|
|  | 3 | * Description: creates and alters molecular systems | 
|---|
|  | 4 | * Copyright (C)  2010 University of Bonn. All rights reserved. | 
|---|
|  | 5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details. | 
|---|
|  | 6 | */ | 
|---|
|  | 7 |  | 
|---|
| [266237] | 8 | /* | 
|---|
| [f844ef] | 9 | * ListOfBondsUnitTest.cpp | 
|---|
| [266237] | 10 | * | 
|---|
|  | 11 | *  Created on: 18 Oct 2009 | 
|---|
|  | 12 | *      Author: user | 
|---|
|  | 13 | */ | 
|---|
|  | 14 |  | 
|---|
| [bf3817] | 15 | // include config.h | 
|---|
|  | 16 | #ifdef HAVE_CONFIG_H | 
|---|
|  | 17 | #include <config.h> | 
|---|
|  | 18 | #endif | 
|---|
|  | 19 |  | 
|---|
| [266237] | 20 | using namespace std; | 
|---|
|  | 21 |  | 
|---|
|  | 22 | #include <cppunit/CompilerOutputter.h> | 
|---|
|  | 23 | #include <cppunit/extensions/TestFactoryRegistry.h> | 
|---|
|  | 24 | #include <cppunit/ui/text/TestRunner.h> | 
|---|
|  | 25 |  | 
|---|
| [49e1ae] | 26 | #include <cstring> | 
|---|
|  | 27 |  | 
|---|
| [255829] | 28 | #include "CodePatterns/Log.hpp" | 
|---|
| [46d958] | 29 | #include "World.hpp" | 
|---|
| [266237] | 30 | #include "atom.hpp" | 
|---|
| [129204] | 31 | #include "Bond/bond.hpp" | 
|---|
| [266237] | 32 | #include "element.hpp" | 
|---|
|  | 33 | #include "molecule.hpp" | 
|---|
|  | 34 | #include "periodentafel.hpp" | 
|---|
| [e6fdbe] | 35 | #include "World.hpp" | 
|---|
| [8aba3c] | 36 | #include "WorldTime.hpp" | 
|---|
| [266237] | 37 |  | 
|---|
| [f844ef] | 38 | #include "ListOfBondsUnitTest.hpp" | 
|---|
|  | 39 |  | 
|---|
| [9b6b2f] | 40 | #ifdef HAVE_TESTRUNNER | 
|---|
|  | 41 | #include "UnitTestMain.hpp" | 
|---|
|  | 42 | #endif /*HAVE_TESTRUNNER*/ | 
|---|
| [266237] | 43 |  | 
|---|
|  | 44 | /********************************************** Test classes **************************************/ | 
|---|
|  | 45 |  | 
|---|
|  | 46 | // Registers the fixture into the 'registry' | 
|---|
|  | 47 | CPPUNIT_TEST_SUITE_REGISTRATION( ListOfBondsTest ); | 
|---|
|  | 48 |  | 
|---|
|  | 49 |  | 
|---|
|  | 50 | void ListOfBondsTest::setUp() | 
|---|
|  | 51 | { | 
|---|
|  | 52 | atom *Walker = NULL; | 
|---|
|  | 53 |  | 
|---|
| [5e2f80] | 54 | WorldTime::setTime(0); | 
|---|
|  | 55 |  | 
|---|
| [266237] | 56 | // construct element | 
|---|
| [4eb4fe] | 57 | hydrogen = World::getInstance().getPeriode()->FindElement(1); | 
|---|
|  | 58 | CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen"); | 
|---|
| [266237] | 59 |  | 
|---|
|  | 60 | // construct molecule (tetraeder of hydrogens) | 
|---|
| [23b547] | 61 | TestMolecule = World::getInstance().createMolecule(); | 
|---|
| [4eb4fe] | 62 | CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule"); | 
|---|
| [23b547] | 63 | Walker = World::getInstance().createAtom(); | 
|---|
| [4eb4fe] | 64 | CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); | 
|---|
| [d74077] | 65 | Walker->setType(hydrogen); | 
|---|
|  | 66 | Walker->setPosition(Vector(1., 0., 1. )); | 
|---|
| [266237] | 67 | TestMolecule->AddAtom(Walker); | 
|---|
| [23b547] | 68 | Walker = World::getInstance().createAtom(); | 
|---|
| [4eb4fe] | 69 | CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); | 
|---|
| [d74077] | 70 | Walker->setType(hydrogen); | 
|---|
|  | 71 | Walker->setPosition(Vector(0., 1., 1. )); | 
|---|
| [266237] | 72 | TestMolecule->AddAtom(Walker); | 
|---|
| [23b547] | 73 | Walker = World::getInstance().createAtom(); | 
|---|
| [4eb4fe] | 74 | CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); | 
|---|
| [d74077] | 75 | Walker->setType(hydrogen); | 
|---|
|  | 76 | Walker->setPosition(Vector(1., 1., 0. )); | 
|---|
| [266237] | 77 | TestMolecule->AddAtom(Walker); | 
|---|
| [23b547] | 78 | Walker = World::getInstance().createAtom(); | 
|---|
| [4eb4fe] | 79 | CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); | 
|---|
| [d74077] | 80 | Walker->setType(hydrogen); | 
|---|
|  | 81 | Walker->setPosition(Vector(0., 0., 0. )); | 
|---|
| [266237] | 82 | TestMolecule->AddAtom(Walker); | 
|---|
|  | 83 |  | 
|---|
|  | 84 | // check that TestMolecule was correctly constructed | 
|---|
| [ea7176] | 85 | CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 ); | 
|---|
| [266237] | 86 | }; | 
|---|
|  | 87 |  | 
|---|
|  | 88 |  | 
|---|
|  | 89 | void ListOfBondsTest::tearDown() | 
|---|
|  | 90 | { | 
|---|
|  | 91 | // remove | 
|---|
| [23b547] | 92 | World::getInstance().destroyMolecule(TestMolecule); | 
|---|
| [a1510d] | 93 | // note that all the atoms, molecules, the tafel and the elements | 
|---|
|  | 94 | // are all cleaned when the world is destroyed | 
|---|
| [23b547] | 95 | World::purgeInstance(); | 
|---|
| [e6fdbe] | 96 | logger::purgeInstance(); | 
|---|
| [266237] | 97 | }; | 
|---|
|  | 98 |  | 
|---|
| [9879f6] | 99 | /** Tests whether setup worked correctly. | 
|---|
|  | 100 | * | 
|---|
|  | 101 | */ | 
|---|
|  | 102 | void ListOfBondsTest::SetupTest() | 
|---|
|  | 103 | { | 
|---|
|  | 104 | CPPUNIT_ASSERT_EQUAL( false, TestMolecule->empty() ); | 
|---|
|  | 105 | CPPUNIT_ASSERT_EQUAL( (size_t)4, TestMolecule->size() ); | 
|---|
|  | 106 | }; | 
|---|
|  | 107 |  | 
|---|
| [266237] | 108 | /** Unit Test of molecule::AddBond() | 
|---|
|  | 109 | * | 
|---|
|  | 110 | */ | 
|---|
|  | 111 | void ListOfBondsTest::AddingBondTest() | 
|---|
|  | 112 | { | 
|---|
|  | 113 | bond *Binder = NULL; | 
|---|
| [9879f6] | 114 | molecule::iterator iter = TestMolecule->begin(); | 
|---|
|  | 115 | atom *atom1 = *iter; | 
|---|
|  | 116 | iter++; | 
|---|
|  | 117 | atom *atom2 = *iter; | 
|---|
| [266237] | 118 | CPPUNIT_ASSERT( atom1 != NULL ); | 
|---|
|  | 119 | CPPUNIT_ASSERT( atom2 != NULL ); | 
|---|
|  | 120 |  | 
|---|
|  | 121 | // add bond | 
|---|
|  | 122 | Binder = TestMolecule->AddBond(atom1, atom2, 1); | 
|---|
|  | 123 | CPPUNIT_ASSERT( Binder != NULL ); | 
|---|
| [e08c46] | 124 | CPPUNIT_ASSERT_EQUAL ( true, TestMolecule->hasBondStructure() ); | 
|---|
| [266237] | 125 |  | 
|---|
|  | 126 | // check that bond contains the two atoms | 
|---|
|  | 127 | CPPUNIT_ASSERT_EQUAL( true, Binder->Contains(atom1) ); | 
|---|
|  | 128 | CPPUNIT_ASSERT_EQUAL( true, Binder->Contains(atom2) ); | 
|---|
|  | 129 |  | 
|---|
|  | 130 | // check that bond is present in both atoms | 
|---|
| [5e2f80] | 131 | const BondList &bondlist1 = atom1->getListOfBonds(); | 
|---|
| [9d83b6] | 132 | BondList::const_iterator bonditer; | 
|---|
| [5e2f80] | 133 | bonditer = bondlist1.begin(); | 
|---|
| [9d83b6] | 134 | bond *TestBond1 = *bonditer; | 
|---|
| [266237] | 135 | CPPUNIT_ASSERT_EQUAL( TestBond1, Binder ); | 
|---|
| [5e2f80] | 136 | const BondList &bondlist2 = atom2->getListOfBonds(); | 
|---|
|  | 137 | bonditer = bondlist2.begin(); | 
|---|
| [9d83b6] | 138 | bond *TestBond2 = *bonditer; | 
|---|
| [266237] | 139 | CPPUNIT_ASSERT_EQUAL( TestBond2, Binder ); | 
|---|
|  | 140 | }; | 
|---|
|  | 141 |  | 
|---|
|  | 142 | /** Unit Test of molecule::RemoveBond() | 
|---|
|  | 143 | * | 
|---|
|  | 144 | */ | 
|---|
|  | 145 | void ListOfBondsTest::RemovingBondTest() | 
|---|
|  | 146 | { | 
|---|
|  | 147 | bond *Binder = NULL; | 
|---|
| [9879f6] | 148 | molecule::iterator iter = TestMolecule->begin(); | 
|---|
|  | 149 | atom *atom1 = *iter; | 
|---|
|  | 150 | iter++; | 
|---|
|  | 151 | atom *atom2 = *iter; | 
|---|
| [266237] | 152 | CPPUNIT_ASSERT( atom1 != NULL ); | 
|---|
|  | 153 | CPPUNIT_ASSERT( atom2 != NULL ); | 
|---|
|  | 154 |  | 
|---|
|  | 155 | // add bond | 
|---|
|  | 156 | Binder = TestMolecule->AddBond(atom1, atom2, 1); | 
|---|
|  | 157 | CPPUNIT_ASSERT( Binder != NULL ); | 
|---|
|  | 158 |  | 
|---|
|  | 159 | // remove bond | 
|---|
|  | 160 | TestMolecule->RemoveBond(Binder); | 
|---|
|  | 161 |  | 
|---|
|  | 162 | // check if removed from atoms | 
|---|
| [9d83b6] | 163 | { | 
|---|
|  | 164 | const BondList& ListOfBonds = atom1->getListOfBonds(); | 
|---|
|  | 165 | CPPUNIT_ASSERT_EQUAL( (size_t) 0, ListOfBonds.size() ); | 
|---|
|  | 166 | } | 
|---|
|  | 167 | { | 
|---|
|  | 168 | const BondList& ListOfBonds = atom2->getListOfBonds(); | 
|---|
|  | 169 | CPPUNIT_ASSERT_EQUAL( (size_t) 0, ListOfBonds.size() ); | 
|---|
|  | 170 | } | 
|---|
| [266237] | 171 |  | 
|---|
|  | 172 | // check if removed from molecule | 
|---|
| [e08c46] | 173 | CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() ); | 
|---|
| [266237] | 174 | }; | 
|---|
|  | 175 |  | 
|---|
|  | 176 | /** Unit Test of molecule::RemoveBonds() | 
|---|
|  | 177 | * | 
|---|
|  | 178 | */ | 
|---|
|  | 179 | void ListOfBondsTest::RemovingBondsTest() | 
|---|
|  | 180 | { | 
|---|
|  | 181 | bond *Binder = NULL; | 
|---|
| [9879f6] | 182 | molecule::iterator iter = TestMolecule->begin(); | 
|---|
|  | 183 | atom *atom1 = *iter; | 
|---|
|  | 184 | iter++; | 
|---|
|  | 185 | atom *atom2 = *iter; | 
|---|
|  | 186 | iter++; | 
|---|
|  | 187 | atom *atom3 = *iter; | 
|---|
| [266237] | 188 | CPPUNIT_ASSERT( atom1 != NULL ); | 
|---|
|  | 189 | CPPUNIT_ASSERT( atom2 != NULL ); | 
|---|
|  | 190 | CPPUNIT_ASSERT( atom3 != NULL ); | 
|---|
|  | 191 |  | 
|---|
|  | 192 | // add bond | 
|---|
|  | 193 | Binder = TestMolecule->AddBond(atom1, atom2, 1); | 
|---|
|  | 194 | CPPUNIT_ASSERT( Binder != NULL ); | 
|---|
|  | 195 | Binder = TestMolecule->AddBond(atom1, atom3, 1); | 
|---|
|  | 196 | CPPUNIT_ASSERT( Binder != NULL ); | 
|---|
|  | 197 | Binder = TestMolecule->AddBond(atom2, atom3, 1); | 
|---|
|  | 198 | CPPUNIT_ASSERT( Binder != NULL ); | 
|---|
|  | 199 |  | 
|---|
|  | 200 | // check that all are present | 
|---|
| [9d83b6] | 201 | { | 
|---|
|  | 202 | const BondList& ListOfBonds = atom1->getListOfBonds(); | 
|---|
|  | 203 | CPPUNIT_ASSERT_EQUAL( (size_t) 2, ListOfBonds.size() ); | 
|---|
|  | 204 | } | 
|---|
|  | 205 | { | 
|---|
|  | 206 | const BondList& ListOfBonds = atom2->getListOfBonds(); | 
|---|
|  | 207 | CPPUNIT_ASSERT_EQUAL( (size_t) 2, ListOfBonds.size() ); | 
|---|
|  | 208 | } | 
|---|
|  | 209 | { | 
|---|
|  | 210 | const BondList& ListOfBonds = atom3->getListOfBonds(); | 
|---|
|  | 211 | CPPUNIT_ASSERT_EQUAL( (size_t) 2, ListOfBonds.size() ); | 
|---|
|  | 212 | } | 
|---|
| [266237] | 213 |  | 
|---|
|  | 214 | // remove bond | 
|---|
|  | 215 | TestMolecule->RemoveBonds(atom1); | 
|---|
|  | 216 |  | 
|---|
|  | 217 | // check if removed from atoms | 
|---|
| [9d83b6] | 218 | { | 
|---|
|  | 219 | const BondList& ListOfBonds = atom1->getListOfBonds(); | 
|---|
|  | 220 | CPPUNIT_ASSERT_EQUAL( (size_t) 0, ListOfBonds.size() ); | 
|---|
|  | 221 | } | 
|---|
|  | 222 | { | 
|---|
|  | 223 | const BondList& ListOfBonds = atom2->getListOfBonds(); | 
|---|
|  | 224 | CPPUNIT_ASSERT_EQUAL( (size_t) 1, ListOfBonds.size() ); | 
|---|
|  | 225 | } | 
|---|
|  | 226 | { | 
|---|
|  | 227 | const BondList& ListOfBonds = atom3->getListOfBonds(); | 
|---|
|  | 228 | CPPUNIT_ASSERT_EQUAL( (size_t) 1, ListOfBonds.size() ); | 
|---|
|  | 229 | } | 
|---|
| [266237] | 230 |  | 
|---|
|  | 231 | // check if removed from molecule | 
|---|
| [e08c46] | 232 | CPPUNIT_ASSERT_EQUAL( true, TestMolecule->hasBondStructure() ); | 
|---|
| [458c31] | 233 | CPPUNIT_ASSERT_EQUAL( (int)1, TestMolecule->getBondCount() ); | 
|---|
| [266237] | 234 | }; | 
|---|
|  | 235 |  | 
|---|
|  | 236 | /** Unit Test of delete(bond *) | 
|---|
|  | 237 | * | 
|---|
|  | 238 | */ | 
|---|
|  | 239 | void ListOfBondsTest::DeleteBondTest() | 
|---|
|  | 240 | { | 
|---|
|  | 241 | bond *Binder = NULL; | 
|---|
| [9879f6] | 242 | molecule::iterator iter = TestMolecule->begin(); | 
|---|
|  | 243 | atom *atom1 = *iter; | 
|---|
|  | 244 | iter++; | 
|---|
|  | 245 | atom *atom2 = *iter; | 
|---|
| [266237] | 246 | CPPUNIT_ASSERT( atom1 != NULL ); | 
|---|
|  | 247 | CPPUNIT_ASSERT( atom2 != NULL ); | 
|---|
|  | 248 |  | 
|---|
|  | 249 | // add bond | 
|---|
|  | 250 | Binder = TestMolecule->AddBond(atom1, atom2, 1); | 
|---|
|  | 251 | CPPUNIT_ASSERT( Binder != NULL ); | 
|---|
|  | 252 |  | 
|---|
|  | 253 | // remove bond | 
|---|
|  | 254 | delete(Binder); | 
|---|
|  | 255 |  | 
|---|
|  | 256 | // check if removed from atoms | 
|---|
| [9d83b6] | 257 | { | 
|---|
|  | 258 | const BondList& ListOfBonds = atom1->getListOfBonds(); | 
|---|
|  | 259 | CPPUNIT_ASSERT_EQUAL( (size_t) 0, ListOfBonds.size() ); | 
|---|
|  | 260 | } | 
|---|
|  | 261 | { | 
|---|
|  | 262 | const BondList& ListOfBonds = atom2->getListOfBonds(); | 
|---|
|  | 263 | CPPUNIT_ASSERT_EQUAL( (size_t) 0, ListOfBonds.size() ); | 
|---|
|  | 264 | } | 
|---|
| [266237] | 265 |  | 
|---|
|  | 266 | // check if removed from molecule | 
|---|
| [e08c46] | 267 | CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() ); | 
|---|
| [266237] | 268 | }; | 
|---|
|  | 269 |  | 
|---|
|  | 270 | /** Unit Test of molecule::RemoveAtom() | 
|---|
|  | 271 | * | 
|---|
|  | 272 | */ | 
|---|
|  | 273 | void ListOfBondsTest::RemoveAtomTest() | 
|---|
|  | 274 | { | 
|---|
|  | 275 | bond *Binder = NULL; | 
|---|
| [9879f6] | 276 | molecule::iterator iter = TestMolecule->begin(); | 
|---|
|  | 277 | atom *atom1 = *iter; | 
|---|
|  | 278 | iter++; | 
|---|
|  | 279 | atom *atom2 = *iter; | 
|---|
| [266237] | 280 | CPPUNIT_ASSERT( atom1 != NULL ); | 
|---|
|  | 281 | CPPUNIT_ASSERT( atom2 != NULL ); | 
|---|
|  | 282 |  | 
|---|
|  | 283 | // add bond | 
|---|
|  | 284 | Binder = TestMolecule->AddBond(atom1, atom2, 1); | 
|---|
|  | 285 | CPPUNIT_ASSERT( Binder != NULL ); | 
|---|
|  | 286 |  | 
|---|
|  | 287 | // remove atom2 | 
|---|
|  | 288 | TestMolecule->RemoveAtom(atom2); | 
|---|
|  | 289 |  | 
|---|
|  | 290 | // check bond if removed from other atom | 
|---|
| [9d83b6] | 291 | { | 
|---|
|  | 292 | const BondList& ListOfBonds = atom1->getListOfBonds(); | 
|---|
|  | 293 | CPPUNIT_ASSERT_EQUAL( (size_t) 0, ListOfBonds.size() ); | 
|---|
|  | 294 | } | 
|---|
| [266237] | 295 |  | 
|---|
|  | 296 | // check if removed from molecule | 
|---|
| [e08c46] | 297 | CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() ); | 
|---|
| [266237] | 298 | }; | 
|---|
|  | 299 |  | 
|---|
|  | 300 | /** Unit Test of delete(atom *) | 
|---|
|  | 301 | * | 
|---|
|  | 302 | */ | 
|---|
|  | 303 | void ListOfBondsTest::DeleteAtomTest() | 
|---|
|  | 304 | { | 
|---|
| [f8e486] | 305 | atom *atom1 = NULL; | 
|---|
|  | 306 | atom *atom2 = NULL; | 
|---|
| [266237] | 307 | bond *Binder = NULL; | 
|---|
| [f8e486] | 308 | { | 
|---|
|  | 309 | molecule::iterator iter = TestMolecule->begin(); | 
|---|
|  | 310 | atom1 = *iter; | 
|---|
|  | 311 | iter++; | 
|---|
|  | 312 | atom2 = *iter; | 
|---|
|  | 313 | } | 
|---|
| [266237] | 314 | CPPUNIT_ASSERT( atom1 != NULL ); | 
|---|
|  | 315 | CPPUNIT_ASSERT( atom2 != NULL ); | 
|---|
|  | 316 |  | 
|---|
|  | 317 | // add bond | 
|---|
|  | 318 | Binder = TestMolecule->AddBond(atom1, atom2, 1); | 
|---|
|  | 319 | CPPUNIT_ASSERT( Binder != NULL ); | 
|---|
|  | 320 |  | 
|---|
| [8aba3c] | 321 | // access test via CurrentTime | 
|---|
| [9d83b6] | 322 | { | 
|---|
|  | 323 | const BondList& ListOfBonds = atom1->getListOfBonds(); | 
|---|
|  | 324 | CPPUNIT_ASSERT_EQUAL( (size_t) 1, ListOfBonds.size() ); | 
|---|
|  | 325 | } | 
|---|
|  | 326 | { | 
|---|
|  | 327 | const BondList& ListOfBonds = atom2->getListOfBonds(); | 
|---|
|  | 328 | CPPUNIT_ASSERT_EQUAL( (size_t) 1, ListOfBonds.size() ); | 
|---|
|  | 329 | } | 
|---|
| [6cfa36] | 330 |  | 
|---|
| [a80241] | 331 | CPPUNIT_ASSERT_EQUAL( true, TestMolecule->hasBondStructure() ); | 
|---|
|  | 332 |  | 
|---|
| [266237] | 333 | // remove atom2 | 
|---|
| [23b547] | 334 | World::getInstance().destroyAtom(atom2); | 
|---|
| [266237] | 335 |  | 
|---|
| [8aba3c] | 336 | // check bond if removed from other atom for all time steps | 
|---|
| [9d83b6] | 337 | { | 
|---|
|  | 338 | const BondList& ListOfBonds = atom1->getListOfBonds(); | 
|---|
|  | 339 | CPPUNIT_ASSERT_EQUAL( (size_t) 0, ListOfBonds.size() ); | 
|---|
|  | 340 | } | 
|---|
| [266237] | 341 |  | 
|---|
|  | 342 | // check if removed from molecule | 
|---|
| [a80241] | 343 | CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() ); | 
|---|
| [266237] | 344 | }; | 
|---|
| [8aba3c] | 345 |  | 
|---|
|  | 346 | /** Unit test on ListOfBonds at multiple time steps. | 
|---|
|  | 347 | * | 
|---|
|  | 348 | */ | 
|---|
|  | 349 | void ListOfBondsTest::MultipleTimeStepTest() | 
|---|
|  | 350 | { | 
|---|
|  | 351 | atom *atom1 = NULL; | 
|---|
|  | 352 | atom *atom2 = NULL; | 
|---|
|  | 353 | bond *Binder = NULL; | 
|---|
|  | 354 | { | 
|---|
|  | 355 | molecule::iterator iter = TestMolecule->begin(); | 
|---|
|  | 356 | atom1 = *iter; | 
|---|
|  | 357 | iter++; | 
|---|
|  | 358 | atom2 = *iter; | 
|---|
|  | 359 | } | 
|---|
|  | 360 | CPPUNIT_ASSERT( atom1 != NULL ); | 
|---|
|  | 361 | CPPUNIT_ASSERT( atom2 != NULL ); | 
|---|
|  | 362 |  | 
|---|
|  | 363 | // add bond | 
|---|
|  | 364 | WorldTime::setTime(0); | 
|---|
|  | 365 | Binder = TestMolecule->AddBond(atom1, atom2, 1); | 
|---|
|  | 366 | CPPUNIT_ASSERT( Binder != NULL ); | 
|---|
|  | 367 | WorldTime::setTime(1); | 
|---|
|  | 368 | Binder = TestMolecule->AddBond(atom1, atom2, 1); | 
|---|
|  | 369 | CPPUNIT_ASSERT( Binder != NULL ); | 
|---|
|  | 370 |  | 
|---|
|  | 371 | // access test via CurrentTime | 
|---|
|  | 372 | { // time step 0 | 
|---|
|  | 373 | WorldTime::setTime(0); | 
|---|
|  | 374 | { | 
|---|
|  | 375 | const BondList& ListOfBonds = atom1->getListOfBonds(); | 
|---|
|  | 376 | CPPUNIT_ASSERT_EQUAL( (size_t) 1, ListOfBonds.size() ); | 
|---|
|  | 377 | } | 
|---|
|  | 378 | { | 
|---|
|  | 379 | const BondList& ListOfBonds = atom2->getListOfBonds(); | 
|---|
|  | 380 | CPPUNIT_ASSERT_EQUAL( (size_t) 1, ListOfBonds.size() ); | 
|---|
|  | 381 | } | 
|---|
|  | 382 | CPPUNIT_ASSERT_EQUAL( true, TestMolecule->hasBondStructure() ); | 
|---|
|  | 383 | } | 
|---|
|  | 384 | { // time step 1 | 
|---|
|  | 385 | WorldTime::setTime(1); | 
|---|
|  | 386 | { | 
|---|
|  | 387 | const BondList& ListOfBonds = atom1->getListOfBonds(); | 
|---|
|  | 388 | CPPUNIT_ASSERT_EQUAL( (size_t) 1, ListOfBonds.size() ); | 
|---|
|  | 389 | } | 
|---|
|  | 390 | { | 
|---|
|  | 391 | const BondList& ListOfBonds = atom2->getListOfBonds(); | 
|---|
|  | 392 | CPPUNIT_ASSERT_EQUAL( (size_t) 1, ListOfBonds.size() ); | 
|---|
|  | 393 | } | 
|---|
|  | 394 | CPPUNIT_ASSERT_EQUAL( true, TestMolecule->hasBondStructure() ); | 
|---|
|  | 395 | WorldTime::setTime(0); | 
|---|
|  | 396 | } | 
|---|
|  | 397 |  | 
|---|
|  | 398 | // access time step directly. | 
|---|
|  | 399 | { // time step 0 | 
|---|
|  | 400 | { | 
|---|
|  | 401 | const BondList& ListOfBonds = atom1->getListOfBondsAtStep(0); | 
|---|
|  | 402 | CPPUNIT_ASSERT_EQUAL( (size_t) 1, ListOfBonds.size() ); | 
|---|
|  | 403 | } | 
|---|
|  | 404 | { | 
|---|
|  | 405 | const BondList& ListOfBonds = atom2->getListOfBondsAtStep(0); | 
|---|
|  | 406 | CPPUNIT_ASSERT_EQUAL( (size_t) 1, ListOfBonds.size() ); | 
|---|
|  | 407 | } | 
|---|
|  | 408 | } | 
|---|
|  | 409 | { // time step 1 | 
|---|
|  | 410 | { | 
|---|
|  | 411 | const BondList& ListOfBonds = atom1->getListOfBondsAtStep(1); | 
|---|
|  | 412 | CPPUNIT_ASSERT_EQUAL( (size_t) 1, ListOfBonds.size() ); | 
|---|
|  | 413 | } | 
|---|
|  | 414 | { | 
|---|
|  | 415 | const BondList& ListOfBonds = atom1->getListOfBondsAtStep(1); | 
|---|
|  | 416 | CPPUNIT_ASSERT_EQUAL( (size_t) 1, ListOfBonds.size() ); | 
|---|
|  | 417 | } | 
|---|
|  | 418 | } | 
|---|
|  | 419 |  | 
|---|
|  | 420 | // remove atom2 | 
|---|
|  | 421 | World::getInstance().destroyAtom(atom2); | 
|---|
|  | 422 |  | 
|---|
|  | 423 | // check bond if removed from other atom for all time steps | 
|---|
|  | 424 | { | 
|---|
|  | 425 | WorldTime::setTime(0); | 
|---|
|  | 426 | const BondList& ListOfBonds = atom1->getListOfBonds(); | 
|---|
|  | 427 | CPPUNIT_ASSERT_EQUAL( (size_t) 0, ListOfBonds.size() ); | 
|---|
|  | 428 | CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() ); | 
|---|
|  | 429 | } | 
|---|
|  | 430 | { | 
|---|
|  | 431 | WorldTime::setTime(1); | 
|---|
|  | 432 | const BondList& ListOfBonds = atom1->getListOfBonds(); | 
|---|
|  | 433 | CPPUNIT_ASSERT_EQUAL( (size_t) 0, ListOfBonds.size() ); | 
|---|
|  | 434 | CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() ); | 
|---|
|  | 435 | WorldTime::setTime(0); | 
|---|
|  | 436 | } | 
|---|
|  | 437 |  | 
|---|
|  | 438 | } | 
|---|