Ignore:
Timestamp:
May 18, 2010, 3:20:52 PM (16 years ago)
Author:
Frederik Heber <heber@…>
Children:
108d38
Parents:
7a6fd9
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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/unittests/analysisbondsunittest.cpp

    r7a6fd9 r06f141  
    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);
Note: See TracChangeset for help on using the changeset viewer.