1 | /*
|
---|
2 | * LinkedCellUnitTest.cpp
|
---|
3 | *
|
---|
4 | * Created on: Apr 9, 2010
|
---|
5 | * Author: heber
|
---|
6 | */
|
---|
7 |
|
---|
8 | using namespace std;
|
---|
9 |
|
---|
10 | #include <cppunit/CompilerOutputter.h>
|
---|
11 | #include <cppunit/extensions/TestFactoryRegistry.h>
|
---|
12 | #include <cppunit/ui/text/TestRunner.h>
|
---|
13 |
|
---|
14 | #include <iostream>
|
---|
15 | #include <stdio.h>
|
---|
16 | #include <cstring>
|
---|
17 |
|
---|
18 | #include "atom.hpp"
|
---|
19 | #include "element.hpp"
|
---|
20 | #include "linkedcell.hpp"
|
---|
21 | #include "molecule.hpp"
|
---|
22 | #include "periodentafel.hpp"
|
---|
23 | #include "LinkedCellUnitTest.hpp"
|
---|
24 |
|
---|
25 | /********************************************** Test classes **************************************/
|
---|
26 |
|
---|
27 | // Registers the fixture into the 'registry'
|
---|
28 | CPPUNIT_TEST_SUITE_REGISTRATION( LinkedCellTest );
|
---|
29 |
|
---|
30 |
|
---|
31 | void LinkedCellTest::setUp()
|
---|
32 | {
|
---|
33 | atom *Walker = NULL;
|
---|
34 |
|
---|
35 | // init private all pointers to zero
|
---|
36 | TestMolecule = NULL;
|
---|
37 | hydrogen = NULL;
|
---|
38 | tafel = NULL;
|
---|
39 |
|
---|
40 | // construct element
|
---|
41 | hydrogen = new element;
|
---|
42 | hydrogen->Z = 1;
|
---|
43 | hydrogen->CovalentRadius = 0.23;
|
---|
44 | strcpy(hydrogen->name, "hydrogen");
|
---|
45 | strcpy(hydrogen->symbol, "H");
|
---|
46 |
|
---|
47 | // construct periodentafel
|
---|
48 | tafel = new periodentafel;
|
---|
49 | tafel->AddElement(hydrogen);
|
---|
50 |
|
---|
51 | // construct molecule (water molecule)
|
---|
52 | TestMolecule = new molecule(tafel);
|
---|
53 | Walker = new atom();
|
---|
54 | Walker->type = hydrogen;
|
---|
55 | Walker->node->Init(0., 0., 0. );
|
---|
56 | TestMolecule->AddAtom(Walker);
|
---|
57 |
|
---|
58 | // check that TestMolecule was correctly constructed
|
---|
59 | CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 1 );
|
---|
60 | Walker = TestMolecule->start->next;
|
---|
61 | CPPUNIT_ASSERT( TestMolecule->end != Walker );
|
---|
62 |
|
---|
63 | // construct linked cell
|
---|
64 | LC = new LinkedCell (TestMolecule, 1.);
|
---|
65 | };
|
---|
66 |
|
---|
67 |
|
---|
68 | void LinkedCellTest::tearDown()
|
---|
69 | {
|
---|
70 | delete(LC);
|
---|
71 | delete(TestMolecule);
|
---|
72 | // note that all the atoms are cleaned by TestMolecule
|
---|
73 | delete(tafel);
|
---|
74 | // note that element is cleaned by periodentafel
|
---|
75 | };
|
---|
76 |
|
---|
77 |
|
---|
78 | /** UnitTest for LinkedCell::GetCurrentCell().
|
---|
79 | */
|
---|
80 | void LinkedCellTest::GetCurrentCellTest()
|
---|
81 | {
|
---|
82 | CPPUNIT_ASSERT_EQUAL( true, true );
|
---|
83 | };
|
---|
84 |
|
---|
85 | /** UnitTest for LinkedCell::GetRelativeToCurrentCell().
|
---|
86 | */
|
---|
87 | void LinkedCellTest::GetRelativeToCurrentCellTest()
|
---|
88 | {
|
---|
89 | CPPUNIT_ASSERT_EQUAL( true, true );
|
---|
90 | };
|
---|
91 |
|
---|
92 |
|
---|
93 | /** UnitTest for LinkedCell::SetIndexToNode().
|
---|
94 | */
|
---|
95 | void LinkedCellTest::SetIndexToNodeTest()
|
---|
96 | {
|
---|
97 | CPPUNIT_ASSERT_EQUAL( true, true );
|
---|
98 | };
|
---|
99 |
|
---|
100 |
|
---|
101 | /** UnitTest for LinkedCell::SetIndexToVector().
|
---|
102 | */
|
---|
103 | void LinkedCellTest::SetIndexToVectorTest()
|
---|
104 | {
|
---|
105 | CPPUNIT_ASSERT_EQUAL( true, true );
|
---|
106 | };
|
---|
107 |
|
---|
108 |
|
---|
109 | /** UnitTest for LinkedCell::CheckBounds().
|
---|
110 | */
|
---|
111 | void LinkedCellTest::CheckBoundsTest()
|
---|
112 | {
|
---|
113 | CPPUNIT_ASSERT_EQUAL( true, true );
|
---|
114 | };
|
---|
115 |
|
---|
116 |
|
---|
117 | /** UnitTest for LinkedCell::GetNeighbourBounds().
|
---|
118 | */
|
---|
119 | void LinkedCellTest::GetNeighbourBoundsTest()
|
---|
120 | {
|
---|
121 | CPPUNIT_ASSERT_EQUAL( true, true );
|
---|
122 | };
|
---|
123 |
|
---|
124 |
|
---|
125 | /** UnitTest for LinkedCell::GetallNeighbours().
|
---|
126 | */
|
---|
127 | void LinkedCellTest::GetallNeighboursTest()
|
---|
128 | {
|
---|
129 | CPPUNIT_ASSERT_EQUAL( true, true );
|
---|
130 | };
|
---|
131 |
|
---|
132 |
|
---|
133 | /** UnitTest for LinkedCell::GetPointsInsideSphere().
|
---|
134 | */
|
---|
135 | void LinkedCellTest::GetPointsInsideSphereTest()
|
---|
136 | {
|
---|
137 | CPPUNIT_ASSERT_EQUAL( true, true );
|
---|
138 | };
|
---|
139 |
|
---|
140 | /********************************************** Main routine **************************************/
|
---|
141 |
|
---|
142 | int main(int argc, char **argv)
|
---|
143 | {
|
---|
144 | // Get the top level suite from the registry
|
---|
145 | CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
|
---|
146 |
|
---|
147 | // Adds the test to the list of test to run
|
---|
148 | CppUnit::TextUi::TestRunner runner;
|
---|
149 | runner.addTest( suite );
|
---|
150 |
|
---|
151 | // Change the default outputter to a compiler error format outputter
|
---|
152 | runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
|
---|
153 | std::cerr ) );
|
---|
154 | // Run the tests.
|
---|
155 | bool wasSucessful = runner.run();
|
---|
156 |
|
---|
157 | // Return error code 1 if the one of test failed.
|
---|
158 | return wasSucessful ? 0 : 1;
|
---|
159 | };
|
---|
160 |
|
---|