Changeset 5f612ee for src/unittests
- Timestamp:
- Apr 27, 2010, 2:25:42 PM (15 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- 632bc3
- Parents:
- 13d5a9 (diff), c695c9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src/unittests
- Files:
-
- 4 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
src/unittests/AnalysisCorrelationToPointUnitTest.cpp
r13d5a9 r5f612ee 83 83 84 84 TestList = World::getInstance().getMolecules(); 85 TestList->insert(TestMolecule); 85 86 TestMolecule->ActiveFlag = true; 86 TestList->insert(TestMolecule);87 87 88 88 // init point … … 122 122 // put pair correlation into bins and check with no range 123 123 binmap = BinData( pointmap, 0.5, 0., 0. ); 124 CPPUNIT_ASSERT_EQUAL( (size_t)2, binmap->size());125 //OutputCorrelation ( binmap);124 OutputCorrelation ( (ofstream *)&cout, binmap ); 125 CPPUNIT_ASSERT_EQUAL( (size_t)3, binmap->size() ); 126 126 tester = binmap->begin(); 127 127 CPPUNIT_ASSERT_EQUAL( 1., tester->first ); … … 135 135 // ... and check with [0., 2.] range 136 136 binmap = BinData( pointmap, 0.5, 0., 2. ); 137 OutputCorrelation ( (ofstream *)&cout, binmap ); 137 138 CPPUNIT_ASSERT_EQUAL( (size_t)5, binmap->size() ); 138 //OutputCorrelation ( binmap );139 139 tester = binmap->begin(); 140 140 CPPUNIT_ASSERT_EQUAL( 0., tester->first ); -
src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
r13d5a9 r5f612ee 70 70 71 71 // construct molecule (tetraeder of hydrogens) base 72 TestSurfaceMolecule = World::getInstance().createMolecule(); 73 Walker = World::getInstance().createAtom(); 74 Walker->type = hydrogen; 75 Walker->node->Init(1., 0., 1. ); 76 TestSurfaceMolecule->AddAtom(Walker); 77 Walker = World::getInstance().createAtom(); 78 Walker->type = hydrogen; 79 Walker->node->Init(0., 1., 1. ); 80 TestSurfaceMolecule->AddAtom(Walker); 81 Walker = World::getInstance().createAtom(); 82 Walker->type = hydrogen; 83 Walker->node->Init(1., 1., 0. ); 84 TestSurfaceMolecule->AddAtom(Walker); 85 Walker = World::getInstance().createAtom(); 86 Walker->type = hydrogen; 87 Walker->node->Init(0., 0., 0. ); 88 TestSurfaceMolecule->AddAtom(Walker); 89 90 // check that TestMolecule was correctly constructed 91 CPPUNIT_ASSERT_EQUAL( TestSurfaceMolecule->AtomCount, 4 ); 92 93 TestList = World::getInstance().getMolecules(); 94 TestSurfaceMolecule->ActiveFlag = true; 95 TestList->insert(TestSurfaceMolecule); 96 97 // init tesselation and linked cell 98 Surface = new Tesselation; 99 LC = new LinkedCell(TestSurfaceMolecule, 5.); 100 FindNonConvexBorder(TestSurfaceMolecule, Surface, (const LinkedCell *&)LC, 2.5, NULL); 101 102 // add outer atoms 72 103 TestMolecule = World::getInstance().createMolecule(); 73 104 Walker = World::getInstance().createAtom(); 74 Walker->type = hydrogen; 75 Walker->node->Init(1., 0., 1. ); 76 TestMolecule->AddAtom(Walker); 77 Walker = World::getInstance().createAtom(); 78 Walker->type = hydrogen; 79 Walker->node->Init(0., 1., 1. ); 80 TestMolecule->AddAtom(Walker); 81 Walker = World::getInstance().createAtom(); 82 Walker->type = hydrogen; 83 Walker->node->Init(1., 1., 0. ); 84 TestMolecule->AddAtom(Walker); 85 Walker = World::getInstance().createAtom(); 86 Walker->type = hydrogen; 87 Walker->node->Init(0., 0., 0. ); 88 TestMolecule->AddAtom(Walker); 89 90 // check that TestMolecule was correctly constructed 91 CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 ); 92 93 TestList = World::getInstance().getMolecules(); 105 Walker->type = carbon; 106 Walker->node->Init(4., 0., 4. ); 107 TestMolecule->AddAtom(Walker); 108 Walker = World::getInstance().createAtom(); 109 Walker->type = carbon; 110 Walker->node->Init(0., 4., 4. ); 111 TestMolecule->AddAtom(Walker); 112 Walker = World::getInstance().createAtom(); 113 Walker->type = carbon; 114 Walker->node->Init(4., 4., 0. ); 115 TestMolecule->AddAtom(Walker); 116 // add inner atoms 117 Walker = World::getInstance().createAtom(); 118 Walker->type = carbon; 119 Walker->node->Init(0.5, 0.5, 0.5 ); 120 TestMolecule->AddAtom(Walker); 94 121 TestMolecule->ActiveFlag = true; 95 122 TestList->insert(TestMolecule); 96 97 // init tesselation and linked cell98 Surface = new Tesselation;99 FindNonConvexBorder(TestMolecule, Surface, (const LinkedCell *&)LC, 2.5, NULL);100 LC = new LinkedCell(TestMolecule, 5.);101 CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->PointsOnBoundary.size() );102 CPPUNIT_ASSERT_EQUAL( (size_t)6, Surface->LinesOnBoundary.size() );103 CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->TrianglesOnBoundary.size() );104 105 // add outer atoms106 Walker = World::getInstance().createAtom();107 Walker->type = carbon;108 Walker->node->Init(4., 0., 4. );109 TestMolecule->AddAtom(Walker);110 Walker = World::getInstance().createAtom();111 Walker->type = carbon;112 Walker->node->Init(0., 4., 4. );113 TestMolecule->AddAtom(Walker);114 Walker = World::getInstance().createAtom();115 Walker->type = carbon;116 Walker->node->Init(4., 4., 0. );117 TestMolecule->AddAtom(Walker);118 // add inner atoms119 Walker = World::getInstance().createAtom();120 Walker->type = carbon;121 Walker->node->Init(0.5, 0.5, 0.5 );122 TestMolecule->AddAtom(Walker);123 123 124 124 // init maps … … 145 145 146 146 147 /** Checks whether setup() does the right thing. 148 */ 149 void AnalysisCorrelationToSurfaceUnitTest::SurfaceTest() 150 { 151 CPPUNIT_ASSERT_EQUAL( 4, TestSurfaceMolecule->AtomCount ); 152 CPPUNIT_ASSERT_EQUAL( 4, TestMolecule->AtomCount ); 153 CPPUNIT_ASSERT_EQUAL( (size_t)2, TestList->ListOfMolecules.size() ); 154 CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->PointsOnBoundary.size() ); 155 CPPUNIT_ASSERT_EQUAL( (size_t)6, Surface->LinesOnBoundary.size() ); 156 CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->TrianglesOnBoundary.size() ); 157 }; 158 147 159 void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceTest() 148 160 { 149 161 // do the pair correlation 150 162 surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC ); 163 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 151 164 CPPUNIT_ASSERT( surfacemap != NULL ); 152 165 CPPUNIT_ASSERT_EQUAL( (size_t)4, surfacemap->size() ); … … 158 171 surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC ); 159 172 // put pair correlation into bins and check with no range 173 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 160 174 binmap = BinData( surfacemap, 0.5, 0., 0. ); 161 175 CPPUNIT_ASSERT_EQUAL( (size_t)1, binmap->size() ); 162 //OutputCorrelation (binmap );176 OutputCorrelation ( (ofstream *)&cout, binmap ); 163 177 tester = binmap->begin(); 164 178 CPPUNIT_ASSERT_EQUAL( 0., tester->first ); … … 171 185 BinPairMap::iterator tester; 172 186 surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC ); 187 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 173 188 // ... and check with [0., 2.] range 174 189 binmap = BinData( surfacemap, 0.5, 0., 2. ); 175 190 CPPUNIT_ASSERT_EQUAL( (size_t)5, binmap->size() ); 176 //OutputCorrelation (binmap );191 // OutputCorrelation ( (ofstream *)&cout, binmap ); 177 192 tester = binmap->begin(); 178 193 CPPUNIT_ASSERT_EQUAL( 0., tester->first ); … … 188 203 BinPairMap::iterator tester; 189 204 surfacemap = CorrelationToSurface( TestList, carbon, Surface, LC ); 205 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 190 206 // put pair correlation into bins and check with no range 191 207 binmap = BinData( surfacemap, 0.5, 0., 0. ); 192 CPPUNIT_ASSERT_EQUAL( (size_t)2, binmap->size());193 OutputCorrelation ( (ofstream *)&cout, binmap);208 //OutputCorrelation ( (ofstream *)&cout, binmap ); 209 CPPUNIT_ASSERT_EQUAL( (size_t)9, binmap->size() ); 194 210 // inside point is first and must have negative value 195 tester = binmap->lower_bound( 2.95); // start depends on the min value and211 tester = binmap->lower_bound(4.25-0.5); // start depends on the min value and 196 212 CPPUNIT_ASSERT( tester != binmap->end() ); 197 213 CPPUNIT_ASSERT_EQUAL( 3, tester->second ); 198 214 // inner point 199 tester = binmap->lower_bound( -0.5);215 tester = binmap->lower_bound(0.); 200 216 CPPUNIT_ASSERT( tester != binmap->end() ); 201 217 CPPUNIT_ASSERT_EQUAL( 1, tester->second ); … … 206 222 BinPairMap::iterator tester; 207 223 surfacemap = CorrelationToSurface( TestList, carbon, Surface, LC ); 224 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 208 225 // ... and check with [0., 2.] range 209 226 binmap = BinData( surfacemap, 0.5, -2., 4. ); 227 //OutputCorrelation ( (ofstream *)&cout, binmap ); 210 228 CPPUNIT_ASSERT_EQUAL( (size_t)13, binmap->size() ); 211 OutputCorrelation ( (ofstream *)&cout, binmap );212 229 // three outside points 213 tester = binmap->lower_bound( 3.);230 tester = binmap->lower_bound(4.25-0.5); 214 231 CPPUNIT_ASSERT( tester != binmap->end() ); 215 232 CPPUNIT_ASSERT_EQUAL( 3, tester->second ); 216 233 // inner point 217 tester = binmap->lower_bound( -0.5);234 tester = binmap->lower_bound(0.); 218 235 CPPUNIT_ASSERT( tester != binmap->end() ); 219 236 CPPUNIT_ASSERT_EQUAL( 1, tester->second ); 220 221 }; 237 }; -
src/unittests/AnalysisCorrelationToSurfaceUnitTest.hpp
r13d5a9 r5f612ee 23 23 { 24 24 CPPUNIT_TEST_SUITE( AnalysisCorrelationToSurfaceUnitTest ) ; 25 CPPUNIT_TEST ( SurfaceTest ); 25 26 CPPUNIT_TEST ( CorrelationToSurfaceTest ); 26 27 CPPUNIT_TEST ( CorrelationToSurfaceHydrogenBinNoRangeTest ); … … 33 34 void setUp(); 34 35 void tearDown(); 36 void SurfaceTest(); 35 37 void CorrelationToSurfaceTest(); 36 38 void CorrelationToSurfaceHydrogenBinNoRangeTest(); … … 43 45 MoleculeListClass *TestList; 44 46 molecule *TestMolecule; 47 molecule *TestSurfaceMolecule; 45 48 element *hydrogen; 46 49 element *carbon; -
src/unittests/Makefile.am
r13d5a9 r5f612ee 4 4 AM_CXXFLAGS = $(CPPUNIT_CFLAGS) 5 5 6 MENUTESTS = ActionSequenceTest 6 MENUTESTS = \ 7 ActionSequenceTest 7 8 8 9 TESTS = \ … … 16 17 BondGraphUnitTest \ 17 18 CacheableTest \ 19 CountBondsUnitTest \ 18 20 GSLMatrixSymmetricUnitTest \ 19 21 GSLMatrixUnitTest \ … … 21 23 InfoUnitTest \ 22 24 LinearSystemOfEquationsUnitTest \ 25 LinkedCellUnitTest \ 23 26 ListOfBondsUnitTest \ 24 27 LogUnitTest \ … … 36 39 ${MENUTESTS} 37 40 38 39 40 41 41 42 check_PROGRAMS = $(TESTS) … … 56 57 bondgraphunittest.cpp \ 57 58 CacheableTest.cpp \ 59 CountBondsUnitTest.cpp \ 58 60 gslmatrixsymmetricunittest.cpp \ 59 61 gslmatrixunittest.cpp \ … … 61 63 infounittest.cpp \ 62 64 linearsystemofequationsunittest.cpp \ 65 LinkedCellUnitTest.cpp \ 63 66 listofbondsunittest.cpp \ 64 67 logunittest.cpp \ … … 76 79 77 80 TESTHEADERS = \ 78 analysis_correlation.hpp 81 ActOnAllUnitTest.hpp \ 82 ActionSequenceTest.hpp \ 83 analysisbondsunittest.hpp \ 84 AnalysisCorrelationToPointUnitTest.hpp \ 85 AnalysisCorrelationToSurfaceUnitTest.hpp \ 86 AnalysisPairCorrelationUnitTest.hpp \ 87 AtomDescriptorTest.hpp \ 88 atomsCalculationTest.hpp \ 89 bondgraphunittest.hpp \ 90 CacheableTest.hpp \ 91 CountBondsUnitTest.hpp \ 92 gslmatrixsymmetricunittest.hpp \ 93 gslmatrixunittest.hpp \ 94 gslvectorunittest.hpp \ 95 infounittest.hpp \ 96 linearsystemofequationsunittest.hpp \ 97 LinkedCellUnitTest.hpp \ 98 listofbondsunittest.hpp \ 99 logunittest.hpp \ 100 manipulateAtomsTest.hpp \ 101 memoryallocatorunittest.hpp \ 102 memoryusageobserverunittest.hpp \ 103 MoleculeDescriptorTest.hpp \ 104 ObserverTest.hpp \ 105 SingletonTest.hpp \ 106 stackclassunittest.hpp \ 107 tesselationunittest.hpp \ 108 tesselation_boundarytriangleunittest.hpp \ 109 tesselation_insideoutsideunittest.hpp \ 110 vectorunittest.hpp 111 79 112 80 113 ActOnAllUnitTest_SOURCES = UnitTestMain.cpp ../test/ActOnAllTest.hpp ActOnAllUnitTest.cpp ActOnAllUnitTest.hpp … … 99 132 BondGraphUnitTest_LDADD = ${ALLLIBS} 100 133 134 CountBondsUnitTest_SOURCES = UnitTestMain.cpp CountBondsUnitTest.cpp CountBondsUnitTest.hpp 135 CountBondsUnitTest_LDADD = ${ALLLIBS} 136 101 137 GSLMatrixSymmetricUnitTest_SOURCES = UnitTestMain.cpp gslmatrixsymmetricunittest.cpp gslmatrixsymmetricunittest.hpp 102 138 GSLMatrixSymmetricUnitTest_LDADD = ${GSLLIBS} … … 114 150 LinearSystemOfEquationsUnitTest_LDADD = ${ALLLIBS} 115 151 152 LinkedCellUnitTest_SOURCES = UnitTestMain.cpp LinkedCellUnitTest.cpp LinkedCellUnitTest.hpp 153 LinkedCellUnitTest_LDADD = ${ALLLIBS} 154 116 155 ListOfBondsUnitTest_SOURCES = UnitTestMain.cpp listofbondsunittest.cpp listofbondsunittest.hpp 117 156 ListOfBondsUnitTest_LDADD = ${ALLLIBS} -
src/unittests/bondgraphunittest.cpp
r13d5a9 r5f612ee 21 21 #include "bondgraph.hpp" 22 22 #include "element.hpp" 23 #include "log.hpp" 23 24 #include "molecule.hpp" 24 25 #include "periodentafel.hpp" … … 48 49 hydrogen = new element; 49 50 hydrogen->Z = 1; 51 hydrogen->CovalentRadius = 0.23; 52 hydrogen->VanDerWaalsRadius = 1.09; 50 53 strcpy(hydrogen->name, "hydrogen"); 51 54 strcpy(hydrogen->symbol, "H"); 52 55 carbon = new element; 53 56 carbon->Z = 2; 57 carbon->CovalentRadius = 0.68; 58 carbon->VanDerWaalsRadius = 1.7; 54 59 strcpy(carbon->name, "carbon"); 55 60 strcpy(carbon->symbol, "C"); … … 64 69 TestMolecule = World::getInstance().createMolecule(); 65 70 Walker = World::getInstance().createAtom(); 66 Walker->type = hydrogen;71 Walker->type = carbon; 67 72 Walker->node->Init(1., 0., 1. ); 68 73 TestMolecule->AddAtom(Walker); 69 74 Walker = World::getInstance().createAtom(); 70 Walker->type = hydrogen;75 Walker->type = carbon; 71 76 Walker->node->Init(0., 1., 1. ); 72 77 TestMolecule->AddAtom(Walker); 73 78 Walker = World::getInstance().createAtom(); 74 Walker->type = hydrogen;79 Walker->type = carbon; 75 80 Walker->node->Init(1., 1., 0. ); 76 81 TestMolecule->AddAtom(Walker); 77 82 Walker = World::getInstance().createAtom(); 78 Walker->type = hydrogen;83 Walker->type = carbon; 79 84 Walker->node->Init(0., 0., 0. ); 80 85 TestMolecule->AddAtom(Walker); … … 84 89 85 90 // create a small file with table 91 dummyname = new string("dummy.dat"); 86 92 filename = new string("test.dat"); 87 93 ofstream test(filename->c_str()); … … 99 105 remove(filename->c_str()); 100 106 delete(filename); 107 delete(dummyname); 101 108 delete(BG); 102 109 … … 122 129 /** UnitTest for BondGraphTest::ConstructBondGraph(). 123 130 */ 124 void BondGraphTest::ConstructGraph Test()131 void BondGraphTest::ConstructGraphFromTableTest() 125 132 { 126 133 atom *Walker = TestMolecule->start->next; … … 131 138 CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) ); 132 139 }; 140 141 /** UnitTest for BondGraphTest::ConstructBondGraph(). 142 */ 143 void BondGraphTest::ConstructGraphFromCovalentRadiiTest() 144 { 145 atom *Walker = TestMolecule->start->next; 146 atom *Runner = TestMolecule->end->previous; 147 CPPUNIT_ASSERT( TestMolecule->end != Walker ); 148 CPPUNIT_ASSERT_EQUAL( false , BG->LoadBondLengthTable(*dummyname) ); 149 CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule) ); 150 CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) ); 151 }; 152 -
src/unittests/bondgraphunittest.hpp
r13d5a9 r5f612ee 23 23 CPPUNIT_TEST_SUITE( BondGraphTest) ; 24 24 CPPUNIT_TEST ( LoadTableTest ); 25 CPPUNIT_TEST ( ConstructGraphTest ); 25 CPPUNIT_TEST ( ConstructGraphFromTableTest ); 26 CPPUNIT_TEST ( ConstructGraphFromCovalentRadiiTest ); 26 27 CPPUNIT_TEST_SUITE_END(); 27 28 … … 30 31 void tearDown(); 31 32 void LoadTableTest(); 32 void ConstructGraphTest(); 33 void ConstructGraphFromTableTest(); 34 void ConstructGraphFromCovalentRadiiTest(); 33 35 34 36 private: … … 41 43 BondGraph *BG; 42 44 string *filename; 45 string *dummyname; 43 46 }; 44 47 -
src/unittests/gslvectorunittest.cpp
r13d5a9 r5f612ee 117 117 CPPUNIT_ASSERT_EQUAL( (double)(3-j), v->Get(j) ); 118 118 }; 119 120 /** UnitTest for operators. 121 */ 122 void GSLVectorTest::OperatorIsTest() 123 { 124 GSLVector zero(3); 125 GSLVector unit(3); 126 zero.SetZero(); 127 unit.SetZero(); 128 unit.Set(1,1.); 129 // summation and scaling 130 CPPUNIT_ASSERT_EQUAL( true, unit.IsOne() ); 131 CPPUNIT_ASSERT_EQUAL( false, zero.IsOne() ); 132 CPPUNIT_ASSERT_EQUAL( false, unit.IsZero() ); 133 CPPUNIT_ASSERT_EQUAL( true, zero.IsZero() ); 134 }; 135 136 /** UnitTest for operators. 137 */ 138 void GSLVectorTest::OperatorAlgebraTest() 139 { 140 GSLVector zero(3); 141 GSLVector unit(3); 142 zero.SetZero(); 143 unit.SetZero(); 144 unit.Set(1,1.); 145 // summation and scaling 146 CPPUNIT_ASSERT_EQUAL( true, (zero+unit).IsOne() ); 147 CPPUNIT_ASSERT_EQUAL( true, (zero+unit).IsOne() ); 148 CPPUNIT_ASSERT_EQUAL( true, (zero-unit).IsOne() ); 149 CPPUNIT_ASSERT_EQUAL( false, (zero-unit).IsZero() ); 150 CPPUNIT_ASSERT_EQUAL( true, (zero+zero).IsZero() ); 151 CPPUNIT_ASSERT_EQUAL( false, (unit*0.98).IsOne() ); 152 CPPUNIT_ASSERT_EQUAL( false, (0.98*unit).IsOne() ); 153 CPPUNIT_ASSERT_EQUAL( true, (unit*1.).IsOne() ); 154 CPPUNIT_ASSERT_EQUAL( true, (1.*unit).IsOne() ); 155 156 CPPUNIT_ASSERT_EQUAL( unit, (zero+unit) ); 157 CPPUNIT_ASSERT_EQUAL( zero, (zero+zero) ); 158 CPPUNIT_ASSERT_EQUAL( unit, (unit+zero) ); 159 160 unit += zero; 161 CPPUNIT_ASSERT_EQUAL( true, unit.IsOne() ); 162 unit *= 1.; 163 CPPUNIT_ASSERT_EQUAL( true, unit.IsOne() ); 164 }; -
src/unittests/gslvectorunittest.hpp
r13d5a9 r5f612ee 22 22 CPPUNIT_TEST (CopyTest ); 23 23 CPPUNIT_TEST (ExchangeTest ); 24 CPPUNIT_TEST (OperatorAlgebraTest ); 25 CPPUNIT_TEST (OperatorIsTest ); 24 26 CPPUNIT_TEST_SUITE_END(); 25 27 … … 32 34 void CopyTest(); 33 35 void ExchangeTest(); 36 void OperatorIsTest(); 37 void OperatorAlgebraTest(); 34 38 35 39 private: -
src/unittests/logunittest.cpp
r13d5a9 r5f612ee 41 41 { 42 42 logger::getInstance().setVerbosity(2); 43 Log() << Verbose(0) << "Verbosity level is set to 2." << endl;44 Log() << Verbose(0) << "Test level 0" << endl;45 Log() << Verbose(1) << "Test level 1" << endl;46 Log() << Verbose(2) << "Test level 2" << endl;47 Log() << Verbose(3) << "Test level 3" << endl;48 Log() << Verbose(4) << "Test level 4" << endl;43 DoLog(0) && (Log() << Verbose(0) << "Verbosity level is set to 2." << endl); 44 DoLog(0) && (Log() << Verbose(0) << "Test level 0" << endl); 45 DoLog(1) && (Log() << Verbose(1) << "Test level 1" << endl); 46 DoLog(2) && (Log() << Verbose(2) << "Test level 2" << endl); 47 DoLog(3) && (Log() << Verbose(3) << "Test level 3" << endl); 48 DoLog(4) && (Log() << Verbose(4) << "Test level 4" << endl); 49 49 50 Log() << Verbose(0) << "Output a log message." << endl;51 eLog() << Verbose(0) << "Output an error message." << endl;50 DoLog(0) && (Log() << Verbose(0) << "Output a log message." << endl); 51 DoeLog(0) && (eLog()<< Verbose(0) << "Output an error message." << endl); 52 52 setVerbosity(3); 53 Log() << Verbose(4) << "This should not be printed." << endl;54 eLog() << Verbose(4) << "This should not be printed." << endl;53 DoLog(4) && (Log() << Verbose(4) << "This should not be printed." << endl); 54 DoeLog(4) && (eLog()<< Verbose(4) << "This should not be printed." << endl); 55 55 }; -
src/unittests/memoryallocatorunittest.cpp
r13d5a9 r5f612ee 52 52 char* buffer3 = NULL; 53 53 buffer3 = Malloc<char>(4, ""); 54 Log() << Verbose(0) << buffer3 << endl;54 DoLog(0) && (Log() << Verbose(0) << buffer3 << endl); 55 55 Free(&buffer3); 56 56 -
src/unittests/tesselation_boundarytriangleunittest.hpp
r13d5a9 r5f612ee 36 36 class BoundaryPointSet *points[3]; 37 37 class TesselPoint *tesselpoints[3]; 38 Linked Nodes Corners;38 LinkedCell::LinkedNodes Corners; 39 39 }; 40 40 -
src/unittests/tesselation_insideoutsideunittest.cpp
r13d5a9 r5f612ee 98 98 while ((!TesselStruct->OpenLines.empty()) && (OneLoopWithoutSuccessFlag)) { 99 99 // 2a. fill all new OpenLines 100 Log() << Verbose(1) << "There are " << TesselStruct->OpenLines.size() << " open lines to scan for candidates:" << endl;100 DoLog(1) && (Log() << Verbose(1) << "There are " << TesselStruct->OpenLines.size() << " open lines to scan for candidates:" << endl); 101 101 for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) 102 Log() << Verbose(2) << *(Runner->second) << endl;102 DoLog(2) && (Log() << Verbose(2) << *(Runner->second) << endl); 103 103 104 104 for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) { … … 106 106 if (baseline->pointlist.empty()) { 107 107 T = (((baseline->BaseLine->triangles.begin()))->second); 108 Log() << Verbose(1) << "Finding best candidate for open line " << *baseline->BaseLine << " of triangle " << *T << endl;108 DoLog(1) && (Log() << Verbose(1) << "Finding best candidate for open line " << *baseline->BaseLine << " of triangle " << *T << endl); 109 109 TesselationFailFlag = TesselStruct->FindNextSuitableTriangle(*baseline, *T, SPHERERADIUS, LinkedList); //the line is there, so there is a triangle, but only one. 110 110 } … … 113 113 // 2b. search for smallest ShortestAngle among all candidates 114 114 double ShortestAngle = 4.*M_PI; 115 Log() << Verbose(1) << "There are " << TesselStruct->OpenLines.size() << " open lines to scan for the best candidates:" << endl;115 DoLog(1) && (Log() << Verbose(1) << "There are " << TesselStruct->OpenLines.size() << " open lines to scan for the best candidates:" << endl); 116 116 for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) 117 Log() << Verbose(2) << *(Runner->second) << endl;117 DoLog(2) && (Log() << Verbose(2) << *(Runner->second) << endl); 118 118 119 119 for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) { … … 127 127 OneLoopWithoutSuccessFlag = false; 128 128 else { 129 TesselStruct->AddCandidate Triangle(*baseline);129 TesselStruct->AddCandidatePolygon(*baseline, SPHERERADIUS, LinkedList); 130 130 } 131 131 } … … 137 137 delete(LinkedList); 138 138 delete(TesselStruct); 139 for (Linked Nodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) {139 for (LinkedCell::LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) { 140 140 delete((*Runner)->node); 141 141 delete(*Runner); -
src/unittests/tesselation_insideoutsideunittest.hpp
r13d5a9 r5f612ee 31 31 private: 32 32 class Tesselation *TesselStruct; 33 Linked Nodes Corners;33 LinkedCell::LinkedNodes Corners; 34 34 class LinkedCell *LinkedList; 35 35 }; -
src/unittests/tesselationunittest.cpp
r13d5a9 r5f612ee 95 95 OneLoopWithoutSuccessFlag = false; 96 96 else { 97 TesselStruct->AddCandidate Triangle(*baseline);97 TesselStruct->AddCandidatePolygon(*baseline, SPHERERADIUS, LinkedList); 98 98 } 99 99 } … … 105 105 delete(LinkedList); 106 106 delete(TesselStruct); 107 for (Linked Nodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) {107 for (LinkedCell::LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) { 108 108 delete((*Runner)->node); 109 109 delete(*Runner); -
src/unittests/tesselationunittest.hpp
r13d5a9 r5f612ee 34 34 private: 35 35 class Tesselation *TesselStruct; 36 Linked Nodes Corners;36 LinkedCell::LinkedNodes Corners; 37 37 class LinkedCell *LinkedList; 38 38 };
Note:
See TracChangeset
for help on using the changeset viewer.