Index: src/unittests/Makefile.am
===================================================================
--- src/unittests/Makefile.am	(revision 46ea3b3e9b5812647dd0fc8c97ecfc39e5eb3f10)
+++ src/unittests/Makefile.am	(revision b7072174869980a43146f17b651981474109f428)
@@ -20,5 +20,5 @@
 AnalysisPairCorrelationUnitTest_LDADD = ../libmolecuilder.a
 
-BondGraphUnitTest_SOURCES = ../bondgraph.cpp ../bondgraph.hpp bondgraphunittest.cpp bondgraphunittest.hpp
+BondGraphUnitTest_SOURCES = bondgraphunittest.cpp bondgraphunittest.hpp
 BondGraphUnitTest_LDADD = ../libmolecuilder.a
 
Index: src/unittests/bondgraphunittest.cpp
===================================================================
--- src/unittests/bondgraphunittest.cpp	(revision b7072174869980a43146f17b651981474109f428)
+++ src/unittests/bondgraphunittest.cpp	(revision b7072174869980a43146f17b651981474109f428)
@@ -0,0 +1,142 @@
+/*
+ * bondgraphunittest.cpp
+ *
+ *  Created on: Oct 29, 2009
+ *      Author: heber
+ */
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include <iostream>
+#include <stdio.h>
+
+#include "atom.hpp"
+#include "bond.hpp"
+#include "bondgraph.hpp"
+#include "element.hpp"
+#include "molecule.hpp"
+#include "periodentafel.hpp"
+#include "bondgraphunittest.hpp"
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( BondGraphTest );
+
+
+void BondGraphTest::setUp()
+{
+  atom *Walker = NULL;
+
+  // init private all pointers to zero
+  TestMolecule = NULL;
+  hydrogen = NULL;
+  tafel = NULL;
+
+  // construct element
+  hydrogen = new element;
+  hydrogen->Z = 1;
+  strcpy(hydrogen->name, "hydrogen");
+  strcpy(hydrogen->symbol, "H");
+  carbon = new element;
+  carbon->Z = 1;
+  strcpy(carbon->name, "carbon");
+  strcpy(carbon->symbol, "C");
+
+
+  // construct periodentafel
+  tafel = new periodentafel;
+  tafel->AddElement(hydrogen);
+  tafel->AddElement(carbon);
+
+  // construct molecule (tetraeder of hydrogens)
+  TestMolecule = new molecule(tafel);
+  Walker = new atom();
+  Walker->type = hydrogen;
+  Walker->node->Init(1., 0., 1. );
+  TestMolecule->AddAtom(Walker);
+  Walker = new atom();
+  Walker->type = hydrogen;
+  Walker->node->Init(0., 1., 1. );
+  TestMolecule->AddAtom(Walker);
+  Walker = new atom();
+  Walker->type = hydrogen;
+  Walker->node->Init(1., 1., 0. );
+  TestMolecule->AddAtom(Walker);
+  Walker = new atom();
+  Walker->type = hydrogen;
+  Walker->node->Init(0., 0., 0. );
+  TestMolecule->AddAtom(Walker);
+
+  // check that TestMolecule was correctly constructed
+  CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
+
+  // create a small file with table
+  filename = new string("test.dat");
+  ofstream test(filename->c_str());
+  test << "# Hydrogen\tCarbon\n1.\t1.2\n1.2\t1.5" << endl;
+  BG = new BondGraph(true);
+};
+
+
+void BondGraphTest::tearDown()
+{
+  // remove the file
+  remove(filename->c_str());
+  delete(filename);
+  delete(BG);
+
+  // remove molecule
+  delete(TestMolecule);
+  // note that all the atoms are cleaned by TestMolecule
+  delete(tafel);
+  // note that element is cleaned by periodentafel
+};
+
+/** UnitTest for BondGraphTest::LoadBondLengthTable().
+ */
+void BondGraphTest::LoadTableTest()
+{
+  CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable((ofstream *)&cout, *filename) );
+  CPPUNIT_ASSERT_EQUAL( 1., BG->GetBondLength(0,0) );
+  CPPUNIT_ASSERT_EQUAL( 1.2, BG->GetBondLength(0,1) );
+  CPPUNIT_ASSERT_EQUAL( 1.5, BG->GetBondLength(1,1) );
+};
+
+/** UnitTest for BondGraphTest::ConstructBondGraph().
+ */
+void BondGraphTest::ConstructGraphTest()
+{
+  atom *Walker = TestMolecule->start->next;
+  atom *Runner = TestMolecule->end->previous;
+  CPPUNIT_ASSERT( TestMolecule->end != Walker );
+  CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable((ofstream *)&cout, *filename) );
+  CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph((ofstream *)&cout, TestMolecule) );
+  CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) );
+};
+
+
+/********************************************** Main routine **************************************/
+
+int main(int argc, char **argv)
+{
+  // Get the top level suite from the registry
+  CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
+
+  // Adds the test to the list of test to run
+  CppUnit::TextUi::TestRunner runner;
+  runner.addTest( suite );
+
+  // Change the default outputter to a compiler error format outputter
+  runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
+                                                       std::cerr ) );
+  // Run the tests.
+  bool wasSucessful = runner.run();
+
+  // Return error code 1 if the one of test failed.
+  return wasSucessful ? 0 : 1;
+};
Index: src/unittests/bondgraphunittest.hpp
===================================================================
--- src/unittests/bondgraphunittest.hpp	(revision b7072174869980a43146f17b651981474109f428)
+++ src/unittests/bondgraphunittest.hpp	(revision b7072174869980a43146f17b651981474109f428)
@@ -0,0 +1,45 @@
+/*
+ * bondgraphunittest.hpp
+ *
+ *  Created on: Oct 29, 2009
+ *      Author: heber
+ */
+
+#ifndef BONDGRAPHUNITTEST_HPP_
+#define BONDGRAPHUNITTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "bondgraph.hpp"
+
+class element;
+class molecule;
+class periodentafel;
+
+/********************************************** Test classes **************************************/
+
+class BondGraphTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( BondGraphTest) ;
+    CPPUNIT_TEST ( LoadTableTest );
+    CPPUNIT_TEST ( ConstructGraphTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+      void setUp();
+      void tearDown();
+      void LoadTableTest();
+      void ConstructGraphTest();
+
+private:
+
+      molecule *TestMolecule;
+      element *hydrogen;
+      element *carbon;
+      periodentafel *tafel;
+
+      BondGraph *BG;
+      string *filename;
+};
+
+#endif /* BONDGRAPHUNITTEST_HPP_ */
