- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/unittests/bondgraphunittest.cpp
r49e1ae re5ad5c 14 14 #include <iostream> 15 15 #include <stdio.h> 16 #include <cstring>17 16 18 17 #include "atom.hpp" … … 20 19 #include "bondgraph.hpp" 21 20 #include "element.hpp" 21 #include "log.hpp" 22 22 #include "molecule.hpp" 23 23 #include "periodentafel.hpp" … … 42 42 hydrogen = new element; 43 43 hydrogen->Z = 1; 44 hydrogen->CovalentRadius = 0.23; 45 hydrogen->VanDerWaalsRadius = 1.09; 44 46 strcpy(hydrogen->name, "hydrogen"); 45 47 strcpy(hydrogen->symbol, "H"); 46 48 carbon = new element; 47 carbon->Z = 1; 49 carbon->Z = 2; 50 carbon->CovalentRadius = 0.68; 51 carbon->VanDerWaalsRadius = 1.7; 48 52 strcpy(carbon->name, "carbon"); 49 53 strcpy(carbon->symbol, "C"); … … 58 62 TestMolecule = new molecule(tafel); 59 63 Walker = new atom(); 60 Walker->type = hydrogen;64 Walker->type = carbon; 61 65 Walker->node->Init(1., 0., 1. ); 62 66 TestMolecule->AddAtom(Walker); 63 67 Walker = new atom(); 64 Walker->type = hydrogen;68 Walker->type = carbon; 65 69 Walker->node->Init(0., 1., 1. ); 66 70 TestMolecule->AddAtom(Walker); 67 71 Walker = new atom(); 68 Walker->type = hydrogen;72 Walker->type = carbon; 69 73 Walker->node->Init(1., 1., 0. ); 70 74 TestMolecule->AddAtom(Walker); 71 75 Walker = new atom(); 72 Walker->type = hydrogen;76 Walker->type = carbon; 73 77 Walker->node->Init(0., 0., 0. ); 74 78 TestMolecule->AddAtom(Walker); … … 78 82 79 83 // create a small file with table 84 dummyname = new string("dummy.dat"); 80 85 filename = new string("test.dat"); 81 86 ofstream test(filename->c_str()); … … 83 88 test << "H\t1.\t1.2\n"; 84 89 test << "C\t1.2\t1.5\n"; 85 test.close();86 90 BG = new BondGraph(true); 87 91 }; … … 93 97 remove(filename->c_str()); 94 98 delete(filename); 99 delete(dummyname); 95 100 delete(BG); 96 101 … … 114 119 /** UnitTest for BondGraphTest::ConstructBondGraph(). 115 120 */ 116 void BondGraphTest::ConstructGraph Test()121 void BondGraphTest::ConstructGraphFromTableTest() 117 122 { 118 123 atom *Walker = TestMolecule->start->next; … … 120 125 CPPUNIT_ASSERT( TestMolecule->end != Walker ); 121 126 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 */ 133 void 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) ); 122 139 CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule) ); 123 140 CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) );
Note:
See TracChangeset
for help on using the changeset viewer.