Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/unittests/listofbondsunittest.cpp

    re6fdbe rcbc5fb  
    1616#include "listofbondsunittest.hpp"
    1717
     18#include "World.hpp"
    1819#include "atom.hpp"
    1920#include "bond.hpp"
     
    2122#include "molecule.hpp"
    2223#include "periodentafel.hpp"
    23 #include "World.hpp"
    24 
    25 #ifdef HAVE_TESTRUNNER
    26 #include "UnitTestMain.hpp"
    27 #endif /*HAVE_TESTRUNNER*/
    2824
    2925/********************************************** Test classes **************************************/
     
    5046
    5147  // construct periodentafel
    52   tafel = new periodentafel;
     48  tafel = World::get()->getPeriode();
    5349  tafel->AddElement(hydrogen);
    5450
    5551  // construct molecule (tetraeder of hydrogens)
    56   TestMolecule = new molecule(tafel);
    57   Walker = new atom();
     52  TestMolecule = World::get()->createMolecule();
     53  Walker = World::get()->createAtom();
    5854  Walker->type = hydrogen;
    5955  Walker->node->Init(1., 0., 1. );
    6056  TestMolecule->AddAtom(Walker);
    61   Walker = new atom();
     57  Walker = World::get()->createAtom();
    6258  Walker->type = hydrogen;
    6359  Walker->node->Init(0., 1., 1. );
    6460  TestMolecule->AddAtom(Walker);
    65   Walker = new atom();
     61  Walker = World::get()->createAtom();
    6662  Walker->type = hydrogen;
    6763  Walker->node->Init(1., 1., 0. );
    6864  TestMolecule->AddAtom(Walker);
    69   Walker = new atom();
     65  Walker = World::get()->createAtom();
    7066  Walker->type = hydrogen;
    7167  Walker->node->Init(0., 0., 0. );
     
    8177{
    8278  // remove
    83   delete(TestMolecule);
     79  World::get()->destroyMolecule(TestMolecule);
    8480  // note that all the atoms are cleaned by TestMolecule
    85   delete(tafel);
    86   // note that element is cleaned by periodentafel
    8781  World::destroy();
    88   MemoryUsageObserver::purgeInstance();
    89   logger::purgeInstance();
    9082};
    9183
     
    250242
    251243  // remove atom2
    252   delete(atom2);
     244  World::get()->destroyAtom(atom2);
    253245
    254246  // check bond if removed from other atom
     
    258250  CPPUNIT_ASSERT_EQUAL( TestMolecule->first->next, TestMolecule->last );
    259251};
     252
     253/********************************************** Main routine **************************************/
     254
     255int 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.