| 1 | /*
 | 
|---|
| 2 |  * Project: MoleCuilder
 | 
|---|
| 3 |  * Description: creates and alters molecular systems
 | 
|---|
| 4 |  * Copyright (C)  2010-2012 University of Bonn. All rights reserved.
 | 
|---|
| 5 |  * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
 | 
|---|
| 6 |  */
 | 
|---|
| 7 | 
 | 
|---|
| 8 | /*
 | 
|---|
| 9 |  * ListOfBondsUnitTest.cpp
 | 
|---|
| 10 |  *
 | 
|---|
| 11 |  *  Created on: 18 Oct 2009
 | 
|---|
| 12 |  *      Author: user
 | 
|---|
| 13 |  */
 | 
|---|
| 14 | 
 | 
|---|
| 15 | // include config.h
 | 
|---|
| 16 | #ifdef HAVE_CONFIG_H
 | 
|---|
| 17 | #include <config.h>
 | 
|---|
| 18 | #endif
 | 
|---|
| 19 | 
 | 
|---|
| 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 <cstring>
 | 
|---|
| 27 | 
 | 
|---|
| 28 | #include "CodePatterns/Log.hpp"
 | 
|---|
| 29 | #include "World.hpp"
 | 
|---|
| 30 | #include "Atom/atom.hpp"
 | 
|---|
| 31 | #include "Bond/bond.hpp"
 | 
|---|
| 32 | #include "Element/element.hpp"
 | 
|---|
| 33 | #include "molecule.hpp"
 | 
|---|
| 34 | #include "Element/periodentafel.hpp"
 | 
|---|
| 35 | #include "World.hpp"
 | 
|---|
| 36 | #include "WorldTime.hpp"
 | 
|---|
| 37 | 
 | 
|---|
| 38 | #include "ListOfBondsUnitTest.hpp"
 | 
|---|
| 39 | 
 | 
|---|
| 40 | #ifdef HAVE_TESTRUNNER
 | 
|---|
| 41 | #include "UnitTestMain.hpp"
 | 
|---|
| 42 | #endif /*HAVE_TESTRUNNER*/
 | 
|---|
| 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 | 
 | 
|---|
| 54 |   WorldTime::setTime(0);
 | 
|---|
| 55 | 
 | 
|---|
| 56 |   // construct element
 | 
|---|
| 57 |   hydrogen = World::getInstance().getPeriode()->FindElement(1);
 | 
|---|
| 58 |   CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen");
 | 
|---|
| 59 | 
 | 
|---|
| 60 |   // construct molecule (tetraeder of hydrogens)
 | 
|---|
| 61 |   TestMolecule = World::getInstance().createMolecule();
 | 
|---|
| 62 |   CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule");
 | 
|---|
| 63 |   Walker = World::getInstance().createAtom();
 | 
|---|
| 64 |   CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
 | 
|---|
| 65 |   Walker->setType(hydrogen);
 | 
|---|
| 66 |   Walker->setPosition(Vector(1., 0., 1. ));
 | 
|---|
| 67 |   TestMolecule->AddAtom(Walker);
 | 
|---|
| 68 |   Walker = World::getInstance().createAtom();
 | 
|---|
| 69 |   CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
 | 
|---|
| 70 |   Walker->setType(hydrogen);
 | 
|---|
| 71 |   Walker->setPosition(Vector(0., 1., 1. ));
 | 
|---|
| 72 |   TestMolecule->AddAtom(Walker);
 | 
|---|
| 73 |   Walker = World::getInstance().createAtom();
 | 
|---|
| 74 |   CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
 | 
|---|
| 75 |   Walker->setType(hydrogen);
 | 
|---|
| 76 |   Walker->setPosition(Vector(1., 1., 0. ));
 | 
|---|
| 77 |   TestMolecule->AddAtom(Walker);
 | 
|---|
| 78 |   Walker = World::getInstance().createAtom();
 | 
|---|
| 79 |   CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
 | 
|---|
| 80 |   Walker->setType(hydrogen);
 | 
|---|
| 81 |   Walker->setPosition(Vector(0., 0., 0. ));
 | 
|---|
| 82 |   TestMolecule->AddAtom(Walker);
 | 
|---|
| 83 | 
 | 
|---|
| 84 |   // check that TestMolecule was correctly constructed
 | 
|---|
| 85 |   CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 );
 | 
|---|
| 86 | };
 | 
|---|
| 87 | 
 | 
|---|
| 88 | 
 | 
|---|
| 89 | void ListOfBondsTest::tearDown()
 | 
|---|
| 90 | {
 | 
|---|
| 91 |   // remove
 | 
|---|
| 92 |   World::getInstance().destroyMolecule(TestMolecule);
 | 
|---|
| 93 |   // note that all the atoms, molecules, the tafel and the elements
 | 
|---|
| 94 |   // are all cleaned when the world is destroyed
 | 
|---|
| 95 |   World::purgeInstance();
 | 
|---|
| 96 |   logger::purgeInstance();
 | 
|---|
| 97 | };
 | 
|---|
| 98 | 
 | 
|---|
| 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 | 
 | 
|---|
| 108 | /** Unit Test of molecule::AddBond()
 | 
|---|
| 109 |  *
 | 
|---|
| 110 |  */
 | 
|---|
| 111 | void ListOfBondsTest::AddingBondTest()
 | 
|---|
| 112 | {
 | 
|---|
| 113 |   bond *Binder = NULL;
 | 
|---|
| 114 |   molecule::iterator iter = TestMolecule->begin();
 | 
|---|
| 115 |   atom *atom1 = *iter;
 | 
|---|
| 116 |   iter++;
 | 
|---|
| 117 |   atom *atom2 = *iter;
 | 
|---|
| 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 );
 | 
|---|
| 124 |   CPPUNIT_ASSERT_EQUAL ( true, TestMolecule->hasBondStructure() );
 | 
|---|
| 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
 | 
|---|
| 131 |   const BondList &bondlist1 = atom1->getListOfBonds();
 | 
|---|
| 132 |   BondList::const_iterator bonditer;
 | 
|---|
| 133 |   bonditer = bondlist1.begin();
 | 
|---|
| 134 |   bond *TestBond1 = *bonditer;
 | 
|---|
| 135 |   CPPUNIT_ASSERT_EQUAL( TestBond1, Binder );
 | 
|---|
| 136 |   const BondList &bondlist2 = atom2->getListOfBonds();
 | 
|---|
| 137 |   bonditer = bondlist2.begin();
 | 
|---|
| 138 |   bond *TestBond2 = *bonditer;
 | 
|---|
| 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;
 | 
|---|
| 148 |   molecule::iterator iter = TestMolecule->begin();
 | 
|---|
| 149 |   atom *atom1 = *iter;
 | 
|---|
| 150 |   iter++;
 | 
|---|
| 151 |   atom *atom2 = *iter;
 | 
|---|
| 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
 | 
|---|
| 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 |   }
 | 
|---|
| 171 | 
 | 
|---|
| 172 |   // check if removed from molecule
 | 
|---|
| 173 |   CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() );
 | 
|---|
| 174 | };
 | 
|---|
| 175 | 
 | 
|---|
| 176 | /** Unit Test of molecule::RemoveBonds()
 | 
|---|
| 177 |  *
 | 
|---|
| 178 |  */
 | 
|---|
| 179 | void ListOfBondsTest::RemovingBondsTest()
 | 
|---|
| 180 | {
 | 
|---|
| 181 |   bond *Binder = NULL;
 | 
|---|
| 182 |   molecule::iterator iter = TestMolecule->begin();
 | 
|---|
| 183 |   atom *atom1 = *iter;
 | 
|---|
| 184 |   iter++;
 | 
|---|
| 185 |   atom *atom2 = *iter;
 | 
|---|
| 186 |   iter++;
 | 
|---|
| 187 |   atom *atom3 = *iter;
 | 
|---|
| 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
 | 
|---|
| 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 |   }
 | 
|---|
| 213 | 
 | 
|---|
| 214 |   // remove bond
 | 
|---|
| 215 |   TestMolecule->RemoveBonds(atom1);
 | 
|---|
| 216 | 
 | 
|---|
| 217 |   // check if removed from atoms
 | 
|---|
| 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 |   }
 | 
|---|
| 230 | 
 | 
|---|
| 231 |   // check if removed from molecule
 | 
|---|
| 232 |   CPPUNIT_ASSERT_EQUAL( true, TestMolecule->hasBondStructure() );
 | 
|---|
| 233 |   CPPUNIT_ASSERT_EQUAL( (int)1, TestMolecule->getBondCount() );
 | 
|---|
| 234 | };
 | 
|---|
| 235 | 
 | 
|---|
| 236 | /** Unit Test of delete(bond *)
 | 
|---|
| 237 |  *
 | 
|---|
| 238 |  */
 | 
|---|
| 239 | void ListOfBondsTest::DeleteBondTest()
 | 
|---|
| 240 | {
 | 
|---|
| 241 |   bond *Binder = NULL;
 | 
|---|
| 242 |   molecule::iterator iter = TestMolecule->begin();
 | 
|---|
| 243 |   atom *atom1 = *iter;
 | 
|---|
| 244 |   iter++;
 | 
|---|
| 245 |   atom *atom2 = *iter;
 | 
|---|
| 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
 | 
|---|
| 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 |   }
 | 
|---|
| 265 | 
 | 
|---|
| 266 |   // check if removed from molecule
 | 
|---|
| 267 |   CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() );
 | 
|---|
| 268 | };
 | 
|---|
| 269 | 
 | 
|---|
| 270 | /** Unit Test of molecule::RemoveAtom()
 | 
|---|
| 271 |  *
 | 
|---|
| 272 |  */
 | 
|---|
| 273 | void ListOfBondsTest::RemoveAtomTest()
 | 
|---|
| 274 | {
 | 
|---|
| 275 |   bond *Binder = NULL;
 | 
|---|
| 276 |   molecule::iterator iter = TestMolecule->begin();
 | 
|---|
| 277 |   atom *atom1 = *iter;
 | 
|---|
| 278 |   iter++;
 | 
|---|
| 279 |   atom *atom2 = *iter;
 | 
|---|
| 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
 | 
|---|
| 291 |   {
 | 
|---|
| 292 |     const BondList& ListOfBonds = atom1->getListOfBonds();
 | 
|---|
| 293 |     CPPUNIT_ASSERT_EQUAL( (size_t) 0, ListOfBonds.size() );
 | 
|---|
| 294 |   }
 | 
|---|
| 295 | 
 | 
|---|
| 296 |   // check if removed from molecule
 | 
|---|
| 297 |   CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() );
 | 
|---|
| 298 | };
 | 
|---|
| 299 | 
 | 
|---|
| 300 | /** Unit Test of delete(atom *)
 | 
|---|
| 301 |  *
 | 
|---|
| 302 |  */
 | 
|---|
| 303 | void ListOfBondsTest::DeleteAtomTest()
 | 
|---|
| 304 | {
 | 
|---|
| 305 |   atom *atom1 = NULL;
 | 
|---|
| 306 |   atom *atom2 = NULL;
 | 
|---|
| 307 |   bond *Binder = NULL;
 | 
|---|
| 308 |   {
 | 
|---|
| 309 |     molecule::iterator iter = TestMolecule->begin();
 | 
|---|
| 310 |     atom1 = *iter;
 | 
|---|
| 311 |     iter++;
 | 
|---|
| 312 |     atom2 = *iter;
 | 
|---|
| 313 |   }
 | 
|---|
| 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 | 
 | 
|---|
| 321 |   // access test via CurrentTime
 | 
|---|
| 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 |   }
 | 
|---|
| 330 | 
 | 
|---|
| 331 |   CPPUNIT_ASSERT_EQUAL( true, TestMolecule->hasBondStructure() );
 | 
|---|
| 332 | 
 | 
|---|
| 333 |   // remove atom2
 | 
|---|
| 334 |   World::getInstance().destroyAtom(atom2);
 | 
|---|
| 335 | 
 | 
|---|
| 336 |   // check bond if removed from other atom for all time steps
 | 
|---|
| 337 |   {
 | 
|---|
| 338 |     const BondList& ListOfBonds = atom1->getListOfBonds();
 | 
|---|
| 339 |     CPPUNIT_ASSERT_EQUAL( (size_t) 0, ListOfBonds.size() );
 | 
|---|
| 340 |   }
 | 
|---|
| 341 | 
 | 
|---|
| 342 |   // check if removed from molecule
 | 
|---|
| 343 |   CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() );
 | 
|---|
| 344 | };
 | 
|---|
| 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 | }
 | 
|---|