Ignore:
Timestamp:
Sep 12, 2008, 12:10:26 AM (14 years ago)
Author:
Peter
Message:

fixes #440

The bug was introduced in trunk after 0.4 release, so it has never
seen daylight.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/iterator_test.cc

    r1487 r1490  
    3232#include "yat/utility/stl_utility.h"
    3333#include "yat/utility/Vector.h"
     34#include "yat/utility/VectorView.h"
     35#include "yat/utility/VectorConstView.h"
    3436#include "yat/utility/WeightIterator.h"
    3537
     
    7274void test_random_access_iterator(RandomAccessIterator, test::Suite&);
    7375
     76void test_stride_iterator(test::Suite& suite);
     77
    7478int main(int argc, char* argv[])
    7579
     
    7781  suite.err() << "testing iterator" << std::endl;
    7882
     83  test_stride_iterator(suite);
    7984  old_main(suite);
    8085  test_boost_util(suite);
     
    111116    suite.add(false);
    112117
     118  suite.err() << "sorting...";
    113119  utility::Vector::iterator end=vec.end();
    114120  std::sort(begin, end);
     121  suite.err() << " sorting done\n";
    115122
    116123  suite.err() << "testing classifier::DataLookup1D::const_iterator" << std::endl;
     
    371378  if (ok_cached && !suite.ok())
    372379    suite.err() << "failed" << std::endl;
    373  
    374 
    375 }
     380}
     381
     382void test_stride_iterator(test::Suite& suite)
     383{
     384  suite.err() << "testing StrideIterator" << std::endl;
     385  using utility::Vector;
     386  Vector a(10);
     387  // stride 2
     388  utility::VectorConstView b(a, 0, 5, 2);
     389  if (!suite.add(b.end()-b.begin()==5))
     390    suite.err() << "ERROR: StrideIterator::operator- returned: "
     391                << b.end()-b.begin()
     392                << " expected 5\n";
     393  utility::VectorView c(a, 0, 3, 2);
     394  Vector::iterator begin = c.begin();
     395  Vector::iterator end = c.end();
     396  Vector::const_iterator cbegin = begin;
     397  Vector::const_iterator cend = end;
     398
     399  if (!suite.add(c.size()==3))
     400    suite.err() << "c.size() incorrect" << std::endl;
     401  if (!suite.add(cend-cbegin == 3))
     402    suite.err() << "cend-cbegin failed\n";
     403}
Note: See TracChangeset for help on using the changeset viewer.