From ddcef2fb196db23a66b8978c2ff9de4a25b1c895 Mon Sep 17 00:00:00 2001 From: Jeremy Siek Date: Thu, 8 Feb 2001 03:08:09 +0000 Subject: [PATCH] Added tests for the make_xxx_iterator() helper functions [SVN r9025] --- iterator_adaptor_test.cpp | 44 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/iterator_adaptor_test.cpp b/iterator_adaptor_test.cpp index 409cac9..9f94bed 100644 --- a/iterator_adaptor_test.cpp +++ b/iterator_adaptor_test.cpp @@ -9,6 +9,8 @@ // See http://www.boost.org for most recent version including documentation. // 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 // possible (which was all but the projection iterator). // (Jeremy Siek) @@ -249,9 +251,24 @@ main() indirect_iterator i = ptr; boost::random_access_iterator_test(i, N, array); +#ifdef BOOST_NO_STD_ITERATOR_TRAITS + typedef boost::iterator 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; boost::random_access_iterator_test(j, N, array); + dummyT*const* const_ptr = ptr; +#ifdef BOOST_NO_STD_ITERATOR_TRAITS + typedef boost::iterator 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); @@ -272,9 +289,13 @@ main() Projection::iterator i = pair_array; boost::random_access_iterator_test(i, N, array); + boost::random_access_iterator_test(boost::make_projection_iterator(pair_array, select1st_()), N, array); + Projection::const_iterator j = pair_array; boost::random_access_iterator_test(j, N, array); + boost::random_access_iterator_test(boost::make_const_projection_iterator(pair_array, select1st_()), N, array); + boost::const_nonconst_iterator_test(i, ++j); } // Test reverse_iterator_generator @@ -292,9 +313,24 @@ main() reverse_iterator i = reversed + N; boost::random_access_iterator_test(i, N, array); +#ifdef BOOST_NO_STD_ITERATOR_TRAITS + tyepdef boost::iterator 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; boost::random_access_iterator_test(j, N, array); + const dummyT* const_reversed = reversed; +#ifdef BOOST_NO_STD_ITERATOR_TRAITS + typedef boost::iterator 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); } @@ -309,9 +345,13 @@ main() { typedef boost::filter_iterator_generator >::type FilterIter; - FilterIter i(array); + dummyT*, dummyT&> > FilterGen; + 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(boost::make_filter_iterator(array, array + N, one_or_four()), dummyT(1), dummyT(4)); } std::cout << "test successful " << std::endl; return 0;