Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/unittests/AnalysisCorrelationToPointUnitTest.cpp

    r3d9df5 rc78d44  
    1818
    1919#include "atom.hpp"
    20 #include "boundary.hpp"
    2120#include "element.hpp"
    2221#include "molecule.hpp"
    2322#include "linkedcell.hpp"
    2423#include "periodentafel.hpp"
    25 #include "tesselation.hpp"
     24#include "World.hpp"
     25
     26#ifdef HAVE_TESTRUNNER
     27#include "UnitTestMain.hpp"
     28#endif /*HAVE_TESTRUNNER*/
    2629
    2730/********************************************** Test classes **************************************/
     
    3740  TestList = NULL;
    3841  TestMolecule = NULL;
    39   hydrogen = NULL;
    40   tafel = NULL;
    4142  pointmap = NULL;
    4243  binmap = NULL;
    4344  point = NULL;
    4445
    45   // construct element
    46   hydrogen = new element;
    47   hydrogen->Z = 1;
    48   strcpy(hydrogen->name, "hydrogen");
    49   strcpy(hydrogen->symbol, "H");
    50 
    51 
    52   // construct periodentafel
    53   tafel = new periodentafel;
    54   tafel->AddElement(hydrogen);
    55 
     46  // construct element list
     47  std::vector<element *> elements;
     48  hydrogen = World::getInstance().getPeriode()->FindElement(1);
     49  CPPUNIT_ASSERT(hydrogen != NULL && "hydrogen element not found");
     50  elements.push_back(hydrogen);
    5651  // construct molecule (tetraeder of hydrogens)
    57   TestMolecule = new molecule(tafel);
    58   Walker = new atom();
     52  TestMolecule = World::getInstance().createMolecule();
     53  Walker = World::getInstance().createAtom();
    5954  Walker->type = hydrogen;
    60   Walker->node->Init(1., 0., 1. );
     55  *Walker->node = Vector(1., 0., 1. );
    6156  TestMolecule->AddAtom(Walker);
    62   Walker = new atom();
     57  Walker = World::getInstance().createAtom();
    6358  Walker->type = hydrogen;
    64   Walker->node->Init(0., 1., 1. );
     59  *Walker->node = Vector(0., 1., 1. );
    6560  TestMolecule->AddAtom(Walker);
    66   Walker = new atom();
     61  Walker = World::getInstance().createAtom();
    6762  Walker->type = hydrogen;
    68   Walker->node->Init(1., 1., 0. );
     63  *Walker->node = Vector(1., 1., 0. );
    6964  TestMolecule->AddAtom(Walker);
    70   Walker = new atom();
     65  Walker = World::getInstance().createAtom();
    7166  Walker->type = hydrogen;
    72   Walker->node->Init(0., 0., 0. );
     67  *Walker->node = Vector(0., 0., 0. );
    7368  TestMolecule->AddAtom(Walker);
    7469
    7570  // check that TestMolecule was correctly constructed
    76   CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
     71  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 );
    7772
    78   TestList = new MoleculeListClass;
     73  TestList = World::getInstance().getMolecules();
     74  TestList->insert(TestMolecule);
    7975  TestMolecule->ActiveFlag = true;
    80   TestList->insert(TestMolecule);
    8176
    8277  // init point
     
    8479
    8580  // init maps
    86   pointmap = CorrelationToPoint( (MoleculeListClass * const)TestList, (const element * const)hydrogen, (const Vector *)point );
     81  pointmap = CorrelationToPoint( (MoleculeListClass * const)TestList, elements, (const Vector *)point );
    8782  binmap = NULL;
    8883
     
    9792    delete(binmap);
    9893
    99   // remove
    100   delete(TestList);
    101   // note that all the atoms are cleaned by TestMolecule
    10294  delete(point);
    103   delete(tafel);
    104   // note that element is cleaned by periodentafel
     95  World::purgeInstance();
     96  logger::purgeInstance();
    10597};
    10698
     
    140132
    141133};
    142 
    143 /********************************************** Main routine **************************************/
    144 
    145 int main(int argc, char **argv)
    146 {
    147   // Get the top level suite from the registry
    148   CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
    149 
    150   // Adds the test to the list of test to run
    151   CppUnit::TextUi::TestRunner runner;
    152   runner.addTest( suite );
    153 
    154   // Change the default outputter to a compiler error format outputter
    155   runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
    156                                                        std::cerr ) );
    157   // Run the tests.
    158   bool wasSucessful = runner.run();
    159 
    160   // Return error code 1 if the one of test failed.
    161   return wasSucessful ? 0 : 1;
    162 };
Note: See TracChangeset for help on using the changeset viewer.