Ignore:
Timestamp:
Sep 27, 2008, 6:27:55 AM (13 years ago)
Author:
Peter
Message:

refs #368 - added several tests. Left now is to add specializations for trait classes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/iterator_test.cc

    r1537 r1538  
    423423  test_bidirectional_iterator(iter, suite);
    424424  test_random_access_iterator(iter, suite);
    425   //std::vector<double> data(vec.size());
    426   //std::vector<double> weight(vec.size());
    427   //WIter iter2(data.begin(), weight.begin());
    428   //  std::copy(iter, iter+3, iter2);
    429   //suite.add(suite.equal(data.front(), 1));
    430 }
     425  std::vector<double> data(vec.size());
     426  std::vector<double> weight(vec.size());
     427  WIter iter2(data.begin(), weight.begin());
     428  utility::DataWeight tmp2(6.89, 0.79);
     429  *iter2 = tmp2;
     430  if (!suite.add(tmp2==*iter2))
     431    suite.err() << "error: tmp2==*iter2" << std::endl;
     432  utility::DataWeight tmp3(*iter2);
     433  suite.add(suite.equal(tmp3.data(), tmp2.data()));
     434  suite.add(suite.equal(tmp3.weight(), tmp2.weight()));
     435  *iter2 = *iter;
     436  if (!suite.add(*iter2 == *iter))
     437    suite.err() << "error: *iter2 == *iter\n";
     438  tmp = *iter2;
     439  suite.add(suite.equal(tmp.data(), 1));
     440  std::copy(iter, iter+3, iter2);
     441  suite.add(suite.equal(vec.front(), 1));
     442  suite.add(suite.equal(data.front(), 1));
     443
     444  suite.err() << "  testing const conversion\n";
     445  typedef std::vector<double>::const_iterator const_Iter;
     446  typedef utility::WeightedIterator<const_Iter, const_Iter> const_WIter;
     447  const_WIter const_iter(vec.begin(), vec.begin());
     448  const_iter = iter;
     449 
     450  suite.err() << "  testing assignment between different iterators\n";
     451  const std::vector<double> const_vec(10, 10.7);
     452  const_WIter const_iter2(const_vec.begin(), const_vec.begin());
     453  utility::DataWeight tmp4;
     454  tmp4 = *const_iter2;
     455  *iter = *const_iter2;
     456  suite.add(*iter==*const_iter2);
     457  *iter = *const_iter;
     458  suite.add(*iter==*const_iter);
     459
     460  double x=101;
     461  utility::WeightedIterator<double*, double*> iter_p(&x, &x);
     462  *iter_p = *iter;
     463  suite.add(*iter_p==*iter); 
     464}
Note: See TracChangeset for help on using the changeset viewer.