Ignore:
Timestamp:
Jun 8, 2016, 10:45:27 PM (9 years ago)
Author:
Frederik Heber <heber@…>
Children:
6369bc
Parents:
e34888
git-author:
Frederik Heber <heber@…> (06/06/16 14:28:05)
git-committer:
Frederik Heber <heber@…> (06/08/16 22:45:27)
Message:

Extended SamplingGridProperties::isCompatible() to allow more finely resolved grids, added ::isEquivalent().

  • isEquivalent contains the old check and we replaced isCompatible() by it.
File:
1 edited

Legend:

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

    re34888 rc739b3  
    8989}
    9090
    91 /** UnitTest on compatible combination of props and values
    92  */
    93 void SamplingGridTest::compatibleGrids_Test()
     91/** UnitTest on equivalent combination of props and values
     92 */
     93void SamplingGridTest::equivalentGrids_Test()
    9494{
    9595  // check illegal grid
    9696  const double begin[NDIM] = { 0., 0., 0. };
    97   const double end[NDIM] = { 2., 2., 2. };
     97  const double end[NDIM] = { 1., 1., 1. };
    9898  SamplingGridProperties illegal_props(begin, end, 5);
    9999  SamplingGridProperties legal_props(begin, end, 2);
     100  CPPUNIT_ASSERT( !grid->isEquivalent(illegal_props) );
     101  CPPUNIT_ASSERT( grid->isEquivalent(legal_props) );
     102  SamplingGrid::sampledvalues_t illegal_values;
     103  for (size_t i=0; i< NUMBEROFSAMPLES(1); ++i)
     104    illegal_values += 1.5;
     105  SamplingGrid::sampledvalues_t legal_values;
     106  for (size_t i=0; i< NUMBEROFSAMPLES(2); ++i)
     107    legal_values += 1.5;
     108#ifndef NDEBUG
     109  // throws because props and size of illegal_values don't match
     110  std::cout << "The following assertion is intended and does not indicate a failure of the test." << std::endl;
     111  CPPUNIT_ASSERT_THROW( SamplingGrid illegal_grid(illegal_props, illegal_values), Assert::AssertionFailure );
     112  std::cout << "The following assertion is intended and does not indicate a failure of the test." << std::endl;
     113  CPPUNIT_ASSERT_THROW( SamplingGrid illegal_grid(legal_props, illegal_values), Assert::AssertionFailure );
     114  std::cout << "The following assertion is intended and does not indicate a failure of the test." << std::endl;
     115  CPPUNIT_ASSERT_THROW( SamplingGrid illegal_grid(illegal_props, legal_values), Assert::AssertionFailure );
     116#endif
     117  // check that grid is still the same
     118  for (SamplingGrid::sampledvalues_t::const_iterator iter = grid->sampled_grid.begin();
     119      iter != grid->sampled_grid.end(); ++iter)
     120    CPPUNIT_ASSERT_EQUAL( grid_value, *iter );
     121}
     122
     123/** UnitTest on compatible combination of props and values
     124 */
     125void SamplingGridTest::compatibleGrids_Test()
     126{
     127  // check illegal grid
     128  const double begin[NDIM] = { 0., 0., 0. };
     129  const double end[NDIM] = { 1., 1., 1. };
     130  const double otherend[NDIM] = { 2.5, 2.5, 2.5 };
     131  SamplingGridProperties illegal_props(begin, otherend, 5);
     132  SamplingGridProperties legal_props(begin, end, 3);
    100133  CPPUNIT_ASSERT( !grid->isCompatible(illegal_props) );
    101134  CPPUNIT_ASSERT( grid->isCompatible(legal_props) );
     
    143176  SamplingGrid default_grid(legal_props);
    144177  // note that we always construct a temporary SamplingGrid from given props
    145   CPPUNIT_ASSERT( default_grid.isCompatible(illegal_begin_props) == default_grid.isCongruent(illegal_begin_props));
    146   CPPUNIT_ASSERT( default_grid.isCompatible(illegal_end_props) == default_grid.isCongruent(illegal_end_props));
    147   CPPUNIT_ASSERT( default_grid.isCompatible(illegal_level_props) == default_grid.isCongruent(illegal_level_props));
    148   CPPUNIT_ASSERT( default_grid.isCompatible(legal_props) == default_grid.isCongruent(legal_props) );
     178  CPPUNIT_ASSERT( default_grid.isEquivalent(illegal_begin_props) == default_grid.isCongruent(illegal_begin_props));
     179  CPPUNIT_ASSERT( default_grid.isEquivalent(illegal_end_props) == default_grid.isCongruent(illegal_end_props));
     180  CPPUNIT_ASSERT( default_grid.isEquivalent(illegal_level_props) == default_grid.isCongruent(illegal_level_props));
     181  CPPUNIT_ASSERT( default_grid.isEquivalent(legal_props) == default_grid.isCongruent(legal_props) );
    149182
    150183  default_grid.setWindowSize(begin, end);
Note: See TracChangeset for help on using the changeset viewer.