- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
rc4d4df r7ea9e6 33 33 34 34 // init private all pointers to zero 35 TestList = NULL; 35 36 TestMolecule = NULL; 36 37 hydrogen = NULL; … … 41 42 LC = NULL; 42 43 43 44 44 // construct element 45 45 hydrogen = new element; 46 46 hydrogen->Z = 1; 47 47 strcpy(hydrogen->name, "hydrogen"); 48 hydrogen->symbol[0] = 'H'; 48 strcpy(hydrogen->symbol, "H"); 49 carbon = new element; 50 carbon->Z = 6; 51 strcpy(carbon->name, "carbon"); 52 strcpy(carbon->symbol, "C"); 49 53 50 54 // construct periodentafel 51 55 tafel = new periodentafel; 52 56 tafel->AddElement(hydrogen); 53 54 // construct molecule (tetraeder of hydrogens) 57 tafel->AddElement(carbon); 58 59 // construct molecule (tetraeder of hydrogens) base 55 60 TestMolecule = new molecule(tafel); 56 61 Walker = new atom(); … … 74 79 CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 ); 75 80 81 TestList = new MoleculeListClass; 82 TestMolecule->ActiveFlag = true; 83 TestList->insert(TestMolecule); 84 76 85 // init tesselation and linked cell 77 86 Surface = new Tesselation; 78 TestMolecule->TesselStruct = Surface; 79 FindNonConvexBorder((ofstream *)&cout, TestMolecule, LC, 2.5, NULL); 87 FindNonConvexBorder((ofstream *)&cerr, TestMolecule, Surface, (const LinkedCell *&)LC, 2.5, NULL); 80 88 LC = new LinkedCell(TestMolecule, 5.); 81 89 CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->PointsOnBoundary.size() ); … … 83 91 CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->TrianglesOnBoundary.size() ); 84 92 93 // add outer atoms 94 Walker = new atom(); 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); 111 85 112 // init maps 86 surfacemap = CorrelationToSurface( (ofstream *)&cout, TestMolecule, hydrogen, Surface, LC );113 surfacemap = NULL; 87 114 binmap = NULL; 88 115 … … 98 125 99 126 // remove 100 delete(TestMolecule); 101 // note that Surface and all the atoms are cleaned by TestMolecule 127 delete(TestList); 128 delete(Surface); 129 // note that all the atoms are cleaned by TestMolecule 102 130 delete(LC); 103 131 delete(tafel); … … 109 137 { 110 138 // do the pair correlation 139 surfacemap = CorrelationToSurface( (ofstream *)&cout, TestList, hydrogen, Surface, LC ); 111 140 CPPUNIT_ASSERT( surfacemap != NULL ); 112 141 CPPUNIT_ASSERT_EQUAL( (size_t)4, surfacemap->size() ); 113 142 }; 114 143 115 void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceBinNoRangeTest() 116 { 117 BinPairMap::iterator tester; 144 void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceHydrogenBinNoRangeTest() 145 { 146 BinPairMap::iterator tester; 147 surfacemap = CorrelationToSurface( (ofstream *)&cout, TestList, hydrogen, Surface, LC ); 118 148 // put pair correlation into bins and check with no range 119 149 binmap = BinData( (ofstream *)&cout, surfacemap, 0.5, 0., 0. ); … … 126 156 }; 127 157 128 void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceBinRangeTest() 129 { 130 BinPairMap::iterator tester; 158 void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceHydrogenBinRangeTest() 159 { 160 BinPairMap::iterator tester; 161 surfacemap = CorrelationToSurface( (ofstream *)&cout, TestList, hydrogen, Surface, LC ); 131 162 // ... and check with [0., 2.] range 132 163 binmap = BinData( (ofstream *)&cout, surfacemap, 0.5, 0., 2. ); … … 142 173 }; 143 174 175 void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceCarbonBinNoRangeTest() 176 { 177 BinPairMap::iterator tester; 178 surfacemap = CorrelationToSurface( (ofstream *)&cout, TestList, carbon, Surface, LC ); 179 // put pair correlation into bins and check with no range 180 binmap = BinData( (ofstream *)&cout, surfacemap, 0.5, 0., 0. ); 181 CPPUNIT_ASSERT_EQUAL( (size_t)2, binmap->size() ); 182 OutputCorrelation ( (ofstream *)&cout, binmap ); 183 // inside point is first and must have negative value 184 tester = binmap->lower_bound(2.95); // start depends on the min value and 185 CPPUNIT_ASSERT( tester != binmap->end() ); 186 CPPUNIT_ASSERT_EQUAL( 3, tester->second ); 187 // inner point 188 tester = binmap->lower_bound(-0.5); 189 CPPUNIT_ASSERT( tester != binmap->end() ); 190 CPPUNIT_ASSERT_EQUAL( 1, tester->second ); 191 }; 192 193 void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceCarbonBinRangeTest() 194 { 195 BinPairMap::iterator tester; 196 surfacemap = CorrelationToSurface( (ofstream *)&cout, TestList, carbon, Surface, LC ); 197 // ... and check with [0., 2.] range 198 binmap = BinData( (ofstream *)&cout, surfacemap, 0.5, -2., 4. ); 199 CPPUNIT_ASSERT_EQUAL( (size_t)13, binmap->size() ); 200 OutputCorrelation ( (ofstream *)&cout, binmap ); 201 // three outside points 202 tester = binmap->lower_bound(3.); 203 CPPUNIT_ASSERT( tester != binmap->end() ); 204 CPPUNIT_ASSERT_EQUAL( 3, tester->second ); 205 // inner point 206 tester = binmap->lower_bound(-0.5); 207 CPPUNIT_ASSERT( tester != binmap->end() ); 208 CPPUNIT_ASSERT_EQUAL( 1, tester->second ); 209 210 }; 211 144 212 /********************************************** Main routine **************************************/ 145 213
Note:
See TracChangeset
for help on using the changeset viewer.