mirror of
https://github.com/boostorg/utility.git
synced 2025-05-09 15:04:00 +00:00
Added tests for the make_xxx_iterator() helper functions
[SVN r9025]
This commit is contained in:
parent
493d124c07
commit
ddcef2fb19
@ -9,6 +9,8 @@
|
|||||||
// See http://www.boost.org for most recent version including documentation.
|
// See http://www.boost.org for most recent version including documentation.
|
||||||
|
|
||||||
// Revision History
|
// Revision History
|
||||||
|
// 07 Feb 01 Added tests for the make_xxx_iterator() helper functions.
|
||||||
|
// (Jeremy Siek)
|
||||||
// 07 Feb 01 Replaced use of xxx_pair_generator with xxx_generator where
|
// 07 Feb 01 Replaced use of xxx_pair_generator with xxx_generator where
|
||||||
// possible (which was all but the projection iterator).
|
// possible (which was all but the projection iterator).
|
||||||
// (Jeremy Siek)
|
// (Jeremy Siek)
|
||||||
@ -249,9 +251,24 @@ main()
|
|||||||
indirect_iterator i = ptr;
|
indirect_iterator i = ptr;
|
||||||
boost::random_access_iterator_test(i, N, array);
|
boost::random_access_iterator_test(i, N, array);
|
||||||
|
|
||||||
|
#ifdef BOOST_NO_STD_ITERATOR_TRAITS
|
||||||
|
typedef boost::iterator<std::random_access_iterator_tag, dummyT> InnerTraits;
|
||||||
|
boost::random_access_iterator_test(boost::make_indirect_iterator(ptr, *ptr, InnerTraits()), N, array);
|
||||||
|
#else
|
||||||
|
boost::random_access_iterator_test(boost::make_indirect_iterator(ptr), N, array);
|
||||||
|
#endif
|
||||||
|
|
||||||
const_indirect_iterator j = ptr;
|
const_indirect_iterator j = ptr;
|
||||||
boost::random_access_iterator_test(j, N, array);
|
boost::random_access_iterator_test(j, N, array);
|
||||||
|
|
||||||
|
dummyT*const* const_ptr = ptr;
|
||||||
|
#ifdef BOOST_NO_STD_ITERATOR_TRAITS
|
||||||
|
typedef boost::iterator<std::random_access_iterator_tag,dummyT,std::ptrdiff_t,const dummyT*,const dummyT&> ConstInnerTraits;
|
||||||
|
boost::random_access_iterator_test(boost::make_indirect_iterator(const_ptr, *const_ptr, ConstInnerTraits()), N, array);
|
||||||
|
#else
|
||||||
|
boost::random_access_iterator_test(boost::make_indirect_iterator(const_ptr), N, array);
|
||||||
|
#endif
|
||||||
|
|
||||||
boost::const_nonconst_iterator_test(i, ++j);
|
boost::const_nonconst_iterator_test(i, ++j);
|
||||||
|
|
||||||
|
|
||||||
@ -272,9 +289,13 @@ main()
|
|||||||
Projection::iterator i = pair_array;
|
Projection::iterator i = pair_array;
|
||||||
boost::random_access_iterator_test(i, N, array);
|
boost::random_access_iterator_test(i, N, array);
|
||||||
|
|
||||||
|
boost::random_access_iterator_test(boost::make_projection_iterator(pair_array, select1st_<Pair>()), N, array);
|
||||||
|
|
||||||
Projection::const_iterator j = pair_array;
|
Projection::const_iterator j = pair_array;
|
||||||
boost::random_access_iterator_test(j, N, array);
|
boost::random_access_iterator_test(j, N, array);
|
||||||
|
|
||||||
|
boost::random_access_iterator_test(boost::make_const_projection_iterator(pair_array, select1st_<Pair>()), N, array);
|
||||||
|
|
||||||
boost::const_nonconst_iterator_test(i, ++j);
|
boost::const_nonconst_iterator_test(i, ++j);
|
||||||
}
|
}
|
||||||
// Test reverse_iterator_generator
|
// Test reverse_iterator_generator
|
||||||
@ -292,9 +313,24 @@ main()
|
|||||||
reverse_iterator i = reversed + N;
|
reverse_iterator i = reversed + N;
|
||||||
boost::random_access_iterator_test(i, N, array);
|
boost::random_access_iterator_test(i, N, array);
|
||||||
|
|
||||||
|
#ifdef BOOST_NO_STD_ITERATOR_TRAITS
|
||||||
|
tyepdef boost::iterator<std::random_access_iterator_tag,dummyT> ReverseTraits;
|
||||||
|
boost::random_access_iterator_test(boost::make_reverse_iterator(reversed + N, ReverseTraits()), N, array);
|
||||||
|
#else
|
||||||
|
boost::random_access_iterator_test(boost::make_reverse_iterator(reversed + N), N, array);
|
||||||
|
#endif
|
||||||
|
|
||||||
const_reverse_iterator j = reversed + N;
|
const_reverse_iterator j = reversed + N;
|
||||||
boost::random_access_iterator_test(j, N, array);
|
boost::random_access_iterator_test(j, N, array);
|
||||||
|
|
||||||
|
const dummyT* const_reversed = reversed;
|
||||||
|
#ifdef BOOST_NO_STD_ITERATOR_TRAITS
|
||||||
|
typedef boost::iterator<std::random_access_iterator_tag,const dummyT> ConstReverseTraits;
|
||||||
|
boost::random_access_iterator_test(boost::make_reverse_iterator(const_reversed + N, ConstReverseTraits()), N, array);
|
||||||
|
#else
|
||||||
|
boost::random_access_iterator_test(boost::make_reverse_iterator(const_reversed + N), N, array);
|
||||||
|
#endif
|
||||||
|
|
||||||
boost::const_nonconst_iterator_test(i, ++j);
|
boost::const_nonconst_iterator_test(i, ++j);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,9 +345,13 @@ main()
|
|||||||
{
|
{
|
||||||
typedef boost::filter_iterator_generator<one_or_four, dummyT*,
|
typedef boost::filter_iterator_generator<one_or_four, dummyT*,
|
||||||
boost::iterator<std::forward_iterator_tag, dummyT, std::ptrdiff_t,
|
boost::iterator<std::forward_iterator_tag, dummyT, std::ptrdiff_t,
|
||||||
dummyT*, dummyT&> >::type FilterIter;
|
dummyT*, dummyT&> > FilterGen;
|
||||||
FilterIter i(array);
|
typedef FilterGen::type FilterIter;
|
||||||
|
typedef FilterGen::policies_type FilterPolicies;
|
||||||
|
FilterIter i(array, FilterPolicies(one_or_four(), array + N));
|
||||||
boost::forward_iterator_test(i, dummyT(1), dummyT(4));
|
boost::forward_iterator_test(i, dummyT(1), dummyT(4));
|
||||||
|
|
||||||
|
boost::forward_iterator_test(boost::make_filter_iterator(array, array + N, one_or_four()), dummyT(1), dummyT(4));
|
||||||
}
|
}
|
||||||
std::cout << "test successful " << std::endl;
|
std::cout << "test successful " << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user