Changeset 06f141 for molecuilder/src/unittests/analysisbondsunittest.cpp
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/unittests/analysisbondsunittest.cpp
r7a6fd9 r06f141 40 40 atom *Walker = NULL; 41 41 42 // init private all pointers to zero 43 TestMolecule = NULL; 44 hydrogen = NULL; 45 tafel = NULL; 46 47 // construct element 48 hydrogen = new element; 49 hydrogen->Z = 1; 50 hydrogen->Valence = 1; 51 hydrogen->NoValenceOrbitals = 1; 52 strcpy(hydrogen->name, "hydrogen"); 53 strcpy(hydrogen->symbol, "H"); 54 carbon = new element; 55 carbon->Z = 2; 56 carbon->Valence = 4; 57 carbon->NoValenceOrbitals = 4; 58 strcpy(carbon->name, "carbon"); 59 strcpy(carbon->symbol, "C"); 60 61 62 // construct periodentafel 63 tafel = World::getInstance().getPeriode(); 64 tafel->AddElement(hydrogen); 65 tafel->AddElement(carbon); 42 // get elements 43 hydrogen = World::getInstance().getPeriode()->FindElement(1); 44 carbon = World::getInstance().getPeriode()->FindElement(6); 45 CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen"); 46 CPPUNIT_ASSERT(carbon != NULL && "could not find element carbon"); 66 47 67 48 // construct molecule (tetraeder of hydrogens) 68 49 TestMolecule = World::getInstance().createMolecule(); 50 CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule"); 69 51 Walker = World::getInstance().createAtom(); 52 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 70 53 Walker->type = hydrogen; 71 54 *Walker->node = Vector(1.5, 0., 1.5 ); 72 55 TestMolecule->AddAtom(Walker); 73 56 Walker = World::getInstance().createAtom(); 57 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 74 58 Walker->type = hydrogen; 75 59 *Walker->node = Vector(0., 1.5, 1.5 ); 76 60 TestMolecule->AddAtom(Walker); 77 61 Walker = World::getInstance().createAtom(); 62 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 78 63 Walker->type = hydrogen; 79 64 *Walker->node = Vector(1.5, 1.5, 0. ); 80 65 TestMolecule->AddAtom(Walker); 81 66 Walker = World::getInstance().createAtom(); 67 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 82 68 Walker->type = hydrogen; 83 69 *Walker->node = Vector(0., 0., 0. ); 84 70 TestMolecule->AddAtom(Walker); 85 71 Walker = World::getInstance().createAtom(); 72 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 86 73 Walker->type = carbon; 87 74 *Walker->node = Vector(0.5, 0.5, 0.5 ); … … 93 80 // create a small file with table 94 81 filename = new string("test.dat"); 82 CPPUNIT_ASSERT(filename != NULL && "could not create string"); 95 83 ofstream test(filename->c_str()); 96 test << ".\tH\tC\n"; 97 test << "H\t1.\t1.2\n"; 98 test << "C\t1.2\t1.5\n"; 84 test << ".\tH\tHe\tLi\tBe\tB\tC\n"; 85 test << "H\t1.\t1.\t1.\t1.\t1.\t1.2\n"; 86 test << "He\t1.\t1.\t1.\t1.\t1.\t1.\n"; 87 test << "Li\t1.\t1.\t1.\t1.\t1.\t1.\n"; 88 test << "Be\t1.\t1.\t1.\t1.\t1.\t1.\n"; 89 test << "B\t1.\t1.\t1.\t1.\t1.\t1.\n"; 90 test << "C\t1.2\t1.\t1.\t1.\t1.\t1.5\n"; 99 91 test.close(); 100 92 BG = new BondGraph(true); 93 CPPUNIT_ASSERT(BG != NULL && "could not create BondGraph"); 101 94 102 95 CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) ); 103 96 CPPUNIT_ASSERT_EQUAL( 1., BG->GetBondLength(0,0) ); 104 CPPUNIT_ASSERT_EQUAL( 1.2, BG->GetBondLength(0, 1) );105 CPPUNIT_ASSERT_EQUAL( 1.5, BG->GetBondLength( 1,1) );97 CPPUNIT_ASSERT_EQUAL( 1.2, BG->GetBondLength(0,5) ); 98 CPPUNIT_ASSERT_EQUAL( 1.5, BG->GetBondLength(5,5) ); 106 99 107 100 BG->ConstructBondGraph(TestMolecule);
Note:
See TracChangeset
for help on using the changeset viewer.
