Ignore:
Timestamp:
Apr 26, 2010, 3:42:45 PM (15 years ago)
Author:
Frederik Heber <heber@…>
Children:
d1829c
Parents:
543ce4
Message:

BUGFIX: BondGraphUnitTest was not working.

Changes:

  • atoms are now carbon, not hydrogen
  • added covalent and van-der-Waals radii to element creation
  • FIX: carbon now has Z = 2.
  • added test case for NULL BondTable (i.e. from covalent radii)

Signed-off-by: Frederik Heber <heber@…>

File:
1 edited

Legend:

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

    r543ce4 raa8542  
    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());
     
    9197  remove(filename->c_str());
    9298  delete(filename);
     99  delete(dummyname);
    93100  delete(BG);
    94101
     
    112119/** UnitTest for BondGraphTest::ConstructBondGraph().
    113120 */
    114 void BondGraphTest::ConstructGraphTest()
     121void BondGraphTest::ConstructGraphFromTableTest()
    115122{
    116123  atom *Walker = TestMolecule->start->next;
     
    118125  CPPUNIT_ASSERT( TestMolecule->end != Walker );
    119126  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) );
    120139  CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule) );
    121140  CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) );
Note: See TracChangeset for help on using the changeset viewer.