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