- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
r8db598 rc6394d 60 60 61 61 // construct molecule (tetraeder of hydrogens) base 62 Test SurfaceMolecule = new molecule(tafel);62 TestMolecule = new molecule(tafel); 63 63 Walker = new atom(); 64 64 Walker->type = hydrogen; 65 65 Walker->node->Init(1., 0., 1. ); 66 Test SurfaceMolecule->AddAtom(Walker);66 TestMolecule->AddAtom(Walker); 67 67 Walker = new atom(); 68 68 Walker->type = hydrogen; 69 69 Walker->node->Init(0., 1., 1. ); 70 Test SurfaceMolecule->AddAtom(Walker);70 TestMolecule->AddAtom(Walker); 71 71 Walker = new atom(); 72 72 Walker->type = hydrogen; 73 73 Walker->node->Init(1., 1., 0. ); 74 Test SurfaceMolecule->AddAtom(Walker);74 TestMolecule->AddAtom(Walker); 75 75 Walker = new atom(); 76 76 Walker->type = hydrogen; 77 77 Walker->node->Init(0., 0., 0. ); 78 Test SurfaceMolecule->AddAtom(Walker);78 TestMolecule->AddAtom(Walker); 79 79 80 80 // check that TestMolecule was correctly constructed 81 CPPUNIT_ASSERT_EQUAL( Test SurfaceMolecule->AtomCount, 4 );81 CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 ); 82 82 83 83 TestList = new MoleculeListClass; 84 Test SurfaceMolecule->ActiveFlag = true;85 TestList->insert(Test SurfaceMolecule);84 TestMolecule->ActiveFlag = true; 85 TestList->insert(TestMolecule); 86 86 87 87 // init tesselation and linked cell 88 88 Surface = new Tesselation; 89 LC = new LinkedCell(TestSurfaceMolecule, 5.); 90 FindNonConvexBorder(TestSurfaceMolecule, Surface, (const LinkedCell *&)LC, 2.5, NULL); 89 FindNonConvexBorder(TestMolecule, Surface, (const LinkedCell *&)LC, 2.5, NULL); 90 LC = new LinkedCell(TestMolecule, 5.); 91 CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->PointsOnBoundary.size() ); 92 CPPUNIT_ASSERT_EQUAL( (size_t)6, Surface->LinesOnBoundary.size() ); 93 CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->TrianglesOnBoundary.size() ); 91 94 92 95 // add outer atoms 93 TestMolecule = new molecule(tafel);94 96 Walker = new atom(); 95 97 Walker->type = carbon; … … 109 111 Walker->node->Init(0.5, 0.5, 0.5 ); 110 112 TestMolecule->AddAtom(Walker); 111 TestMolecule->ActiveFlag = true;112 TestList->insert(TestMolecule);113 113 114 114 // init maps … … 136 136 137 137 138 /** Checks whether setup() does the right thing.139 */140 void AnalysisCorrelationToSurfaceUnitTest::SurfaceTest()141 {142 CPPUNIT_ASSERT_EQUAL( 4, TestSurfaceMolecule->AtomCount );143 CPPUNIT_ASSERT_EQUAL( 4, TestMolecule->AtomCount );144 CPPUNIT_ASSERT_EQUAL( (size_t)2, TestList->ListOfMolecules.size() );145 CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->PointsOnBoundary.size() );146 CPPUNIT_ASSERT_EQUAL( (size_t)6, Surface->LinesOnBoundary.size() );147 CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->TrianglesOnBoundary.size() );148 };149 150 138 void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceTest() 151 139 { 152 140 // do the pair correlation 153 141 surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC ); 154 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );155 142 CPPUNIT_ASSERT( surfacemap != NULL ); 156 143 CPPUNIT_ASSERT_EQUAL( (size_t)4, surfacemap->size() ); … … 162 149 surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC ); 163 150 // put pair correlation into bins and check with no range 164 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );165 151 binmap = BinData( surfacemap, 0.5, 0., 0. ); 166 152 CPPUNIT_ASSERT_EQUAL( (size_t)1, binmap->size() ); 167 OutputCorrelation ( (ofstream *)&cout,binmap );153 //OutputCorrelation ( binmap ); 168 154 tester = binmap->begin(); 169 155 CPPUNIT_ASSERT_EQUAL( 0., tester->first ); … … 176 162 BinPairMap::iterator tester; 177 163 surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC ); 178 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );179 164 // ... and check with [0., 2.] range 180 165 binmap = BinData( surfacemap, 0.5, 0., 2. ); 181 166 CPPUNIT_ASSERT_EQUAL( (size_t)5, binmap->size() ); 182 // OutputCorrelation ( (ofstream *)&cout,binmap );167 //OutputCorrelation ( binmap ); 183 168 tester = binmap->begin(); 184 169 CPPUNIT_ASSERT_EQUAL( 0., tester->first ); … … 194 179 BinPairMap::iterator tester; 195 180 surfacemap = CorrelationToSurface( TestList, carbon, Surface, LC ); 196 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );197 181 // put pair correlation into bins and check with no range 198 182 binmap = BinData( surfacemap, 0.5, 0., 0. ); 199 CPPUNIT_ASSERT_EQUAL( (size_t)2, binmap->size() );200 183 OutputCorrelation ( (ofstream *)&cout, binmap ); 184 CPPUNIT_ASSERT_EQUAL( (size_t)9, binmap->size() ); 201 185 // inside point is first and must have negative value 202 tester = binmap->lower_bound( 4.25-0.5); // start depends on the min value and186 tester = binmap->lower_bound(2.95); // start depends on the min value and 203 187 CPPUNIT_ASSERT( tester != binmap->end() ); 204 188 CPPUNIT_ASSERT_EQUAL( 3, tester->second ); 205 189 // inner point 206 tester = binmap->lower_bound( 0.);190 tester = binmap->lower_bound(-0.5); 207 191 CPPUNIT_ASSERT( tester != binmap->end() ); 208 192 CPPUNIT_ASSERT_EQUAL( 1, tester->second ); … … 213 197 BinPairMap::iterator tester; 214 198 surfacemap = CorrelationToSurface( TestList, carbon, Surface, LC ); 215 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );216 199 // ... and check with [0., 2.] range 217 200 binmap = BinData( surfacemap, 0.5, -2., 4. ); 201 OutputCorrelation ( (ofstream *)&cout, binmap ); 218 202 CPPUNIT_ASSERT_EQUAL( (size_t)13, binmap->size() ); 219 // OutputCorrelation ( (ofstream *)&cout, binmap );220 203 // three outside points 221 tester = binmap->lower_bound( 4.25-0.5);204 tester = binmap->lower_bound(3.); 222 205 CPPUNIT_ASSERT( tester != binmap->end() ); 223 206 CPPUNIT_ASSERT_EQUAL( 3, tester->second ); 224 207 // inner point 225 tester = binmap->lower_bound( 0.);208 tester = binmap->lower_bound(-0.5); 226 209 CPPUNIT_ASSERT( tester != binmap->end() ); 227 210 CPPUNIT_ASSERT_EQUAL( 1, tester->second ); 211 228 212 }; 229 213
Note:
See TracChangeset
for help on using the changeset viewer.