Ignore:
Timestamp:
Oct 17, 2013, 7:14:21 AM (12 years ago)
Author:
Frederik Heber <heber@…>
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)
Message:

Added (in)equality operators to all SetValues.

Location:
src/Fragmentation/Summation/SetValues/unittests
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/Summation/SetValues/unittests/FragmentUnitTest.cpp

    re0ae58d r955051  
    235235  CPPUNIT_ASSERT( otherfragment == otherfragment );
    236236  CPPUNIT_ASSERT( emptyfragment == emptyfragment );
     237
     238  // check against ZeroInstance
     239  CPPUNIT_ASSERT( *fragment != ZeroInstance<Fragment>() );
     240  CPPUNIT_ASSERT( otherfragment != ZeroInstance<Fragment>() );
    237241}
    238242
  • src/Fragmentation/Summation/SetValues/unittests/HistogramUnitTest.cpp

    re0ae58d r955051  
    318318}
    319319
     320/** UnitTest for operator==()
     321 */
     322void 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  
    3333    CPPUNIT_TEST ( operatorPlusEqual_Test );
    3434    CPPUNIT_TEST ( operatorMinusEqual_Test );
     35    CPPUNIT_TEST ( equality_Test );
    3536    CPPUNIT_TEST_SUITE_END();
    3637
     
    4748      void operatorPlusEqual_Test();
    4849      void operatorMinusEqual_Test();
     50      void equality_Test();
    4951
    5052private:
  • src/Fragmentation/Summation/SetValues/unittests/IndexedVectorsUnitTest.cpp

    re0ae58d r955051  
    183183}
    184184
     185
     186/** UnitTest for operator==()
     187 */
     188void 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  
    2727    CPPUNIT_TEST ( operatorPlusEqual_Test );
    2828    CPPUNIT_TEST ( operatorMinusEqual_Test );
     29    CPPUNIT_TEST ( equality_Test );
    2930    CPPUNIT_TEST_SUITE_END();
    3031
     
    3536      void operatorPlusEqual_Test();
    3637      void operatorMinusEqual_Test();
     38      void equality_Test();
    3739
    3840private:
  • src/Fragmentation/Summation/SetValues/unittests/Makefile.am

    re0ae58d r955051  
    33
    44FRAGMENTATIONSETVALUESTESTSSOURCES = \
     5        ../Fragmentation/Summation/SetValues/unittests/EigenvaluesUnitTest.cpp \
    56        ../Fragmentation/Summation/SetValues/unittests/FragmentUnitTest.cpp \
    67        ../Fragmentation/Summation/SetValues/unittests/HistogramUnitTest.cpp \
     
    1011
    1112FRAGMENTATIONSETVALUESTESTSHEADERS = \
     13        ../Fragmentation/Summation/SetValues/unittests/EigenvaluesUnitTest.hpp \
    1214        ../Fragmentation/Summation/SetValues/unittests/FragmentUnitTest.hpp \
    1315        ../Fragmentation/Summation/SetValues/unittests/HistogramUnitTest.hpp \
     
    1719
    1820FRAGMENTATIONSETVALUESTESTS = \
     21        EigenvaluesUnitTest \
    1922        FragmentUnitTest \
    2023        HistogramUnitTest \
     
    3134        ${CodePatterns_LIBS} \
    3235        $(BOOST_LIB)
     36
     37EigenvaluesUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
     38        ../Fragmentation/Summation/SetValues/unittests/EigenvaluesUnitTest.cpp \
     39        ../Fragmentation/Summation/SetValues/unittests/EigenvaluesUnitTest.hpp
     40EigenvaluesUnitTest_LDADD = \
     41        ${FRAGMENTATIONSETVALUESLIBS} \
     42        $(BOOST_SERIALIZATION_LDFLAGS) $(BOOST_SERIALIZATION_LIBS)
    3343
    3444FragmentUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
  • src/Fragmentation/Summation/SetValues/unittests/SamplingGridPropertiesUnitTest.cpp

    re0ae58d r955051  
    3939#include <cppunit/extensions/TestFactoryRegistry.h>
    4040#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>
    4145
    4246#include "SamplingGridPropertiesUnitTest.hpp"
     
    123127  CPPUNIT_ASSERT( *props != moreotherprops );
    124128  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>() );
    125136}
    126137
     138
     139/** UnitTest for serialization
     140 */
     141void 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  
    2626    CPPUNIT_TEST ( isCompatible_Test );
    2727    CPPUNIT_TEST ( equality_Test );
     28    CPPUNIT_TEST ( serializeTest );
    2829    CPPUNIT_TEST_SUITE_END();
    2930
     
    3334      void isCompatible_Test();
    3435      void equality_Test();
     36      void serializeTest();
    3537
    3638private:
  • src/Fragmentation/Summation/SetValues/unittests/SamplingGridUnitTest.cpp

    re0ae58d r955051  
    3939#include <cppunit/extensions/TestFactoryRegistry.h>
    4040#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>
    4145
    4246#include "SamplingGridUnitTest.hpp"
     
    131135
    132136  // 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. };
    135139  const double otherbegin_window[3] = { 0.45, 0.45, 0.45 };
    136140  const double otherend_window[3] = { 1.05, 1.05, 1.05 };
     
    422426}
    423427
     428
     429/** UnitTest for operator==()
     430 */
     431void 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 */
     499void 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  
    3535    CPPUNIT_TEST ( addOntoWindow_Test );
    3636    CPPUNIT_TEST ( addOntoWindow_asymmetric_Test );
     37    CPPUNIT_TEST ( equality_Test );
     38    CPPUNIT_TEST ( serializeTest );
    3739    CPPUNIT_TEST_SUITE_END();
    3840
     
    5153      void operatorPlusEqual_Test();
    5254      void operatorMinusEqual_Test();
     55      void equality_Test();
     56      void serializeTest();
    5357
    5458private:
Note: See TracChangeset for help on using the changeset viewer.