Changeset 3149


Ignore:
Timestamp:
Dec 23, 2013, 7:02:47 AM (7 years ago)
Author:
Peter
Message:

change test_output_iterator: there is requirement that output iterators have value_type

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/Suite.h

    r3114 r3149  
    127127    template<typename TrivialIterator>
    128128    void test_trivial_iterator(const TrivialIterator&);
    129    
     129
    130130    template<typename InputIterator>
    131131    void test_input_iterator(InputIterator&);
    132    
     132
    133133    template<typename OutputIterator>
    134134    void test_output_iterator(OutputIterator&);
    135  
     135
    136136    template<typename ForwardIterator>
    137137    void test_forward_iterator(ForwardIterator);
    138    
     138
    139139    template<typename BidirectionalIterator>
    140140    void test_bidirectional_iterator(BidirectionalIterator);
    141    
     141
    142142    template<typename RandomAccessIterator>
    143143    void test_random_access_iterator(RandomAccessIterator);
     
    202202    typedef T value_type;
    203203    typedef const T& const_reference;
    204     typedef const T* const_iterator; 
     204    typedef const T* const_iterator;
    205205    typedef const_iterator const_column_iterator;
    206206    typedef const_iterator const_row_iterator;
     
    213213    size_t columns(void) const { return 0; }
    214214    size_t rows(void) const { return 0; }
    215     const_reference operator()(size_t row, size_t column) const 
     215    const_reference operator()(size_t row, size_t column) const
    216216    { return element_; }
    217217
     
    232232  public:
    233233    typedef T& reference;
    234     typedef T* iterator; 
     234    typedef T* iterator;
    235235    typedef iterator column_iterator;
    236236    typedef iterator row_iterator;
     
    278278  public:
    279279    neighbor_weighting_archetype(void) {}
    280     void operator()(const utility::VectorBase& distance, 
     280    void operator()(const utility::VectorBase& distance,
    281281                    const std::vector<size_t>& k_sorted,
    282                     const classifier::Target& target, 
     282                    const classifier::Target& target,
    283283                    utility::VectorMutable& prediction) const {}
    284284    neighbor_weighting_archetype& operator=(const neighbor_weighting_archetype&)
     
    341341    bool ok = ss2.str()==ss.str();
    342342    if (!ok) {
    343       this->err() << "ERROR: first object gave following output:\n" 
     343      this->err() << "ERROR: first object gave following output:\n"
    344344                  << ss.str() << "\n"
    345                   << "ERROR: and second object gave following output:\n" 
     345                  << "ERROR: and second object gave following output:\n"
    346346                  << ss2.str() << "\n";
    347347    }
     
    358358    default_constructed == default_constructed; // avoid compiler warning
    359359  }
    360  
     360
    361361  template<typename InputIterator>
    362362  void Suite::test_input_iterator(InputIterator& iter)
     
    370370    }
    371371  }
    372  
     372
    373373  template<typename OutputIterator>
    374374  void Suite::test_output_iterator(OutputIterator& iter)
    375375  {
    376     test_trivial_iterator(iter);
    377376    err() << "  testing Output features" << std::endl;
    378   }
    379  
     377    // OutputIterator should be default constructible and assignable
     378    OutputIterator oi;
     379    oi = iter;
     380    ++oi;
     381  }
     382
    380383  template<typename ForwardIterator>
    381384  void Suite::test_forward_iterator(ForwardIterator iter)
     
    384387    test_input_iterator(iter);
    385388    err() << "  testing Forward features" << std::endl;
    386    
     389
    387390    typename std::iterator_traits<ForwardIterator>::value_type tmp = *iter;
    388391    // testing multiple traversing is possible and does not change the data
     
    394397    add(tmp==*iter);
    395398  }
    396  
     399
    397400  template<typename BidirectionalIterator>
    398401  void Suite::test_bidirectional_iterator(BidirectionalIterator iter)
     
    433436      err() << "operator-(int) failed" << std::endl;
    434437    add(++iter2 == iter3);
    435    
     438
    436439    RandomAccessIterator iter5 = iter + 0;
    437440    RandomAccessIterator iter6 = 0 + iter;
    438441    add(iter6 == iter5);
    439    
     442
    440443    RandomAccessIterator iter7 = iter - 0;
    441444    add(iter7 == iter);
    442445    add(iter7 - iter == 0);
    443446    add(! (iter7<iter));
    444    
     447
    445448    typename RandomAccessIterator::value_type tmp = iter[0];
    446449    typename RandomAccessIterator::value_type tmp2 = *iter;
     
    490493    column_iterator ci = mc.begin_column(0);
    491494    row_iterator ri = mc.begin_row(0);
    492     *i = *ci; 
    493     *ci = *i; 
    494     *ri = *i; 
     495    *i = *ci;
     496    *ci = *i;
     497    *ri = *i;
    495498    i = mc.end();
    496499    ci = mc.end_column(0);
Note: See TracChangeset for help on using the changeset viewer.