Changeset 3322


Ignore:
Timestamp:
Oct 6, 2014, 8:41:48 AM (7 years ago)
Author:
Peter
Message:

change name of test function to more descriptive 'avoid_compiler_warning'; test weighted_iterator_traits; refs #803

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/concepts.doxygen

    r3295 r3322  
    451451  - an unweighted iterator with value type convertible to \c double.
    452452
     453in addition
     454
     455  - \c theplu::yat::utility::weighted_iterator_traits<I> must work
     456    well, which implies that iterator, \c I is a \readable_iterator.
     457
    453458\section concept_data_iterator_implementations Implementations
    454459
  • trunk/test/Suite.h

    r3295 r3322  
    382382  // function that can be used to avoid warning: '-Wunused-but-set-variable'
    383383  template<typename T>
    384   void dummie_function(T) {}
     384  void avoid_compiler_warning(T) {}
    385385
    386386  template<class T>
     
    413413    add(tmp==*iter);
    414414    TrivialIterator default_constructed;
    415     dummie_function(default_constructed);
     415    avoid_compiler_warning(default_constructed);
    416416  }
    417417
     
    535535    size_t rows = c.rows();
    536536    // just to avoid compiler warning
    537     dummie_function(cols);
    538     dummie_function(rows);
     537    avoid_compiler_warning(cols);
     538    avoid_compiler_warning(rows);
    539539    const_reference x = c(0,0);
    540540    value_type y;
    541541    y = x;
    542     dummie_function(y);
     542    avoid_compiler_warning(y);
    543543  }
    544544
  • trunk/test/data_weight_proxy.cc

    r3114 r3322  
    121121    x = proxy.weight();
    122122    proxy.data() = proxy.weight() = 0.0;
    123     test::dummie_function(x);
     123    test::avoid_compiler_warning(x);
    124124  }
    125125
  • trunk/test/iterator.cc

    r3283 r3322  
    2424
    2525#include "Suite.h"
     26#include "weighted_iterator_archetype.h"
    2627
    2728#include "yat/classifier/DataLookup1D.h"
     
    7071void test_data_iterator(test::Suite& suite);
    7172void test_weight_iterator(test::Suite& suite);
     73void test_weighted_iterator_traits(test::Suite& suite);
    7274void test_iterator_traits(test::Suite& suite);
    7375void test_stride_iterator(test::Suite& suite);
     
    9294  test_data_iterator(suite);
    9395  test_weight_iterator(suite);
     96  test_weighted_iterator_traits(suite);
    9497  return suite.return_value();
    9598}
     
    352355
    353356
     357void test_weighted_iterator_traits(test::Suite& suite)
     358{
     359  typedef boost::iterator_archetypes::readable_iterator_t Access;
     360  typedef boost::incrementable_traversal_tag Traversal;
     361  if (false) {
     362    typedef test::weighted_iterator_archetype<Access, Traversal> I;
     363    theplu::yat::utility::weighted_iterator_traits<I>::type tag;
     364    test::avoid_compiler_warning(tag);
     365  }
     366  if (false) {
     367    typedef double Value;
     368    typedef boost::iterator_archetype<Value, Access, Traversal> I;
     369    theplu::yat::utility::weighted_iterator_traits<I>::type tag;
     370    test::avoid_compiler_warning(tag);
     371  }
     372}
     373
     374
    354375void test_iterator_traits(test::Suite& suite)
    355376{
     
    380401
    381402  // do not run compile test
    382   return;
    383   using utility::DataWeight;
    384   using utility::iterator_traits;
    385   // iterator_traits does not work with a proxy that lacks member
    386   // function data() so we test with no_proxy archetype instead.
    387   typedef boost::input_iterator_archetype_no_proxy<DataWeight> input;
    388   utility::iterator_traits<input> traits3;
    389   w = traits3.weight(input());
    390   typedef boost::output_iterator_archetype<DataWeight> output;
    391   utility::iterator_traits<output> traits4;
    392   w = traits4.weight(boost::detail::dummy_constructor());
     403  if (false) {
     404    using utility::DataWeight;
     405    using utility::iterator_traits;
     406
     407    // test unweighted iterator
     408    typedef boost::iterator_archetypes::readable_iterator_t Access;
     409    typedef boost::incrementable_traversal_tag Traversal;
     410    // test unweighted iterator
     411    {
     412      typedef double Value;
     413      typedef boost::input_iterator_archetype<Value> I;
     414      I iter;
     415      iterator_traits<I> traits;
     416      double x = traits.data(iter);
     417      x = traits.weight(iter);
     418      test::avoid_compiler_warning(x);
     419    }
     420    // test weighted iterator
     421    {
     422      typedef test::weighted_iterator_archetype<Access, Traversal> I;
     423      test::ctor_arg arg;
     424      I iter(arg);
     425      iterator_traits<I> traits;
     426      double x = traits.data(iter);
     427      test::avoid_compiler_warning(x);
     428      double w = traits.weight(iter);
     429      test::avoid_compiler_warning(w);
     430    }
     431    // test with mutable weighted
     432    {
     433      typedef
     434        boost::iterator_archetypes::readable_writable_iterator_t MutableAccess;
     435      typedef test::weighted_iterator_archetype<MutableAccess, Traversal> I;
     436      test::ctor_arg arg;
     437      I iter(arg);
     438      iterator_traits<I> traits;
     439      double x = traits.data(iter);
     440      test::avoid_compiler_warning(x);
     441      double w = traits.weight(iter);
     442      test::avoid_compiler_warning(w);
     443      // test that return types are non-const
     444      traits.data(iter) = 0.5;
     445      traits.weight(iter) = 0.5;
     446    }
     447  }
    393448}
    394449
  • trunk/test/statistics.cc

    r3236 r3322  
    8888    double x = median(boost::random_access_iterator_archetype<double>(),
    8989                      boost::random_access_iterator_archetype<double>());
    90     test::dummie_function(x);
     90    test::avoid_compiler_warning(x);
    9191    x = median(boost::random_access_iterator_archetype<utility::DataWeight>(),
    9292               boost::random_access_iterator_archetype<utility::DataWeight>());
    93     test::dummie_function(x);
     93    test::avoid_compiler_warning(x);
    9494  }
    9595  statistics::percentile2(data.begin(), data.end(), 100);
     
    117117    double x = average(boost::input_iterator_archetype<double>(),
    118118                       boost::input_iterator_archetype<double>());
    119     test::dummie_function(x);
     119    test::avoid_compiler_warning(x);
    120120    using utility::DataWeight;
    121121    x = average(boost::input_iterator_archetype_no_proxy<DataWeight>(),
    122122                boost::input_iterator_archetype_no_proxy<DataWeight>());
    123     test::dummie_function(x);
     123    test::avoid_compiler_warning(x);
    124124  }
    125125
     
    241241    double x = mad(boost::random_access_iterator_archetype<double>(),
    242242                   boost::random_access_iterator_archetype<double>());
    243     test::dummie_function(x);
     243    test::avoid_compiler_warning(x);
    244244    x = mad(boost::random_access_iterator_archetype<utility::DataWeight>(),
    245245            boost::random_access_iterator_archetype<utility::DataWeight>());
    246     test::dummie_function(x);
     246    test::avoid_compiler_warning(x);
    247247  }
    248248}
     
    278278  double m = 0;
    279279  m = statistics::median(x.begin(), x.end(), true);
    280   test::dummie_function(m);
     280  test::avoid_compiler_warning(m);
    281281}
    282282
     
    343343    typedef random_access_iterator_archetype<double> Iterator;
    344344    double x = percentiler(Iterator(), Iterator());
    345     test::dummie_function(x);
     345    test::avoid_compiler_warning(x);
    346346    using utility::DataWeight;
    347347    typedef random_access_iterator_archetype<DataWeight> WeigtedItererator;
    348348    x = percentiler(WeigtedItererator(), WeigtedItererator());
    349     test::dummie_function(x);
     349    test::avoid_compiler_warning(x);
    350350  }
    351351}
  • trunk/test/utility.cc

    r3295 r3322  
    300300  const std::map<std::string, int> m2(m);
    301301  int i = utility::get(m2, static_cast<std::string>("one"));
    302   test::dummie_function(i); // avoid compiler warning
     302  test::avoid_compiler_warning(i); // avoid compiler warning
    303303  try {
    304304    utility::get(m2, static_cast<std::string>("three"));
  • trunk/yat/utility/DataIterator.h

    r3276 r3322  
    5656     \endcode
    5757
    58     Type Requirement: \c BASE must be an \input_iterator
     58    Type Requirement:
     59    - \c BASE must model a \ref concept_data_iterator
    5960  */
    6061  template<typename Base>
  • trunk/yat/utility/iterator_traits.h

    r3188 r3322  
    2727#include "DataWeight.h"
    2828
     29#include <boost/iterator/iterator_traits.hpp>
    2930#include <boost/mpl/logical.hpp>
    3031#include <boost/type_traits/is_const.hpp>
     
    6970    */
    7071    typedef unweighted_iterator_tag type;
    71   }; 
    72 
    73   /** 
     72  };
     73
     74  /**
    7475      \internal
    7576
     
    8283     */
    8384    typedef weighted_iterator_tag type;
    84   }; 
     85  };
    8586
    8687} // namespace detail
     
    8990
    9091
    91   /** 
     92  /**
    9293      Metafunction to decide whether an Iterator is weighted or
    9394      non-weighted. This (default) implementation returns
    94       unweighted_iterator_tag, unless value_type of Iterator is
     95      unweighted_iterator_tag, unless \c value_type of Iterator is
    9596      convertible to DataWeight in which case weighted_iterator_tag is
    9697      returned.
     98
     99      Type Requirements:
     100      - \c boost::iterator_value<Iterator>::type must be defined, which is
     101      guaranteed if \c Iterator is a \readable_iterator
     102      (\c std::ostream_iterator e.g. does not work)
    97103  */
    98104  template <class Iterator>
    99   struct weighted_iterator_traits 
     105  struct weighted_iterator_traits
    100106  {
    101107  private:
    102     typedef typename std::iterator_traits<Iterator>::value_type value;
     108    typedef typename boost::iterator_value<Iterator>::type value;
    103109  public:
    104110    /**
Note: See TracChangeset for help on using the changeset viewer.