diff --git a/include/boost/pending/iterator_tests.hpp b/include/boost/pending/iterator_tests.hpp index 15a5ec4..c3c3601 100644 --- a/include/boost/pending/iterator_tests.hpp +++ b/include/boost/pending/iterator_tests.hpp @@ -1,17 +1,28 @@ #ifndef BOOST_ITERATOR_TESTS_HPP -#define BOOST_ITERATOR_TESTS_HPP +# define BOOST_ITERATOR_TESTS_HPP // This is meant to be the beginnings of a comprehensive, generic // test suite for STL concepts such as iterators and containers. +// +// Revision History: +// 08 Feb 2001 Fixed bidirectional iterator test so that +// --i is no longer a precondition. +// (Jeremy Siek) +// 04 Feb 2001 Added lvalue test, corrected preconditions +// (David Abrahams) -#include -#include +# include +# include +# include +# include +# include // for detail::dummy_constructor namespace boost { // use this for the value type struct dummyT { dummyT() { } + dummyT(detail::dummy_constructor) { } dummyT(int x) : m_x(x) { } int foo() const { return m_x; } bool operator==(const dummyT& d) const { return m_x == d.m_x; } @@ -83,17 +94,47 @@ void input_iterator_test(Iterator i, T v1, T v2) // how to test output iterator? + +template struct lvalue_test +{ + template static void check(Iterator) + { +# ifndef BOOST_NO_STD_ITERATOR_TRAITS + typedef typename std::iterator_traits::reference reference; + typedef typename std::iterator_traits::value_type value_type; +# else + typedef typename Iterator::reference reference; + typedef typename Iterator::value_type value_type; +# endif + BOOST_STATIC_ASSERT(boost::is_reference::value); + BOOST_STATIC_ASSERT((boost::is_same::value + || boost::is_same::value + )); + } +}; + +# ifdef BOOST_NO_STD_ITERATOR_TRAITS +template <> struct lvalue_test { + template static void check(T) {} +}; +#endif + template void forward_iterator_test(Iterator i, T v1, T v2) { input_iterator_test(i, v1, v2); + + // borland doesn't allow non-type template parameters +# if !defined(__BORLANDC__) || (__BORLANDC__ > 0x551) + lvalue_test<(boost::is_pointer::value)>::check(i); +#endif } // Preconditions: *i == v1, *++i == v2 template void bidirectional_iterator_test(Iterator i, T v1, T v2) { - input_iterator_test(i, v1, v2); + forward_iterator_test(i, v1, v2); ++i; Iterator i1 = i, i2 = i; @@ -107,8 +148,8 @@ void bidirectional_iterator_test(Iterator i, T v1, T v2) --i; assert(i == i1); assert(i == i2); - --i1; - --i2; + ++i1; + ++i2; trivial_iterator_test(i, i1, v1); trivial_iterator_test(i, i2, v1);