Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/unittests/listofbondsunittest.cpp

    rcbc5fb re6fdbe  
    1616#include "listofbondsunittest.hpp"
    1717
    18 #include "World.hpp"
    1918#include "atom.hpp"
    2019#include "bond.hpp"
     
    2221#include "molecule.hpp"
    2322#include "periodentafel.hpp"
     23#include "World.hpp"
     24
     25#ifdef HAVE_TESTRUNNER
     26#include "UnitTestMain.hpp"
     27#endif /*HAVE_TESTRUNNER*/
    2428
    2529/********************************************** Test classes **************************************/
     
    4650
    4751  // construct periodentafel
    48   tafel = World::get()->getPeriode();
     52  tafel = new periodentafel;
    4953  tafel->AddElement(hydrogen);
    5054
    5155  // construct molecule (tetraeder of hydrogens)
    52   TestMolecule = World::get()->createMolecule();
    53   Walker = World::get()->createAtom();
     56  TestMolecule = new molecule(tafel);
     57  Walker = new atom();
    5458  Walker->type = hydrogen;
    5559  Walker->node->Init(1., 0., 1. );
    5660  TestMolecule->AddAtom(Walker);
    57   Walker = World::get()->createAtom();
     61  Walker = new atom();
    5862  Walker->type = hydrogen;
    5963  Walker->node->Init(0., 1., 1. );
    6064  TestMolecule->AddAtom(Walker);
    61   Walker = World::get()->createAtom();
     65  Walker = new atom();
    6266  Walker->type = hydrogen;
    6367  Walker->node->Init(1., 1., 0. );
    6468  TestMolecule->AddAtom(Walker);
    65   Walker = World::get()->createAtom();
     69  Walker = new atom();
    6670  Walker->type = hydrogen;
    6771  Walker->node->Init(0., 0., 0. );
     
    7781{
    7882  // remove
    79   World::get()->destroyMolecule(TestMolecule);
     83  delete(TestMolecule);
    8084  // note that all the atoms are cleaned by TestMolecule
     85  delete(tafel);
     86  // note that element is cleaned by periodentafel
    8187  World::destroy();
     88  MemoryUsageObserver::purgeInstance();
     89  logger::purgeInstance();
    8290};
    8391
     
    242250
    243251  // remove atom2
    244   World::get()->destroyAtom(atom2);
     252  delete(atom2);
    245253
    246254  // check bond if removed from other atom
     
    250258  CPPUNIT_ASSERT_EQUAL( TestMolecule->first->next, TestMolecule->last );
    251259};
    252 
    253 /********************************************** Main routine **************************************/
    254 
    255 int main(int argc, char **argv)
    256 {
    257   // Get the top level suite from the registry
    258   CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
    259 
    260   // Adds the test to the list of test to run
    261   CppUnit::TextUi::TestRunner runner;
    262   runner.addTest( suite );
    263 
    264   // Change the default outputter to a compiler error format outputter
    265   runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
    266                                                        std::cerr ) );
    267   // Run the tests.
    268   bool wasSucessful = runner.run();
    269 
    270   // Return error code 1 if the one of test failed.
    271   return wasSucessful ? 0 : 1;
    272 };
Note: See TracChangeset for help on using the changeset viewer.