Changeset 4eb4fe for src/unittests


Ignore:
Timestamp:
May 18, 2010, 3:20:52 PM (16 years ago)
Author:
Frederik Heber <heber@…>
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, Candidate_v1.7.0, Candidate_v1.7.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:
673c7f, b0e9c9
Parents:
5079a0
Message:

"-e <db path>" not necessary anymore.

Removed necessity of specifying path to databases (this was one check of molecuilder/test/testsuite.at which cannot be fulfilled anymore with boost::program_options)
For this to work a great number of small changes have been necessary:

class periodentafel:

  • all .db files merged into const char * arrays in elements_db.cpp
  • periodentafel rewritten:
  • FindElement(), AskElement() and EnterElement return element * const instead of const element * (i.e. the contents of the pointer is const (the element) not the pointer itself which is very vexatious (i.e. FindElement() yields const element * which can subsequently not be used for RemoveElement(), ...)
  • parsedElems is not needed anymore. Instead we operate on map elements directly
  • new unittest periodentafelTest which is made friend of periodentafel to be able to access private loading functions directly

A number of unit tests had to be changed (all that create elements during setUp() which is now unnecessary)

Some of the analysis_bonds function's signatures were changed in the process:

Finally, the respective tests are removed from molecuilder/tests/testsuite.at.

Location:
src/unittests
Files:
2 added
18 edited

Legend:

Unmodified
Added
Removed
  • src/unittests/AnalysisCorrelationToPointUnitTest.cpp

    r5079a0 r4eb4fe  
    1717#include "AnalysisCorrelationToPointUnitTest.hpp"
    1818
    19 #include "World.hpp"
    2019#include "atom.hpp"
    21 #include "boundary.hpp"
    2220#include "element.hpp"
    2321#include "molecule.hpp"
    2422#include "linkedcell.hpp"
    2523#include "periodentafel.hpp"
    26 #include "tesselation.hpp"
    2724#include "World.hpp"
    2825
     
    4340  TestList = NULL;
    4441  TestMolecule = NULL;
    45   hydrogen = NULL;
    46   tafel = NULL;
    4742  pointmap = NULL;
    4843  binmap = NULL;
    4944  point = NULL;
    5045
    51   // construct element
    52   hydrogen = new element;
    53   hydrogen->Z = 1;
    54   strcpy(hydrogen->name, "hydrogen");
    55   strcpy(hydrogen->symbol, "H");
    56 
    57 
    58   // construct periodentafel
    59   tafel = World::getInstance().getPeriode();
    60   tafel->AddElement(hydrogen);
    61 
    6246  // construct molecule (tetraeder of hydrogens)
     47  hydrogen = World::getInstance().getPeriode()->FindElement(1);
     48  CPPUNIT_ASSERT(hydrogen != NULL && "hydrogen element not found");
    6349  TestMolecule = World::getInstance().createMolecule();
    6450  Walker = World::getInstance().createAtom();
  • src/unittests/AnalysisCorrelationToPointUnitTest.hpp

    r5079a0 r4eb4fe  
    1212
    1313class element;
    14 class LinkedCell;
    1514class molecule;
    1615class MoleculeListClass;
    17 class periodentafel;
    18 class Tesselation;
    1916class Vector;
    2017
     
    4037      MoleculeListClass *TestList;
    4138      molecule *TestMolecule;
    42       element *hydrogen;
    43       periodentafel *tafel;
     39      const element *hydrogen;
    4440
    4541      CorrelationToPointMap *pointmap;
  • src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp

    r5079a0 r4eb4fe  
    1717#include "AnalysisCorrelationToSurfaceUnitTest.hpp"
    1818
    19 #include "World.hpp"
    2019#include "atom.hpp"
    2120#include "boundary.hpp"
     
    4746  TestList = NULL;
    4847  TestSurfaceMolecule = NULL;
    49   hydrogen = NULL;
    50   tafel = NULL;
    5148  surfacemap = NULL;
    5249  binmap = NULL;
     
    5451  LC = NULL;
    5552
    56   // construct element
    57   hydrogen = new element;
    58   hydrogen->Z = 1;
    59   strcpy(hydrogen->name, "hydrogen");
    60   strcpy(hydrogen->symbol, "H");
    61   carbon = new element;
    62   carbon->Z = 6;
    63   strcpy(carbon->name, "carbon");
    64   strcpy(carbon->symbol, "C");
    65 
    66   // construct periodentafel
    67   tafel = World::getInstance().getPeriode();
    68   tafel->AddElement(hydrogen);
    69   tafel->AddElement(carbon);
    70 
    7153  // construct molecule (tetraeder of hydrogens) base
     54  hydrogen = World::getInstance().getPeriode()->FindElement(1);
    7255  TestSurfaceMolecule = World::getInstance().createMolecule();
    7356  Walker = World::getInstance().createAtom();
     
    10285
    10386  // add outer atoms
     87  carbon = World::getInstance().getPeriode()->FindElement(6);
    10488  TestSurfaceMolecule = World::getInstance().createMolecule();
    10589  Walker = World::getInstance().createAtom();
  • src/unittests/AnalysisCorrelationToSurfaceUnitTest.hpp

    r5079a0 r4eb4fe  
    4545      MoleculeListClass *TestList;
    4646      molecule *TestSurfaceMolecule;
    47       element *hydrogen;
    48       element *carbon;
    49       periodentafel *tafel;
     47      const element *hydrogen;
     48      const element *carbon;
    5049
    5150      CorrelationToSurfaceMap *surfacemap;
  • src/unittests/AnalysisPairCorrelationUnitTest.cpp

    r5079a0 r4eb4fe  
    4444  TestList = NULL;
    4545  TestMolecule = NULL;
    46   hydrogen = NULL;
    47   tafel = NULL;
    4846  correlationmap = NULL;
    4947  binmap = NULL;
    5048
    51   // construct element
    52   hydrogen = new element;
    53   hydrogen->Z = 1;
    54   strcpy(hydrogen->name, "hydrogen");
    55   strcpy(hydrogen->symbol, "H");
    56 
    57   // construct periodentafel
    58   tafel = World::getInstance().getPeriode();
    59   tafel->AddElement(hydrogen);
    60 
    6149  // construct molecule (tetraeder of hydrogens)
     50  hydrogen = World::getInstance().getPeriode()->FindElement(1);
    6251  TestMolecule = World::getInstance().createMolecule();
    6352  Walker = World::getInstance().createAtom();
  • src/unittests/AnalysisPairCorrelationUnitTest.hpp

    r5079a0 r4eb4fe  
    1212
    1313class element;
    14 class LinkedCell;
    1514class molecule;
    1615class MoleculeListClass;
    17 class periodentafel;
    18 class Tesselation;
    1916class Vector;
    2017
     
    4037      MoleculeListClass *TestList;
    4138      molecule *TestMolecule;
    42       element *hydrogen;
    43       periodentafel *tafel;
     39      const element *hydrogen;
    4440
    4541      PairCorrelationMap *correlationmap;
  • src/unittests/CountBondsUnitTest.cpp

    r5079a0 r4eb4fe  
    1616#include <stdio.h>
    1717#include <cstring>
     18
     19#include "Helpers/Assert.hpp"
    1820
    1921#include "analysis_bonds.hpp"
     
    4042{
    4143  atom *Walker = NULL;
    42   BG = NULL;
    43   filename = NULL;
    44 
    45   // init private all pointers to zero
    46   molecules = NULL;
    47   TestMolecule1 = NULL;
    48   TestMolecule2 = NULL;
    49   hydrogen = NULL;
    50   oxygen = NULL;
    51   tafel = NULL;
    5244
    5345  // construct element
    54   hydrogen = new element;
    55   hydrogen->Z = 1;
    56   hydrogen->CovalentRadius = 0.23;
    57   strcpy(hydrogen->name, "hydrogen");
    58   strcpy(hydrogen->symbol, "H");
    59   oxygen = new element;
    60   oxygen->Z = 8;
    61   oxygen->CovalentRadius = 0.68;
    62   strcpy(oxygen->name, "oxygen");
    63   strcpy(oxygen->symbol, "O");
    64 
    65   // construct periodentafel
    66   tafel = World::getInstance().getPeriode();
    67   tafel->AddElement(hydrogen);
    68   tafel->AddElement(oxygen);
     46  hydrogen = World::getInstance().getPeriode()->FindElement(1);
     47  oxygen = World::getInstance().getPeriode()->FindElement(8);
     48  CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen");
     49  CPPUNIT_ASSERT(oxygen != NULL && "could not find element oxygen");
    6950
    7051  // construct molecule (water molecule)
    7152  TestMolecule1 = World::getInstance().createMolecule();
    72   Walker = World::getInstance().createAtom();
     53  CPPUNIT_ASSERT(TestMolecule1 != NULL && "could not create first molecule");
     54  Walker = World::getInstance().createAtom();
     55  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    7356  Walker->type = hydrogen;
    7457  *Walker->node = Vector(-0.2418, 0.9350, 0. );
    7558  TestMolecule1->AddAtom(Walker);
    7659  Walker = World::getInstance().createAtom();
     60  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    7761  Walker->type = hydrogen;
    7862  *Walker->node = Vector(0.9658, 0., 0. );
    7963  TestMolecule1->AddAtom(Walker);
    8064  Walker = World::getInstance().createAtom();
     65  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    8166  Walker->type = oxygen;
    8267  *Walker->node = Vector(0., 0., 0. );
     
    8469
    8570  TestMolecule2 = World::getInstance().createMolecule();
    86   Walker = World::getInstance().createAtom();
     71  CPPUNIT_ASSERT(TestMolecule2 != NULL && "could not create second molecule");
     72  Walker = World::getInstance().createAtom();
     73  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    8774  Walker->type = hydrogen;
    8875  *Walker->node = Vector(-0.2418, 0.9350, 0. );
    8976  TestMolecule2->AddAtom(Walker);
    9077  Walker = World::getInstance().createAtom();
     78  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    9179  Walker->type = hydrogen;
    9280  *Walker->node = Vector(0.9658, 0., 0. );
    9381  TestMolecule2->AddAtom(Walker);
    9482  Walker = World::getInstance().createAtom();
     83  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    9584  Walker->type = oxygen;
    9685  *Walker->node = Vector(0., 0., 0. );
     
    9887
    9988  molecules = World::getInstance().getMolecules();
     89  CPPUNIT_ASSERT(molecules != NULL && "could not obtain list of molecules");
    10090  molecules->insert(TestMolecule1);
    10191  molecules->insert(TestMolecule2);
     
    111101  // create a small file with table
    112102  BG = new BondGraph(true);
     103  CPPUNIT_ASSERT(BG != NULL && "could not create BondGraph");
    113104
    114105  // construct bond graphs
     
    158149{
    159150  double *mirror = new double[3];
     151  CPPUNIT_ASSERT(mirror != NULL && "could not create array of doubles");
    160152  for (int i=0;i<3;i++)
    161153    mirror[i] = -1.;
  • src/unittests/CountBondsUnitTest.hpp

    r5079a0 r4eb4fe  
    3939      molecule *TestMolecule1;
    4040      molecule *TestMolecule2;
    41       element *hydrogen;
    42       element *oxygen;
    43       periodentafel *tafel;
     41      const element *hydrogen;
     42      const element *oxygen;
    4443
    4544      BondGraph *BG;
  • src/unittests/LinkedCellUnitTest.cpp

    r5079a0 r4eb4fe  
    3838  atom *Walker = NULL;
    3939
    40   // init private all pointers to zero
    41   TestMolecule = NULL;
    42   hydrogen = NULL;
    43   tafel = NULL;
    44 
    4540  // construct element
    46   hydrogen = new element;
    47   hydrogen->Z = 1;
    48   hydrogen->CovalentRadius = 0.23;
    49   strcpy(hydrogen->name, "hydrogen");
    50   strcpy(hydrogen->symbol, "H");
    51 
    52   // construct periodentafel
    53   tafel = World::getInstance().getPeriode();
    54   tafel->AddElement(hydrogen);
     41  hydrogen = World::getInstance().getPeriode()->FindElement(1);
     42  CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen");
    5543
    5644  // construct molecule (water molecule)
    5745  TestMolecule = World::getInstance().createMolecule();
     46  CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule");
    5847  for (double x=0.5;x<3;x+=1.)
    5948    for (double y=0.5;y<3;y+=1.)
    6049      for (double z=0.5;z<3;z+=1.) {
    6150        Walker = World::getInstance().createAtom();
     51        CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    6252        Walker->type = hydrogen;
    6353        *Walker->node = Vector(x, y, z );
     
    6757  // construct linked cell
    6858  LC = new LinkedCell (TestMolecule, 1.);
     59  CPPUNIT_ASSERT(LC != NULL && "could not create LinkedCell");
    6960
    7061  // check that TestMolecule was correctly constructed
  • src/unittests/LinkedCellUnitTest.hpp

    r5079a0 r4eb4fe  
    4848
    4949      molecule *TestMolecule;
    50       element *hydrogen;
    51       periodentafel *tafel;
     50      const element *hydrogen;
    5251      LinkedCell *LC;
    5352};
  • src/unittests/Makefile.am

    r5079a0 r4eb4fe  
    3333  MemoryAllocatorUnitTest \
    3434  MoleculeDescriptorTest \
    35   PlaneUnittest \
    3635  ObserverTest \
    3736  ParserUnitTest \
     37  periodentafelTest \
     38  PlaneUnittest \
    3839  SingletonTest \
    3940  StackClassUnitTest \
     
    7576  memoryusageobserverunittest.cpp \
    7677  MoleculeDescriptorTest.cpp \
    77   PlaneUnittest.cpp \
    7878  ObserverTest.cpp \
    7979  ParserUnitTest.cpp \
     80  periodentafelTest.cpp \
     81  PlaneUnittest.cpp \
    8082  SingletonTest.cpp \
    8183  stackclassunittest.cpp \
     
    109111  memoryusageobserverunittest.hpp \
    110112  MoleculeDescriptorTest.hpp \
     113  periodentafelTest.hpp \
    111114  PlaneUnittest.hpp \
    112115  ObserverTest.hpp \
     
    194197ParserUnitTest_LDADD = ${ALLLIBS}
    195198
     199periodentafelTest_SOURCES = UnitTestMain.cpp periodentafelTest.cpp periodentafelTest.hpp
     200periodentafelTest_LDADD = ${ALLLIBS}
     201
    196202PlaneUnittest_SOURCES = UnitTestMain.cpp PlaneUnittest.cpp PlaneUnittest.hpp
    197203PlaneUnittest_LDADD = ${ALLLIBS}
  • src/unittests/ParserUnitTest.cpp

    r5079a0 r4eb4fe  
    3131
    3232void ParserUnitTest::setUp() {
    33   element* oxygen = new element();
    34   oxygen->symbol[0] = 'O';
    35   oxygen->Z = 8;
    36   World::getInstance().getPeriode()->AddElement(oxygen);
    37 
    38   element* hydrogen = new element();
    39   hydrogen->symbol[0] = 'H';
    40   hydrogen->Z = 1;
    41   World::getInstance().getPeriode()->AddElement(hydrogen);
     33  World::getInstance();
    4234}
    4335
  • src/unittests/analysisbondsunittest.cpp

    r5079a0 r4eb4fe  
    4040  atom *Walker = NULL;
    4141
    42   // init private all pointers to zero
    43   TestMolecule = NULL;
    44   hydrogen = NULL;
    45   tafel = NULL;
    46 
    47   // construct element
    48   hydrogen = new element;
    49   hydrogen->Z = 1;
    50   hydrogen->Valence = 1;
    51   hydrogen->NoValenceOrbitals = 1;
    52   strcpy(hydrogen->name, "hydrogen");
    53   strcpy(hydrogen->symbol, "H");
    54   carbon = new element;
    55   carbon->Z = 2;
    56   carbon->Valence = 4;
    57   carbon->NoValenceOrbitals = 4;
    58   strcpy(carbon->name, "carbon");
    59   strcpy(carbon->symbol, "C");
    60 
    61 
    62   // construct periodentafel
    63   tafel = World::getInstance().getPeriode();
    64   tafel->AddElement(hydrogen);
    65   tafel->AddElement(carbon);
     42  // get elements
     43  hydrogen = World::getInstance().getPeriode()->FindElement(1);
     44  carbon = World::getInstance().getPeriode()->FindElement(6);
     45  CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen");
     46  CPPUNIT_ASSERT(carbon != NULL && "could not find element carbon");
    6647
    6748  // construct molecule (tetraeder of hydrogens)
    6849  TestMolecule = World::getInstance().createMolecule();
     50  CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule");
    6951  Walker = World::getInstance().createAtom();
     52  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    7053  Walker->type = hydrogen;
    7154  *Walker->node = Vector(1.5, 0., 1.5 );
    7255  TestMolecule->AddAtom(Walker);
    7356  Walker = World::getInstance().createAtom();
     57  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    7458  Walker->type = hydrogen;
    7559  *Walker->node = Vector(0., 1.5, 1.5 );
    7660  TestMolecule->AddAtom(Walker);
    7761  Walker = World::getInstance().createAtom();
     62  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    7863  Walker->type = hydrogen;
    7964  *Walker->node = Vector(1.5, 1.5, 0. );
    8065  TestMolecule->AddAtom(Walker);
    8166  Walker = World::getInstance().createAtom();
     67  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    8268  Walker->type = hydrogen;
    8369  *Walker->node = Vector(0., 0., 0. );
    8470  TestMolecule->AddAtom(Walker);
    8571  Walker = World::getInstance().createAtom();
     72  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    8673  Walker->type = carbon;
    8774  *Walker->node = Vector(0.5, 0.5, 0.5 );
     
    9380  // create a small file with table
    9481  filename = new string("test.dat");
     82  CPPUNIT_ASSERT(filename != NULL && "could not create string");
    9583  ofstream test(filename->c_str());
    96   test << ".\tH\tC\n";
    97   test << "H\t1.\t1.2\n";
    98   test << "C\t1.2\t1.5\n";
     84  test << ".\tH\tHe\tLi\tBe\tB\tC\n";
     85  test << "H\t1.\t1.\t1.\t1.\t1.\t1.2\n";
     86  test << "He\t1.\t1.\t1.\t1.\t1.\t1.\n";
     87  test << "Li\t1.\t1.\t1.\t1.\t1.\t1.\n";
     88  test << "Be\t1.\t1.\t1.\t1.\t1.\t1.\n";
     89  test << "B\t1.\t1.\t1.\t1.\t1.\t1.\n";
     90  test << "C\t1.2\t1.\t1.\t1.\t1.\t1.5\n";
    9991  test.close();
    10092  BG = new BondGraph(true);
     93  CPPUNIT_ASSERT(BG != NULL && "could not create BondGraph");
    10194
    10295  CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) );
    10396  CPPUNIT_ASSERT_EQUAL( 1., BG->GetBondLength(0,0) );
    104   CPPUNIT_ASSERT_EQUAL( 1.2, BG->GetBondLength(0,1) );
    105   CPPUNIT_ASSERT_EQUAL( 1.5, BG->GetBondLength(1,1) );
     97  CPPUNIT_ASSERT_EQUAL( 1.2, BG->GetBondLength(0,5) );
     98  CPPUNIT_ASSERT_EQUAL( 1.5, BG->GetBondLength(5,5) );
    10699
    107100  BG->ConstructBondGraph(TestMolecule);
  • src/unittests/analysisbondsunittest.hpp

    r5079a0 r4eb4fe  
    3434
    3535      molecule *TestMolecule;
    36       element *hydrogen;
    37       element *carbon;
    38       periodentafel *tafel;
     36      const element *hydrogen;
     37      const element *carbon;
    3938
    4039      BondGraph *BG;
  • src/unittests/bondgraphunittest.cpp

    r5079a0 r4eb4fe  
    1515#include <stdio.h>
    1616#include <cstring>
     17
     18#include "Helpers/Assert.hpp"
    1719
    1820#include "World.hpp"
     
    4143  atom *Walker = NULL;
    4244
    43   // init private all pointers to zero
    44   TestMolecule = NULL;
    45   hydrogen = NULL;
    46   tafel = NULL;
    47 
    4845  // construct element
    49   hydrogen = new element;
    50   hydrogen->Z = 1;
    51   hydrogen->CovalentRadius = 0.23;
    52   hydrogen->VanDerWaalsRadius = 1.09;
    53   strcpy(hydrogen->name, "hydrogen");
    54   strcpy(hydrogen->symbol, "H");
    55   carbon = new element;
    56   carbon->Z = 2;
    57   carbon->CovalentRadius = 0.68;
    58   carbon->VanDerWaalsRadius = 1.7;
    59   strcpy(carbon->name, "carbon");
    60   strcpy(carbon->symbol, "C");
    61 
    62 
    63   // construct periodentafel
    64   tafel = World::getInstance().getPeriode();
    65   tafel->AddElement(hydrogen);
    66   tafel->AddElement(carbon);
     46  hydrogen = World::getInstance().getPeriode()->FindElement(1);
     47  carbon = World::getInstance().getPeriode()->FindElement(6);
     48  CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen");
     49  CPPUNIT_ASSERT(carbon != NULL && "could not find element carbon");
    6750
    6851  // construct molecule (tetraeder of hydrogens)
    6952  TestMolecule = World::getInstance().createMolecule();
     53  CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule");
    7054  Walker = World::getInstance().createAtom();
     55  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    7156  Walker->type = carbon;
    7257  *Walker->node = Vector(1., 0., 1. );
     
    7459
    7560  Walker = World::getInstance().createAtom();
     61  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    7662  Walker->type = carbon;
    7763  *Walker->node = Vector(0., 1., 1. );
     
    7965
    8066  Walker = World::getInstance().createAtom();
     67  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    8168  Walker->type = carbon;
    8269  *Walker->node = Vector(1., 1., 0. );
     
    8471
    8572  Walker = World::getInstance().createAtom();
     73  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    8674  Walker->type = carbon;
    8775  *Walker->node = Vector(0., 0., 0. );
     
    9381  // create a small file with table
    9482  dummyname = new string("dummy.dat");
     83  CPPUNIT_ASSERT(dummyname != NULL && "could not create string");
    9584  filename = new string("test.dat");
     85  CPPUNIT_ASSERT(filename != NULL && "could not create string");
    9686  ofstream test(filename->c_str());
    97   test << ".\tH\tC\n";
    98   test << "H\t1.\t1.2\n";
    99   test << "C\t1.2\t1.5\n";
     87  test << ".\tH\tHe\tLi\tBe\tB\tC\n";
     88  test << "H\t1.\t1.\t1.\t1.\t1.\t1.2\n";
     89  test << "He\t1.\t1.\t1.\t1.\t1.\t1.\n";
     90  test << "Li\t1.\t1.\t1.\t1.\t1.\t1.\n";
     91  test << "Be\t1.\t1.\t1.\t1.\t1.\t1.\n";
     92  test << "B\t1.\t1.\t1.\t1.\t1.\t1.\n";
     93  test << "C\t1.2\t1.\t1.\t1.\t1.\t1.5\n";
    10094  test.close();
    10195  BG = new BondGraph(true);
     96  CPPUNIT_ASSERT(BG != NULL && "could not create BondGraph");
    10297};
    10398
     
    126121  CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) );
    127122  CPPUNIT_ASSERT_EQUAL( 1., BG->GetBondLength(0,0) );
    128   CPPUNIT_ASSERT_EQUAL( 1.2, BG->GetBondLength(0,1) );
    129   CPPUNIT_ASSERT_EQUAL( 1.5, BG->GetBondLength(1,1) );
     123  CPPUNIT_ASSERT_EQUAL( 1.2, BG->GetBondLength(0,5) );
     124  CPPUNIT_ASSERT_EQUAL( 1.5, BG->GetBondLength(5,5) );
    130125};
    131126
  • src/unittests/bondgraphunittest.hpp

    r5079a0 r4eb4fe  
    3737
    3838      molecule *TestMolecule;
    39       element *hydrogen;
    40       element *carbon;
    41       periodentafel *tafel;
     39      const element *hydrogen;
     40      const element *carbon;
    4241
    4342      BondGraph *BG;
  • src/unittests/listofbondsunittest.cpp

    r5079a0 r4eb4fe  
    3838  atom *Walker = NULL;
    3939
    40   // init private all pointers to zero
    41   TestMolecule = NULL;
    42   hydrogen = NULL;
    43   tafel = NULL;
    44 
    4540  // 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 = World::getInstance().getPeriode();
    54   tafel->AddElement(hydrogen);
     41  hydrogen = World::getInstance().getPeriode()->FindElement(1);
     42  CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen");
    5543
    5644  // construct molecule (tetraeder of hydrogens)
    5745  TestMolecule = World::getInstance().createMolecule();
    58   Walker = World::getInstance().createAtom();
     46  CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule");
     47  Walker = World::getInstance().createAtom();
     48  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    5949  Walker->type = hydrogen;
    6050  *Walker->node = Vector(1., 0., 1. );
    6151  TestMolecule->AddAtom(Walker);
    6252  Walker = World::getInstance().createAtom();
     53  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    6354  Walker->type = hydrogen;
    6455  *Walker->node = Vector(0., 1., 1. );
    6556  TestMolecule->AddAtom(Walker);
    6657  Walker = World::getInstance().createAtom();
     58  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    6759  Walker->type = hydrogen;
    6860  *Walker->node = Vector(1., 1., 0. );
    6961  TestMolecule->AddAtom(Walker);
    7062  Walker = World::getInstance().createAtom();
     63  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    7164  Walker->type = hydrogen;
    7265  *Walker->node = Vector(0., 0., 0. );
     
    7568  // check that TestMolecule was correctly constructed
    7669  CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
    77 
    7870};
    7971
  • src/unittests/listofbondsunittest.hpp

    r5079a0 r4eb4fe  
    4141
    4242      molecule *TestMolecule;
    43       element *hydrogen;
    44       periodentafel *tafel;
     43      const element *hydrogen;
    4544};
    4645
Note: See TracChangeset for help on using the changeset viewer.