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