forked from boostorg/iterator
Add more tests
[SVN r1294]
This commit is contained in:
@@ -50,9 +50,48 @@ struct old_iterator
|
||||
};
|
||||
old_iterator operator+(std::ptrdiff_t, old_iterator x) { return x; }
|
||||
|
||||
void test_tag_convertibility()
|
||||
{
|
||||
#ifndef BOOST_NO_IS_CONVERTIBLE
|
||||
{
|
||||
typedef boost::iterator_tag<
|
||||
boost::writable_lvalue_iterator_tag
|
||||
, boost::single_pass_iterator_tag
|
||||
> tag;
|
||||
|
||||
BOOST_STATIC_ASSERT((
|
||||
boost::is_convertible<tag, std::output_iterator_tag>::value
|
||||
));
|
||||
BOOST_STATIC_ASSERT((
|
||||
boost::is_convertible<tag, std::input_iterator_tag>::value
|
||||
));
|
||||
BOOST_STATIC_ASSERT((
|
||||
!boost::is_convertible<tag, std::forward_iterator_tag>::value
|
||||
));
|
||||
}
|
||||
{
|
||||
typedef boost::iterator_tag<
|
||||
boost::readable_lvalue_iterator_tag
|
||||
, boost::single_pass_iterator_tag
|
||||
> tag;
|
||||
BOOST_STATIC_ASSERT((
|
||||
boost::is_convertible<tag, std::input_iterator_tag>::value
|
||||
));
|
||||
BOOST_STATIC_ASSERT((
|
||||
!boost::is_convertible<tag, std::output_iterator_tag>::value
|
||||
));
|
||||
BOOST_STATIC_ASSERT((
|
||||
!boost::is_convertible<tag, std::forward_iterator_tag>::value
|
||||
));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test_tag_convertibility();
|
||||
|
||||
typedef boost::iterator_tag< boost::writable_lvalue_iterator_tag, boost::random_access_traversal_tag > tag;
|
||||
|
||||
// BOOST_STATIC_ASSERT((boost::detail::is_random_access_iterator<tag>::value));
|
||||
|
@@ -4,6 +4,8 @@
|
||||
// "as is" without express or implied warranty, and with no claim as
|
||||
// to its suitability for any purpose.
|
||||
#include <boost/iterator/iterator_adaptor.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type.hpp>
|
||||
|
||||
struct X { int a; };
|
||||
|
||||
@@ -28,8 +30,90 @@ void operator_arrow_test()
|
||||
take_xptr(Xiter(&x).operator->());
|
||||
}
|
||||
|
||||
template <class T, class U>
|
||||
struct static_assert_same
|
||||
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
{
|
||||
template <class V>
|
||||
static int check(V, V);
|
||||
enum { value = sizeof(check(boost::type<T>(), boost::type<U>())) };
|
||||
}
|
||||
#endif
|
||||
;
|
||||
|
||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
template <class T>
|
||||
struct static_assert_same<T,T>
|
||||
{
|
||||
enum { value };
|
||||
};
|
||||
#endif
|
||||
|
||||
template <class T, class U, class Min>
|
||||
struct static_assert_min_cat
|
||||
: static_assert_same<
|
||||
typename boost::detail::minimum_category<T,U>::type, Min
|
||||
>
|
||||
{};
|
||||
|
||||
void category_test()
|
||||
{
|
||||
using namespace boost;
|
||||
using namespace boost::detail;
|
||||
|
||||
BOOST_STATIC_ASSERT((
|
||||
!is_tag<
|
||||
input_output_iterator_tag
|
||||
, std::input_iterator_tag>::value));
|
||||
|
||||
BOOST_STATIC_ASSERT((
|
||||
!is_tag<
|
||||
input_output_iterator_tag
|
||||
, std::output_iterator_tag>::value));
|
||||
|
||||
BOOST_STATIC_ASSERT((
|
||||
is_tag<
|
||||
std::input_iterator_tag
|
||||
, input_output_iterator_tag>::value));
|
||||
|
||||
BOOST_STATIC_ASSERT((
|
||||
is_tag<
|
||||
std::output_iterator_tag
|
||||
, input_output_iterator_tag>::value));
|
||||
|
||||
BOOST_STATIC_ASSERT((
|
||||
is_tag<
|
||||
input_output_iterator_tag
|
||||
, std::forward_iterator_tag>::value));
|
||||
|
||||
int test = static_assert_min_cat<
|
||||
std::input_iterator_tag,input_output_iterator_tag, std::input_iterator_tag
|
||||
>::value;
|
||||
|
||||
test = static_assert_min_cat<
|
||||
input_output_iterator_tag,std::input_iterator_tag, std::input_iterator_tag
|
||||
>::value;
|
||||
|
||||
test = static_assert_min_cat<
|
||||
input_output_iterator_tag,std::forward_iterator_tag, input_output_iterator_tag
|
||||
>::value;
|
||||
|
||||
test = static_assert_min_cat<
|
||||
std::input_iterator_tag,std::forward_iterator_tag, std::input_iterator_tag
|
||||
>::value;
|
||||
|
||||
test = static_assert_min_cat<
|
||||
std::input_iterator_tag,std::random_access_iterator_tag, std::input_iterator_tag
|
||||
>::value;
|
||||
|
||||
test = static_assert_min_cat<
|
||||
std::output_iterator_tag,std::random_access_iterator_tag, std::output_iterator_tag
|
||||
>::value;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
category_test();
|
||||
operator_arrow_test();
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user