Changeset 57f5cf for src/unittests


Ignore:
Timestamp:
Mar 4, 2010, 9:49:45 AM (16 years ago)
Author:
Saskia Metzler <metzler@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
ab4b55
Parents:
6bc51d (diff), 88d586 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge commit 'till/StructureRefactoring' into StateAndFormatParser

Conflicts:

molecuilder/src/Makefile.am
molecuilder/src/unittests/Makefile.am

SOURCE and HEADER are both one long line and thus could not be merged automatically.

Location:
src/unittests
Files:
4 added
9 edited

Legend:

Unmodified
Added
Removed
  • src/unittests/AnalysisCorrelationToPointUnitTest.cpp

    r6bc51d r57f5cf  
    1717#include "AnalysisCorrelationToPointUnitTest.hpp"
    1818
     19#include "World.hpp"
    1920#include "atom.hpp"
    2021#include "boundary.hpp"
     
    5657
    5758  // construct periodentafel
    58   tafel = new periodentafel;
     59  tafel = World::get()->getPeriode();
    5960  tafel->AddElement(hydrogen);
    6061
    6162  // construct molecule (tetraeder of hydrogens)
    62   TestMolecule = new molecule(tafel);
    63   Walker = new atom();
     63  TestMolecule = World::get()->createMolecule();
     64  Walker = World::get()->createAtom();
    6465  Walker->type = hydrogen;
    6566  Walker->node->Init(1., 0., 1. );
    6667  TestMolecule->AddAtom(Walker);
    67   Walker = new atom();
     68  Walker = World::get()->createAtom();
    6869  Walker->type = hydrogen;
    6970  Walker->node->Init(0., 1., 1. );
    7071  TestMolecule->AddAtom(Walker);
    71   Walker = new atom();
     72  Walker = World::get()->createAtom();
    7273  Walker->type = hydrogen;
    7374  Walker->node->Init(1., 1., 0. );
    7475  TestMolecule->AddAtom(Walker);
    75   Walker = new atom();
     76  Walker = World::get()->createAtom();
    7677  Walker->type = hydrogen;
    7778  Walker->node->Init(0., 0., 0. );
     
    8182  CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
    8283
    83   TestList = new MoleculeListClass;
     84  TestList = World::get()->getMolecules();
    8485  TestMolecule->ActiveFlag = true;
    8586  TestList->insert(TestMolecule);
     
    102103    delete(binmap);
    103104
    104   // remove
    105   delete(TestList);
    106   // note that all the atoms are cleaned by TestMolecule
    107105  delete(point);
    108   delete(tafel);
    109   // note that element is cleaned by periodentafel
    110106  World::destroy();
    111107  MemoryUsageObserver::purgeInstance();
  • src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp

    r6bc51d r57f5cf  
    1717#include "AnalysisCorrelationToSurfaceUnitTest.hpp"
    1818
     19#include "World.hpp"
    1920#include "atom.hpp"
    2021#include "boundary.hpp"
     
    6061
    6162  // construct periodentafel
    62   tafel = new periodentafel;
     63  tafel = World::get()->getPeriode();
    6364  tafel->AddElement(hydrogen);
    6465  tafel->AddElement(carbon);
    6566
    6667  // construct molecule (tetraeder of hydrogens) base
    67   TestMolecule = new molecule(tafel);
    68   Walker = new atom();
     68  TestMolecule = World::get()->createMolecule();
     69  Walker = World::get()->createAtom();
    6970  Walker->type = hydrogen;
    7071  Walker->node->Init(1., 0., 1. );
    7172  TestMolecule->AddAtom(Walker);
    72   Walker = new atom();
     73  Walker = World::get()->createAtom();
    7374  Walker->type = hydrogen;
    7475  Walker->node->Init(0., 1., 1. );
    7576  TestMolecule->AddAtom(Walker);
    76   Walker = new atom();
     77  Walker = World::get()->createAtom();
    7778  Walker->type = hydrogen;
    7879  Walker->node->Init(1., 1., 0. );
    7980  TestMolecule->AddAtom(Walker);
    80   Walker = new atom();
     81  Walker = World::get()->createAtom();
    8182  Walker->type = hydrogen;
    8283  Walker->node->Init(0., 0., 0. );
     
    8687  CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
    8788
    88   TestList = new MoleculeListClass;
     89  TestList = World::get()->getMolecules();
    8990  TestMolecule->ActiveFlag = true;
    9091  TestList->insert(TestMolecule);
     
    99100
    100101  // add outer atoms
    101   Walker = new atom();
     102  Walker = World::get()->createAtom();
    102103  Walker->type = carbon;
    103104  Walker->node->Init(4., 0., 4. );
    104105  TestMolecule->AddAtom(Walker);
    105   Walker = new atom();
     106  Walker = World::get()->createAtom();
    106107  Walker->type = carbon;
    107108  Walker->node->Init(0., 4., 4. );
    108109  TestMolecule->AddAtom(Walker);
    109   Walker = new atom();
     110  Walker = World::get()->createAtom();
    110111  Walker->type = carbon;
    111112  Walker->node->Init(4., 4., 0. );
    112113  TestMolecule->AddAtom(Walker);
    113114  // add inner atoms
    114   Walker = new atom();
     115  Walker = World::get()->createAtom();
    115116  Walker->type = carbon;
    116117  Walker->node->Init(0.5, 0.5, 0.5 );
     
    131132    delete(binmap);
    132133
    133   // remove
    134   delete(TestList);
    135134  delete(Surface);
    136135  // note that all the atoms are cleaned by TestMolecule
    137136  delete(LC);
    138   delete(tafel);
    139   // note that element is cleaned by periodentafel
    140137  World::destroy();
    141138  MemoryUsageObserver::purgeInstance();
  • src/unittests/AnalysisPairCorrelationUnitTest.cpp

    r6bc51d r57f5cf  
    1717#include "AnalysisPairCorrelationUnitTest.hpp"
    1818
     19#include "World.hpp"
    1920#include "atom.hpp"
    2021#include "boundary.hpp"
     
    5556
    5657  // construct periodentafel
    57   tafel = new periodentafel;
     58  tafel = World::get()->getPeriode();
    5859  tafel->AddElement(hydrogen);
    5960
    6061  // construct molecule (tetraeder of hydrogens)
    61   TestMolecule = new molecule(tafel);
    62   Walker = new atom();
     62  TestMolecule = World::get()->createMolecule();
     63  Walker = World::get()->createAtom();
    6364  Walker->type = hydrogen;
    6465  Walker->node->Init(1., 0., 1. );
    6566  TestMolecule->AddAtom(Walker);
    66   Walker = new atom();
     67  Walker = World::get()->createAtom();
    6768  Walker->type = hydrogen;
    6869  Walker->node->Init(0., 1., 1. );
    6970  TestMolecule->AddAtom(Walker);
    70   Walker = new atom();
     71  Walker = World::get()->createAtom();
    7172  Walker->type = hydrogen;
    7273  Walker->node->Init(1., 1., 0. );
    7374  TestMolecule->AddAtom(Walker);
    74   Walker = new atom();
     75  Walker = World::get()->createAtom();
    7576  Walker->type = hydrogen;
    7677  Walker->node->Init(0., 0., 0. );
     
    8081  CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
    8182
    82   TestList = new MoleculeListClass;
     83  TestList = World::get()->getMolecules();
    8384  TestMolecule->ActiveFlag = true;
    8485  TestList->insert(TestMolecule);
     
    9899    delete(binmap);
    99100
    100   // remove
    101   delete(TestList);
    102101  // note that all the atoms are cleaned by TestMolecule
    103   delete(tafel);
    104   // note that element is cleaned by periodentafel
    105102  World::destroy();
    106103  MemoryUsageObserver::purgeInstance();
  • src/unittests/DescriptorUnittest.cpp

    r6bc51d r57f5cf  
    2727CPPUNIT_TEST_SUITE_REGISTRATION( DescriptorUnittest );
    2828
    29 // some stubs
    30 class AtomStub : public atom {
    31 public:
    32   AtomStub(int _id) :
    33   atom(),
    34   id(_id)
    35   {}
    36 
    37   virtual int getId(){
    38     return id;
    39   }
    40 
    41 private:
    42   int id;
    43 };
    44 
    45 
    4629// set up and tear down
    4730void DescriptorUnittest::setUp(){
    4831  World::get();
    4932  for(int i=0;i<ATOM_COUNT;++i){
    50     atoms[i]= new AtomStub(i);
     33    atoms[i]= World::get()->createAtom();
     34    atomIds[i] = atoms[i]->getId();
    5135  }
    5236}
    5337void DescriptorUnittest::tearDown(){
    5438  World::destroy();
    55   for(int i=0;i<ATOM_COUNT;++i){
    56     delete atoms[i];
    57   }
    5839}
    5940
    6041// some helper functions
    61 bool hasAll(std::vector<atom*> atoms,int min, int max, std::set<int> excluded = std::set<int>()){
    62   for(int i=min;i<max;++i){
    63     if(!excluded.count(i)){
     42bool hasAll(std::vector<atom*> atoms,int ids[ATOM_COUNT], std::set<int> excluded = std::set<int>()){
     43  for(int i=0;i<ATOM_COUNT;++i){
     44    int id = ids[i];
     45    if(!excluded.count(id)){
    6446      std::vector<atom*>::iterator iter;
    6547      bool res=false;
    6648      for(iter=atoms.begin();iter!=atoms.end();++iter){
    67         res |= (*iter)->getId() == i;
     49        res |= (*iter)->getId() == id;
    6850      }
    6951      if(!res) {
    70         cout << "Atom " << i << " missing in returned list" << endl;
     52        cout << "Atom " << id << " missing in returned list" << endl;
    7153        return false;
    7254      }
     
    9173void DescriptorUnittest::AtomBaseSetsTest(){
    9274  std::vector<atom*> allAtoms = World::get()->getAllAtoms(AllAtoms());
    93   CPPUNIT_ASSERT_EQUAL( true , hasAll(allAtoms,0,ATOM_COUNT));
     75  CPPUNIT_ASSERT_EQUAL( true , hasAll(allAtoms,atomIds));
    9476  CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicates(allAtoms));
    9577
     
    10082  // test Atoms from boundaries and middle of the set
    10183  atom* testAtom;
    102   testAtom = World::get()->getAtom(AtomById(0));
    103   CPPUNIT_ASSERT_EQUAL( 0, testAtom->getId());
    104   testAtom = World::get()->getAtom(AtomById(ATOM_COUNT/2));
    105   CPPUNIT_ASSERT_EQUAL( ATOM_COUNT/2, testAtom->getId());
    106   testAtom = World::get()->getAtom(AtomById(ATOM_COUNT-1));
    107   CPPUNIT_ASSERT_EQUAL( ATOM_COUNT-1, testAtom->getId());
     84  testAtom = World::get()->getAtom(AtomById(atomIds[0]));
     85  CPPUNIT_ASSERT(testAtom);
     86  CPPUNIT_ASSERT_EQUAL( atomIds[0], testAtom->getId());
     87  testAtom = World::get()->getAtom(AtomById(atomIds[ATOM_COUNT/2]));
     88  CPPUNIT_ASSERT(testAtom);
     89  CPPUNIT_ASSERT_EQUAL( atomIds[ATOM_COUNT/2], testAtom->getId());
     90  testAtom = World::get()->getAtom(AtomById(atomIds[ATOM_COUNT-1]));
     91  CPPUNIT_ASSERT(testAtom);
     92  CPPUNIT_ASSERT_EQUAL( atomIds[ATOM_COUNT-1], testAtom->getId());
    10893
     94  // find some ID that has not been created
     95  int outsideId =-1;
     96  bool res = false;
     97  while(!res) {
     98    ++outsideId;
     99    res = true;
     100    for(int i = 0; i < ATOM_COUNT; ++i){
     101      res &= atomIds[i]!=outsideId;
     102    }
     103  }
    109104  // test from outside of set
    110   testAtom = World::get()->getAtom(AtomById(ATOM_COUNT));
     105  testAtom = World::get()->getAtom(AtomById(outsideId));
    111106  CPPUNIT_ASSERT(!testAtom);
    112107}
     
    115110  {
    116111    std::vector<atom*> testAtoms = World::get()->getAllAtoms(AllAtoms()||NoAtoms());
    117     CPPUNIT_ASSERT_EQUAL( true , hasAll(testAtoms,0,ATOM_COUNT));
     112    CPPUNIT_ASSERT_EQUAL( true , hasAll(testAtoms,atomIds));
    118113    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicates(testAtoms));
    119114  }
     
    121116  {
    122117    std::vector<atom*> testAtoms = World::get()->getAllAtoms(NoAtoms()||AllAtoms());
    123     CPPUNIT_ASSERT_EQUAL( true , hasAll(testAtoms,0,ATOM_COUNT));
     118    CPPUNIT_ASSERT_EQUAL( true , hasAll(testAtoms,atomIds));
    124119    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicates(testAtoms));
    125120  }
     
    142137  {
    143138    std::vector<atom*> testAtoms = World::get()->getAllAtoms(!NoAtoms());
    144     CPPUNIT_ASSERT_EQUAL( true , hasAll(testAtoms,0,ATOM_COUNT));
     139    CPPUNIT_ASSERT_EQUAL( true , hasAll(testAtoms,atomIds));
    145140    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicates(testAtoms));
    146141  }
     
    148143  // exclude and include some atoms
    149144  {
    150     std::vector<atom*> testAtoms = World::get()->getAllAtoms(AllAtoms()&&(!AtomById(ATOM_COUNT/2)));
     145    std::vector<atom*> testAtoms = World::get()->getAllAtoms(AllAtoms()&&(!AtomById(atomIds[ATOM_COUNT/2])));
    151146    std::set<int> excluded;
    152     excluded.insert(ATOM_COUNT/2);
    153     CPPUNIT_ASSERT_EQUAL( true , hasAll(testAtoms,0,ATOM_COUNT,excluded));
     147    excluded.insert(atomIds[ATOM_COUNT/2]);
     148    CPPUNIT_ASSERT_EQUAL( true , hasAll(testAtoms,atomIds,excluded));
    154149    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicates(testAtoms));
    155150    CPPUNIT_ASSERT_EQUAL( (size_t)(ATOM_COUNT-1), testAtoms.size());
     
    157152
    158153  {
    159     std::vector<atom*> testAtoms = World::get()->getAllAtoms(NoAtoms()||(AtomById(ATOM_COUNT/2)));
     154    std::vector<atom*> testAtoms = World::get()->getAllAtoms(NoAtoms()||(AtomById(atomIds[ATOM_COUNT/2])));
    160155    CPPUNIT_ASSERT_EQUAL( (size_t)1, testAtoms.size());
    161     CPPUNIT_ASSERT_EQUAL( ATOM_COUNT/2, testAtoms[0]->getId());
     156    CPPUNIT_ASSERT_EQUAL( atomIds[ATOM_COUNT/2], testAtoms[0]->getId());
    162157  }
    163158}
  • src/unittests/DescriptorUnittest.hpp

    r6bc51d r57f5cf  
    3333private:
    3434  atom *atoms [ATOM_COUNT];
     35  int atomIds [ATOM_COUNT];
    3536};
    3637
  • src/unittests/Makefile.am

    r6bc51d r57f5cf  
    3131  DescriptorUnittest \
    3232  MatrixUnitTest \
     33  manipulateAtomsTest \
     34  atomsCalculationTest \
    3335  ${MENUTESTS} 
    3436   
     
    6163  tesselation_insideoutsideunittest.cpp \
    6264  vectorunittest.cpp \
    63   ActionSequenceTest.cpp \
    6465  ObserverTest.cpp \
    6566  CacheableTest.cpp \
    6667  DescriptorUnittest.cpp \
    67   MatrixUnitTest.cpp   
     68  MatrixUnitTest.cpp \
     69  manipulateAtomsTest.cpp \
     70  atomsCalculationTest.cpp \
     71  ActionSequenceTest.cpp
    6872
    6973TESTHEADERS = \
     
    145149MatrixUnitTest_LDADD = ${ALLLIBS}
    146150
     151manipulateAtomsTest_SOURCES = UnitTestMain.cpp manipulateAtomsTest.cpp manipulateAtomsTest.hpp
     152manipulateAtomsTest_LDADD = ${ALLLIBS}
     153
     154atomsCalculationTest_SOURCES = UnitTestMain.cpp atomsCalculationTest.cpp atomsCalculationTest.hpp
     155atomsCalculationTest_LDADD = ${ALLLIBS}
     156
    147157TestRunner_SOURCES = TestRunnerMain.cpp $(TESTSOURCES) $(TESTHEADERS)
    148158TestRunner_LDADD = ${ALLLIBS}
  • src/unittests/analysisbondsunittest.cpp

    r6bc51d r57f5cf  
    1616#include <cstring>
    1717
     18#include "World.hpp"
    1819#include "analysis_bonds.hpp"
    1920#include "analysisbondsunittest.hpp"
     
    6061
    6162  // construct periodentafel
    62   tafel = new periodentafel;
     63  tafel = World::get()->getPeriode();
    6364  tafel->AddElement(hydrogen);
    6465  tafel->AddElement(carbon);
    6566
    6667  // construct molecule (tetraeder of hydrogens)
    67   TestMolecule = new molecule(tafel);
    68   Walker = new atom();
     68  TestMolecule = World::get()->createMolecule();
     69  Walker = World::get()->createAtom();
    6970  Walker->type = hydrogen;
    7071  Walker->node->Init(1.5, 0., 1.5 );
    7172  TestMolecule->AddAtom(Walker);
    72   Walker = new atom();
     73  Walker = World::get()->createAtom();
    7374  Walker->type = hydrogen;
    7475  Walker->node->Init(0., 1.5, 1.5 );
    7576  TestMolecule->AddAtom(Walker);
    76   Walker = new atom();
     77  Walker = World::get()->createAtom();
    7778  Walker->type = hydrogen;
    7879  Walker->node->Init(1.5, 1.5, 0. );
    7980  TestMolecule->AddAtom(Walker);
    80   Walker = new atom();
     81  Walker = World::get()->createAtom();
    8182  Walker->type = hydrogen;
    8283  Walker->node->Init(0., 0., 0. );
    8384  TestMolecule->AddAtom(Walker);
    84   Walker = new atom();
     85  Walker = World::get()->createAtom();
    8586  Walker->type = carbon;
    8687  Walker->node->Init(0.5, 0.5, 0.5 );
     
    116117
    117118  // remove molecule
    118   delete(TestMolecule);
     119  World::get()->destroyMolecule(TestMolecule);
    119120  // note that all the atoms are cleaned by TestMolecule
    120   delete(tafel);
    121   // note that element is cleaned by periodentafel
     121  World::destroy();
    122122};
    123123
  • src/unittests/bondgraphunittest.cpp

    r6bc51d r57f5cf  
    1616#include <cstring>
    1717
     18#include "World.hpp"
    1819#include "atom.hpp"
    1920#include "bond.hpp"
     
    5657
    5758  // construct periodentafel
    58   tafel = new periodentafel;
     59  tafel = World::get()->getPeriode();
    5960  tafel->AddElement(hydrogen);
    6061  tafel->AddElement(carbon);
    6162
    6263  // construct molecule (tetraeder of hydrogens)
    63   TestMolecule = new molecule(tafel);
    64   Walker = new atom();
     64  TestMolecule = World::get()->createMolecule();
     65  Walker = World::get()->createAtom();
    6566  Walker->type = hydrogen;
    6667  Walker->node->Init(1., 0., 1. );
    6768  TestMolecule->AddAtom(Walker);
    68   Walker = new atom();
     69  Walker = World::get()->createAtom();
    6970  Walker->type = hydrogen;
    7071  Walker->node->Init(0., 1., 1. );
    7172  TestMolecule->AddAtom(Walker);
    72   Walker = new atom();
     73  Walker = World::get()->createAtom();
    7374  Walker->type = hydrogen;
    7475  Walker->node->Init(1., 1., 0. );
    7576  TestMolecule->AddAtom(Walker);
    76   Walker = new atom();
     77  Walker = World::get()->createAtom();
    7778  Walker->type = hydrogen;
    7879  Walker->node->Init(0., 0., 0. );
     
    101102
    102103  // remove molecule
    103   delete(TestMolecule);
    104   // note that all the atoms are cleaned by TestMolecule
    105   delete(tafel);
    106   // note that element is cleaned by periodentafel
     104  World::get()->destroyMolecule(TestMolecule);
     105  // note that all the atoms, molecules, the tafel and the elements
     106  // are all cleaned when the world is destroyed
    107107  World::destroy();
    108108  MemoryUsageObserver::purgeInstance();
  • src/unittests/listofbondsunittest.cpp

    r6bc51d r57f5cf  
    1616#include "listofbondsunittest.hpp"
    1717
     18#include "World.hpp"
    1819#include "atom.hpp"
    1920#include "bond.hpp"
     
    5051
    5152  // construct periodentafel
    52   tafel = new periodentafel;
     53  tafel = World::get()->getPeriode();
    5354  tafel->AddElement(hydrogen);
    5455
    5556  // construct molecule (tetraeder of hydrogens)
    56   TestMolecule = new molecule(tafel);
    57   Walker = new atom();
     57  TestMolecule = World::get()->createMolecule();
     58  Walker = World::get()->createAtom();
    5859  Walker->type = hydrogen;
    5960  Walker->node->Init(1., 0., 1. );
    6061  TestMolecule->AddAtom(Walker);
    61   Walker = new atom();
     62  Walker = World::get()->createAtom();
    6263  Walker->type = hydrogen;
    6364  Walker->node->Init(0., 1., 1. );
    6465  TestMolecule->AddAtom(Walker);
    65   Walker = new atom();
     66  Walker = World::get()->createAtom();
    6667  Walker->type = hydrogen;
    6768  Walker->node->Init(1., 1., 0. );
    6869  TestMolecule->AddAtom(Walker);
    69   Walker = new atom();
     70  Walker = World::get()->createAtom();
    7071  Walker->type = hydrogen;
    7172  Walker->node->Init(0., 0., 0. );
     
    8182{
    8283  // remove
    83   delete(TestMolecule);
    84   // note that all the atoms are cleaned by TestMolecule
    85   delete(tafel);
    86   // note that element is cleaned by periodentafel
     84  World::get()->destroyMolecule(TestMolecule);
     85  // note that all the atoms, molecules, the tafel and the elements
     86  // are all cleaned when the world is destroyed
    8787  World::destroy();
    8888  MemoryUsageObserver::purgeInstance();
     
    250250
    251251  // remove atom2
    252   delete(atom2);
     252  World::get()->destroyAtom(atom2);
    253253
    254254  // check bond if removed from other atom
Note: See TracChangeset for help on using the changeset viewer.