Changeset 955051
- Timestamp:
- Oct 17, 2013, 7:14:21 AM (11 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:
- 58952a
- Parents:
- e0ae58d
- git-author:
- Frederik Heber <heber@…> (09/27/13 11:25:35)
- git-committer:
- Frederik Heber <heber@…> (10/17/13 07:14:21)
- Location:
- src/Fragmentation/Summation/SetValues
- Files:
-
- 2 added
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/Summation/SetValues/Eigenvalues.cpp
re0ae58d r955051 98 98 } 99 99 100 bool Eigenvalues::operator==(const Eigenvalues& other) const 101 { 102 bool status = true; 103 status &= addedsamples == other.addedsamples; 104 status &= subtractedsamples == other.subtractedsamples; 105 return status; 106 } 107 100 108 template<> Eigenvalues ZeroInstance<Eigenvalues>() 101 109 { -
src/Fragmentation/Summation/SetValues/Eigenvalues.hpp
re0ae58d r955051 20 20 class Eigenvalues 21 21 { 22 //!> grant unit test access to private parts 23 friend class EigenvaluesTest; 24 //!> grant output operator access 25 friend std::ostream & operator<<(std::ostream &ost, const Eigenvalues &eigenvalues); 22 26 public: 23 27 //!> named type for a vector of sample values 24 28 typedef std::vector<double> samples_t; 25 //!> grant output operator access26 friend std::ostream & operator<<(std::ostream &ost, const Eigenvalues &eigenvalues);27 29 public: 28 30 /** Default constructor for class Eigenvalues. … … 71 73 // } 72 74 75 /** Equality operator. 76 * 77 * @param other other instance to check against 78 * @return true - both are equal, false - some eigenvalues differ 79 */ 80 bool operator==(const Eigenvalues& other) const; 81 82 bool operator!=(const Eigenvalues& other) const 83 { 84 return (!(*this == other)); 85 } 86 73 87 private: 74 88 //!> typedef for the internal container format -
src/Fragmentation/Summation/SetValues/Histogram.cpp
re0ae58d r955051 107 107 const_cast<BinLowerEnd &>(offset) = *samples.begin(); 108 108 // set binwidth to statistical sensible value 109 MinMax_t MinMax = getMinMaxFromSamples(samples);109 // MinMax_t MinMax = getMinMaxFromSamples(samples); 110 110 // const_cast<double &>(binwidth) = (*(MinMax.second) - *(MinMax.first))/pow(samples.size(), 1./3.); 111 111 // and add all samples to these histogram bins 112 addSamples(samples);113 }112 } 113 addSamples(samples); 114 114 } 115 115 … … 185 185 } 186 186 LOG(3, "DEBUG: Bins after adding empties before start are " << printBins() << "."); 187 loweriter = getLowerEndBin(LowerEnd);188 ASSERT( loweriter != bins.end(),189 "Histogram::extendMissingBins() - still no lower bound after adding empties.");190 187 } 191 188 if (upperiter == bins.end()) { … … 198 195 } 199 196 LOG(3, "DEBUG: Bins after adding empties after end are " << printBins() << "."); 200 upperiter = getHigherEndBin(NextLowerEnd); 201 ASSERT( upperiter != bins.end(), 202 "Histogram::extendMissingBins() - still no upper bound after adding empties."); 203 } 197 } 198 loweriter = getLowerEndBin(LowerEnd); 199 ASSERT( loweriter != bins.end(), 200 "Histogram::extendMissingBins() - still no lower bound after adding empties."); 201 upperiter = getHigherEndBin(NextLowerEnd); 202 ASSERT( upperiter != bins.end(), 203 "Histogram::extendMissingBins() - still no upper bound after adding empties."); 204 204 } 205 205 … … 347 347 } 348 348 349 bool Histogram::operator==(const Histogram& other) const 350 { 351 bool status = true; 352 status &= binwidth == other.binwidth; 353 status &= offset == other.offset; 354 status &= bins == other.bins; 355 return status; 356 } 357 349 358 template<> Histogram ZeroInstance<Histogram>() 350 359 { -
src/Fragmentation/Summation/SetValues/Histogram.hpp
re0ae58d r955051 126 126 void addSamples(const samples_t &samples); 127 127 128 /** Equality operator. 129 * 130 * @param other other instance to check against 131 * @return true - both are equal, false - some bins differ 132 */ 133 bool operator==(const Histogram& other) const; 134 135 bool operator!=(const Histogram& other) const 136 { 137 return (!(*this == other)); 138 } 139 128 140 private: 129 141 /** Returns the iterator to the bin representing the lower end into which the \a value fits. -
src/Fragmentation/Summation/SetValues/IndexedVectors.cpp
re0ae58d r955051 103 103 } 104 104 105 bool IndexedVectors::operator==(const IndexedVectors& other) const 106 { 107 bool status = vectors == other.vectors; 108 return status; 109 } 110 105 111 std::ostream & operator<<(std::ostream &ost, const IndexedVectors &other) 106 112 { -
src/Fragmentation/Summation/SetValues/IndexedVectors.hpp
re0ae58d r955051 102 102 { return vectors; } 103 103 104 /** Equality operator. 105 * 106 * @param other other instance to check against 107 * @return true - both are equal, false - some IndexedVectors differ 108 */ 109 bool operator==(const IndexedVectors& other) const; 110 111 bool operator!=(const IndexedVectors& other) const 112 { 113 return (!(*this == other)); 114 } 115 104 116 private: 105 117 /** Helper function that contains all the logic of how to superpose two -
src/Fragmentation/Summation/SetValues/SamplingGrid.cpp
re0ae58d r955051 266 266 const double value, const size_t axis) const 267 267 { 268 const double length = end[axis] - begin[axis];268 const double length = getTotalLengthPerAxis(axis); 269 269 if ((fabs(length) < std::numeric_limits<double>::epsilon()) || (getGridPointsPerAxis() == 0)) 270 270 return begin[axis]; 271 if ( value > end[axis])271 if ((value - end[axis]) > -std::numeric_limits<double>::epsilon()*1.e4) 272 272 return end[axis]; 273 273 const double offset = value - begin[axis]; 274 if (offset < 0)274 if (offset < std::numeric_limits<double>::epsilon()*1.e4) 275 275 return begin[axis]; 276 276 // modify value a little if value actually has been on a grid point but … … 279 279 floor((double)getGridPointsPerAxis()*(offset/length) 280 280 +std::numeric_limits<double>::epsilon()*1.e4); 281 return factor*(length/(double)getGridPointsPerAxis());281 return begin[axis]+factor*getDeltaPerAxis(axis); 282 282 } 283 283 … … 285 285 const double value, const size_t axis) const 286 286 { 287 const double length = end[axis] - begin[axis];287 const double length = getTotalLengthPerAxis(axis); 288 288 if ((fabs(length) < std::numeric_limits<double>::epsilon()) || (getGridPointsPerAxis() == 0)) 289 289 return end[axis]; 290 if ( value > end[axis])290 if ((value - end[axis]) > -std::numeric_limits<double>::epsilon()*1.e4) 291 291 return end[axis]; 292 292 const double offset = value - begin[axis]; 293 if (offset < 0)293 if (offset < std::numeric_limits<double>::epsilon()*1.e4) 294 294 return begin[axis]; 295 295 // modify value a little if value actually has been on a grid point but … … 298 298 ceil((double)getGridPointsPerAxis()*(offset/length) 299 299 -std::numeric_limits<double>::epsilon()*1.e4); 300 return factor*(length/(double)getGridPointsPerAxis());300 return begin[axis]+factor*getDeltaPerAxis(axis); 301 301 } 302 302 … … 605 605 } 606 606 607 608 bool SamplingGrid::operator==(const SamplingGrid &other) const 609 { 610 bool status = 611 static_cast<const SamplingGridProperties &>(*this) 612 == static_cast<const SamplingGridProperties &>(other); 613 // compare general properties 614 if (status) { 615 // compare windows 616 for (size_t i=0; i<3; ++i) { 617 status &= begin_window[i] == other.begin_window[i]; 618 status &= end_window[i] == other.end_window[i]; 619 } 620 // compare grids 621 if (status) 622 status &= sampled_grid == other.sampled_grid; 623 } 624 return status; 625 } 626 607 627 std::ostream & operator<<(std::ostream &ost, const SamplingGrid& other) 608 628 { -
src/Fragmentation/Summation/SetValues/SamplingGrid.hpp
re0ae58d r955051 22 22 23 23 #include "Fragmentation/Summation/SetValues/SamplingGridProperties.hpp" 24 #include "Fragmentation/Summation/ZeroInstance.hpp" 24 25 25 26 class MPQCData; … … 221 222 size_t *total) const; 222 223 224 /** Equality operator. 225 * 226 * @param other other instance to check against 227 * @return true - both are equal, false - grids differ 228 */ 229 bool operator==(const SamplingGrid& other) const; 230 231 bool operator!=(const SamplingGrid& other) const 232 { 233 return (!(*this == other)); 234 } 235 223 236 private: 224 237 /** Sets the size of the domain. … … 394 407 std::ostream & operator<<(std::ostream &ost, const SamplingGrid& other); 395 408 396 template<typename T> T ZeroInstance();397 409 template<> SamplingGrid ZeroInstance<SamplingGrid>(); 398 410 -
src/Fragmentation/Summation/SetValues/SamplingGridProperties.cpp
re0ae58d r955051 100 100 } 101 101 102 103 template<> SamplingGridProperties ZeroInstance<SamplingGridProperties>() 104 { 105 SamplingGridProperties returnvalue; 106 return returnvalue; 107 } 108 102 109 // we need to explicitly instantiate the serialization functions as 103 110 // its is only serialized through its base class FragmentJob -
src/Fragmentation/Summation/SetValues/SamplingGridProperties.hpp
re0ae58d r955051 16 16 #include "boost/serialization/export.hpp" 17 17 #include "boost/serialization/array.hpp" 18 19 #include "Fragmentation/Summation/ZeroInstance.hpp" 18 20 19 21 /** This class stores a sample function on a three-dimensional grid. … … 136 138 }; 137 139 140 template<> SamplingGridProperties ZeroInstance<SamplingGridProperties>(); 141 138 142 // we need to give this class a unique key for serialization 139 143 // its is only serialized through its base class FragmentJob -
src/Fragmentation/Summation/SetValues/SamplingGridProperties_inline.hpp
re0ae58d r955051 61 61 } 62 62 63 64 63 #endif /* SAMPLINGGRIDPROPERTIES_INLINE_HPP_ */ -
src/Fragmentation/Summation/SetValues/unittests/FragmentUnitTest.cpp
re0ae58d r955051 235 235 CPPUNIT_ASSERT( otherfragment == otherfragment ); 236 236 CPPUNIT_ASSERT( emptyfragment == emptyfragment ); 237 238 // check against ZeroInstance 239 CPPUNIT_ASSERT( *fragment != ZeroInstance<Fragment>() ); 240 CPPUNIT_ASSERT( otherfragment != ZeroInstance<Fragment>() ); 237 241 } 238 242 -
src/Fragmentation/Summation/SetValues/unittests/HistogramUnitTest.cpp
re0ae58d r955051 318 318 } 319 319 320 /** UnitTest for operator==() 321 */ 322 void HistogramTest::equality_Test() 323 { 324 Histogram::samples_t sampled_values; 325 sampled_values += 1.,2.,3.,4.; 326 histogram = new Histogram(sampled_values, 1., 1.); 327 328 // create different histogram 329 Histogram::samples_t more_values; 330 more_values += 0.5, 1.25, 2.5,3., 4.2; 331 Histogram otherhistogram(more_values, 0.5, .625); 332 333 CPPUNIT_ASSERT( !(*histogram == otherhistogram) ); 334 CPPUNIT_ASSERT( *histogram != otherhistogram ); 335 336 // test against empty histogram 337 Histogram emptyhistogram; 338 CPPUNIT_ASSERT( !(*histogram == emptyhistogram) ); 339 CPPUNIT_ASSERT( *histogram != emptyhistogram ); 340 341 // tests against themselves 342 CPPUNIT_ASSERT( *histogram == *histogram ); 343 CPPUNIT_ASSERT( otherhistogram == otherhistogram ); 344 CPPUNIT_ASSERT( emptyhistogram == emptyhistogram ); 345 346 // check against ZeroInstance 347 CPPUNIT_ASSERT( *histogram != ZeroInstance<Histogram>() ); 348 CPPUNIT_ASSERT( otherhistogram != ZeroInstance<Histogram>() ); 349 } -
src/Fragmentation/Summation/SetValues/unittests/HistogramUnitTest.hpp
re0ae58d r955051 33 33 CPPUNIT_TEST ( operatorPlusEqual_Test ); 34 34 CPPUNIT_TEST ( operatorMinusEqual_Test ); 35 CPPUNIT_TEST ( equality_Test ); 35 36 CPPUNIT_TEST_SUITE_END(); 36 37 … … 47 48 void operatorPlusEqual_Test(); 48 49 void operatorMinusEqual_Test(); 50 void equality_Test(); 49 51 50 52 private: -
src/Fragmentation/Summation/SetValues/unittests/IndexedVectorsUnitTest.cpp
re0ae58d r955051 183 183 } 184 184 185 186 /** UnitTest for operator==() 187 */ 188 void IndexedVectorsTest::equality_Test() 189 { 190 CPPUNIT_ASSERT( !(*ivectors == *otherivectors) ); 191 CPPUNIT_ASSERT( *ivectors != *otherivectors ); 192 193 // test against empty ivectors 194 IndexedVectors emptyivectors; 195 CPPUNIT_ASSERT( !(*ivectors == emptyivectors) ); 196 CPPUNIT_ASSERT( *ivectors != emptyivectors ); 197 198 // tests against themselves 199 CPPUNIT_ASSERT( *ivectors == *ivectors ); 200 CPPUNIT_ASSERT( *otherivectors == *otherivectors ); 201 CPPUNIT_ASSERT( emptyivectors == emptyivectors ); 202 203 // check against ZeroInstance 204 CPPUNIT_ASSERT( *ivectors != ZeroInstance<IndexedVectors>() ); 205 CPPUNIT_ASSERT( *otherivectors != ZeroInstance<IndexedVectors>() ); 206 } -
src/Fragmentation/Summation/SetValues/unittests/IndexedVectorsUnitTest.hpp
re0ae58d r955051 27 27 CPPUNIT_TEST ( operatorPlusEqual_Test ); 28 28 CPPUNIT_TEST ( operatorMinusEqual_Test ); 29 CPPUNIT_TEST ( equality_Test ); 29 30 CPPUNIT_TEST_SUITE_END(); 30 31 … … 35 36 void operatorPlusEqual_Test(); 36 37 void operatorMinusEqual_Test(); 38 void equality_Test(); 37 39 38 40 private: -
src/Fragmentation/Summation/SetValues/unittests/Makefile.am
re0ae58d r955051 3 3 4 4 FRAGMENTATIONSETVALUESTESTSSOURCES = \ 5 ../Fragmentation/Summation/SetValues/unittests/EigenvaluesUnitTest.cpp \ 5 6 ../Fragmentation/Summation/SetValues/unittests/FragmentUnitTest.cpp \ 6 7 ../Fragmentation/Summation/SetValues/unittests/HistogramUnitTest.cpp \ … … 10 11 11 12 FRAGMENTATIONSETVALUESTESTSHEADERS = \ 13 ../Fragmentation/Summation/SetValues/unittests/EigenvaluesUnitTest.hpp \ 12 14 ../Fragmentation/Summation/SetValues/unittests/FragmentUnitTest.hpp \ 13 15 ../Fragmentation/Summation/SetValues/unittests/HistogramUnitTest.hpp \ … … 17 19 18 20 FRAGMENTATIONSETVALUESTESTS = \ 21 EigenvaluesUnitTest \ 19 22 FragmentUnitTest \ 20 23 HistogramUnitTest \ … … 31 34 ${CodePatterns_LIBS} \ 32 35 $(BOOST_LIB) 36 37 EigenvaluesUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \ 38 ../Fragmentation/Summation/SetValues/unittests/EigenvaluesUnitTest.cpp \ 39 ../Fragmentation/Summation/SetValues/unittests/EigenvaluesUnitTest.hpp 40 EigenvaluesUnitTest_LDADD = \ 41 ${FRAGMENTATIONSETVALUESLIBS} \ 42 $(BOOST_SERIALIZATION_LDFLAGS) $(BOOST_SERIALIZATION_LIBS) 33 43 34 44 FragmentUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \ -
src/Fragmentation/Summation/SetValues/unittests/SamplingGridPropertiesUnitTest.cpp
re0ae58d r955051 39 39 #include <cppunit/extensions/TestFactoryRegistry.h> 40 40 #include <cppunit/ui/text/TestRunner.h> 41 42 // include headers that implement a archive in simple text format 43 #include <boost/archive/text_oarchive.hpp> 44 #include <boost/archive/text_iarchive.hpp> 41 45 42 46 #include "SamplingGridPropertiesUnitTest.hpp" … … 123 127 CPPUNIT_ASSERT( *props != moreotherprops ); 124 128 CPPUNIT_ASSERT( moreotherprops != *props ); 129 130 // check against ZeroInstance 131 CPPUNIT_ASSERT( *props != ZeroInstance<SamplingGridProperties>() ); 132 CPPUNIT_ASSERT( sameprops != ZeroInstance<SamplingGridProperties>() ); 133 CPPUNIT_ASSERT( otherprops != ZeroInstance<SamplingGridProperties>() ); 134 CPPUNIT_ASSERT( anotherprops != ZeroInstance<SamplingGridProperties>() ); 135 CPPUNIT_ASSERT( moreotherprops != ZeroInstance<SamplingGridProperties>() ); 125 136 } 126 137 138 139 /** UnitTest for serialization 140 */ 141 void SamplingGridPropertiesTest::serializeTest() 142 { 143 // serialize 144 std::stringstream outputstream; 145 boost::archive::text_oarchive oa(outputstream); 146 oa << props; 147 148 // deserialize 149 SamplingGridProperties *sameprops = NULL; 150 std::stringstream returnstream(outputstream.str()); 151 boost::archive::text_iarchive ia(returnstream); 152 ia >> sameprops; 153 154 CPPUNIT_ASSERT( sameprops != NULL ); 155 CPPUNIT_ASSERT( *props == *sameprops ); 156 157 delete sameprops; 158 } -
src/Fragmentation/Summation/SetValues/unittests/SamplingGridPropertiesUnitTest.hpp
re0ae58d r955051 26 26 CPPUNIT_TEST ( isCompatible_Test ); 27 27 CPPUNIT_TEST ( equality_Test ); 28 CPPUNIT_TEST ( serializeTest ); 28 29 CPPUNIT_TEST_SUITE_END(); 29 30 … … 33 34 void isCompatible_Test(); 34 35 void equality_Test(); 36 void serializeTest(); 35 37 36 38 private: -
src/Fragmentation/Summation/SetValues/unittests/SamplingGridUnitTest.cpp
re0ae58d r955051 39 39 #include <cppunit/extensions/TestFactoryRegistry.h> 40 40 #include <cppunit/ui/text/TestRunner.h> 41 42 // include headers that implement a archive in simple text format 43 #include <boost/archive/text_oarchive.hpp> 44 #include <boost/archive/text_iarchive.hpp> 41 45 42 46 #include "SamplingGridUnitTest.hpp" … … 131 135 132 136 // differing windows 133 const double begin_window[3] = { 0.5, 0.5, 0.5 };134 const double end_window[3] = { 1., 1., 1. };137 // const double begin_window[3] = { 0.5, 0.5, 0.5 }; 138 // const double end_window[3] = { 1., 1., 1. }; 135 139 const double otherbegin_window[3] = { 0.45, 0.45, 0.45 }; 136 140 const double otherend_window[3] = { 1.05, 1.05, 1.05 }; … … 422 426 } 423 427 428 429 /** UnitTest for operator==() 430 */ 431 void SamplingGridTest::equality_Test() 432 { 433 const double begin[3] = { 0., 0., 0. }; 434 const double otherbegin[3] = { .5, 0.1, -0.5 }; 435 const double end[3] = { 1., 1., 1. }; 436 const double otherend[3] = { 2., 2., 2. }; 437 const double begin_window[3] = { 0., 0., 0. }; 438 const double otherbegin_window[3] = { .75, 0.1, 0. }; 439 const double end_window[3] = { 1., 1., 1. }; 440 const double otherend_window[3] = { .9, .9, .9 }; 441 442 // create other grid 443 SamplingGrid samegrid(begin, end, 2, values); 444 SamplingGrid differentbegin(otherbegin, end, 2, values); 445 SamplingGrid differentend(begin, otherend, 2, values); 446 SamplingGrid::sampledvalues_t morevalues; 447 { 448 const double othergrid_value = 1.5; 449 for (size_t i=0; i< NUMBEROFSAMPLES(4); ++i) 450 morevalues += othergrid_value; 451 } 452 SamplingGrid differentlevel(begin, end, 4, morevalues); 453 SamplingGrid::sampledvalues_t othervalues; 454 { 455 const double othergrid_value = 1.5; 456 for (size_t i=0; i< NUMBEROFSAMPLES(2); ++i) 457 othervalues += othergrid_value; 458 } 459 SamplingGrid differentvalues(begin, end, 2, othervalues); 460 461 // check for same level, begin, and end 462 CPPUNIT_ASSERT( *grid == *grid ); 463 CPPUNIT_ASSERT( *grid == samegrid ); 464 CPPUNIT_ASSERT( samegrid == *grid); 465 CPPUNIT_ASSERT( *grid != differentbegin); 466 CPPUNIT_ASSERT( differentbegin != *grid); 467 CPPUNIT_ASSERT( *grid != differentend ); 468 CPPUNIT_ASSERT( differentend != *grid ); 469 CPPUNIT_ASSERT( *grid != differentlevel ); 470 CPPUNIT_ASSERT( differentlevel != *grid ); 471 472 // check for all but differing values 473 CPPUNIT_ASSERT( *grid != differentvalues ); 474 CPPUNIT_ASSERT( differentvalues != *grid ); 475 476 // check for different windows 477 SamplingGrid differentwindowbegin(begin, end, 2); 478 differentwindowbegin.setWindow(otherbegin_window, end_window); 479 SamplingGrid differentwindowend(begin, end, 2); 480 differentwindowend.setWindow(begin_window, otherend_window); 481 CPPUNIT_ASSERT( *grid != differentwindowbegin ); 482 CPPUNIT_ASSERT( differentwindowbegin != *grid ); 483 CPPUNIT_ASSERT( *grid != differentwindowend ); 484 CPPUNIT_ASSERT( differentwindowend != *grid ); 485 486 // check against ZeroInstance 487 CPPUNIT_ASSERT( *grid != ZeroInstance<SamplingGrid>() ); 488 CPPUNIT_ASSERT( samegrid != ZeroInstance<SamplingGrid>() ); 489 CPPUNIT_ASSERT( differentbegin != ZeroInstance<SamplingGrid>() ); 490 CPPUNIT_ASSERT( differentend != ZeroInstance<SamplingGrid>() ); 491 CPPUNIT_ASSERT( differentlevel != ZeroInstance<SamplingGrid>() ); 492 CPPUNIT_ASSERT( differentvalues != ZeroInstance<SamplingGrid>() ); 493 CPPUNIT_ASSERT( differentwindowbegin != ZeroInstance<SamplingGrid>() ); 494 CPPUNIT_ASSERT( differentwindowend != ZeroInstance<SamplingGrid>() ); 495 } 496 497 /** UnitTest for serialization 498 */ 499 void SamplingGridTest::serializeTest() 500 { 501 // serialize 502 std::stringstream outputstream; 503 boost::archive::text_oarchive oa(outputstream); 504 oa << grid; 505 506 // deserialize 507 SamplingGrid *samegrid = NULL; 508 std::stringstream returnstream(outputstream.str()); 509 boost::archive::text_iarchive ia(returnstream); 510 ia >> samegrid; 511 512 CPPUNIT_ASSERT( samegrid != NULL ); 513 CPPUNIT_ASSERT( *grid == *samegrid ); 514 515 delete samegrid; 516 } -
src/Fragmentation/Summation/SetValues/unittests/SamplingGridUnitTest.hpp
re0ae58d r955051 35 35 CPPUNIT_TEST ( addOntoWindow_Test ); 36 36 CPPUNIT_TEST ( addOntoWindow_asymmetric_Test ); 37 CPPUNIT_TEST ( equality_Test ); 38 CPPUNIT_TEST ( serializeTest ); 37 39 CPPUNIT_TEST_SUITE_END(); 38 40 … … 51 53 void operatorPlusEqual_Test(); 52 54 void operatorMinusEqual_Test(); 55 void equality_Test(); 56 void serializeTest(); 53 57 54 58 private:
Note:
See TracChangeset
for help on using the changeset viewer.