Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/unittests/bondgraphunittest.cpp

    r9a7186 re5ad5c  
    1919#include "bondgraph.hpp"
    2020#include "element.hpp"
     21#include "log.hpp"
    2122#include "molecule.hpp"
    2223#include "periodentafel.hpp"
     
    4142  hydrogen = new element;
    4243  hydrogen->Z = 1;
     44  hydrogen->CovalentRadius = 0.23;
     45  hydrogen->VanDerWaalsRadius = 1.09;
    4346  strcpy(hydrogen->name, "hydrogen");
    4447  strcpy(hydrogen->symbol, "H");
    4548  carbon = new element;
    46   carbon->Z = 1;
     49  carbon->Z = 2;
     50  carbon->CovalentRadius = 0.68;
     51  carbon->VanDerWaalsRadius = 1.7;
    4752  strcpy(carbon->name, "carbon");
    4853  strcpy(carbon->symbol, "C");
     
    5762  TestMolecule = new molecule(tafel);
    5863  Walker = new atom();
    59   Walker->type = hydrogen;
     64  Walker->type = carbon;
    6065  Walker->node->Init(1., 0., 1. );
    6166  TestMolecule->AddAtom(Walker);
    6267  Walker = new atom();
    63   Walker->type = hydrogen;
     68  Walker->type = carbon;
    6469  Walker->node->Init(0., 1., 1. );
    6570  TestMolecule->AddAtom(Walker);
    6671  Walker = new atom();
    67   Walker->type = hydrogen;
     72  Walker->type = carbon;
    6873  Walker->node->Init(1., 1., 0. );
    6974  TestMolecule->AddAtom(Walker);
    7075  Walker = new atom();
    71   Walker->type = hydrogen;
     76  Walker->type = carbon;
    7277  Walker->node->Init(0., 0., 0. );
    7378  TestMolecule->AddAtom(Walker);
     
    7782
    7883  // create a small file with table
     84  dummyname = new string("dummy.dat");
    7985  filename = new string("test.dat");
    8086  ofstream test(filename->c_str());
     
    8288  test << "H\t1.\t1.2\n";
    8389  test << "C\t1.2\t1.5\n";
    84   test.close();
    8590  BG = new BondGraph(true);
    8691};
     
    9297  remove(filename->c_str());
    9398  delete(filename);
     99  delete(dummyname);
    94100  delete(BG);
    95101
     
    113119/** UnitTest for BondGraphTest::ConstructBondGraph().
    114120 */
    115 void BondGraphTest::ConstructGraphTest()
     121void BondGraphTest::ConstructGraphFromTableTest()
    116122{
    117123  atom *Walker = TestMolecule->start->next;
     
    119125  CPPUNIT_ASSERT( TestMolecule->end != Walker );
    120126  CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) );
     127  CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule) );
     128  CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) );
     129};
     130
     131/** UnitTest for BondGraphTest::ConstructBondGraph().
     132 */
     133void BondGraphTest::ConstructGraphFromCovalentRadiiTest()
     134{
     135  atom *Walker = TestMolecule->start->next;
     136  atom *Runner = TestMolecule->end->previous;
     137  CPPUNIT_ASSERT( TestMolecule->end != Walker );
     138  CPPUNIT_ASSERT_EQUAL( false , BG->LoadBondLengthTable(*dummyname) );
    121139  CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule) );
    122140  CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) );
Note: See TracChangeset for help on using the changeset viewer.