Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/unittests/bondgraphunittest.cpp

    r49e1ae re5ad5c  
    1414#include <iostream>
    1515#include <stdio.h>
    16 #include <cstring>
    1716
    1817#include "atom.hpp"
     
    2019#include "bondgraph.hpp"
    2120#include "element.hpp"
     21#include "log.hpp"
    2222#include "molecule.hpp"
    2323#include "periodentafel.hpp"
     
    4242  hydrogen = new element;
    4343  hydrogen->Z = 1;
     44  hydrogen->CovalentRadius = 0.23;
     45  hydrogen->VanDerWaalsRadius = 1.09;
    4446  strcpy(hydrogen->name, "hydrogen");
    4547  strcpy(hydrogen->symbol, "H");
    4648  carbon = new element;
    47   carbon->Z = 1;
     49  carbon->Z = 2;
     50  carbon->CovalentRadius = 0.68;
     51  carbon->VanDerWaalsRadius = 1.7;
    4852  strcpy(carbon->name, "carbon");
    4953  strcpy(carbon->symbol, "C");
     
    5862  TestMolecule = new molecule(tafel);
    5963  Walker = new atom();
    60   Walker->type = hydrogen;
     64  Walker->type = carbon;
    6165  Walker->node->Init(1., 0., 1. );
    6266  TestMolecule->AddAtom(Walker);
    6367  Walker = new atom();
    64   Walker->type = hydrogen;
     68  Walker->type = carbon;
    6569  Walker->node->Init(0., 1., 1. );
    6670  TestMolecule->AddAtom(Walker);
    6771  Walker = new atom();
    68   Walker->type = hydrogen;
     72  Walker->type = carbon;
    6973  Walker->node->Init(1., 1., 0. );
    7074  TestMolecule->AddAtom(Walker);
    7175  Walker = new atom();
    72   Walker->type = hydrogen;
     76  Walker->type = carbon;
    7377  Walker->node->Init(0., 0., 0. );
    7478  TestMolecule->AddAtom(Walker);
     
    7882
    7983  // create a small file with table
     84  dummyname = new string("dummy.dat");
    8085  filename = new string("test.dat");
    8186  ofstream test(filename->c_str());
     
    8388  test << "H\t1.\t1.2\n";
    8489  test << "C\t1.2\t1.5\n";
    85   test.close();
    8690  BG = new BondGraph(true);
    8791};
     
    9397  remove(filename->c_str());
    9498  delete(filename);
     99  delete(dummyname);
    95100  delete(BG);
    96101
     
    114119/** UnitTest for BondGraphTest::ConstructBondGraph().
    115120 */
    116 void BondGraphTest::ConstructGraphTest()
     121void BondGraphTest::ConstructGraphFromTableTest()
    117122{
    118123  atom *Walker = TestMolecule->start->next;
     
    120125  CPPUNIT_ASSERT( TestMolecule->end != Walker );
    121126  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) );
    122139  CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule) );
    123140  CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) );
Note: See TracChangeset for help on using the changeset viewer.