3 // Copyright Neil Groves 2010. Use, modification and
4 // distribution is subject to the Boost Software License, Version
5 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
9 // For more information, see http://www.boost.org/libs/range/
11 #include <boost/range/has_range_iterator.hpp>
12 #include <boost/config.hpp>
14 #include <boost/test/test_tools.hpp>
15 #include <boost/test/unit_test.hpp>
21 class MockClassWithoutIterators
{};
23 template<typename Container
>
24 void test_has_range_iterator_impl(const bool expected_value
)
26 BOOST_CHECK_EQUAL( boost::has_range_iterator
<Container
>::value
, expected_value
);
29 template<typename Container
>
30 void test_has_range_const_iterator_impl(const bool expected_value
)
32 BOOST_CHECK_EQUAL( boost::has_range_const_iterator
<Container
>::value
, expected_value
);
35 void test_has_range_iterator()
37 test_has_range_iterator_impl
< std::vector
<int> >(true);
38 test_has_range_iterator_impl
< MockClassWithoutIterators
>(false);
40 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
41 test_has_range_iterator_impl
<std::vector
<int>&&>(true);
42 test_has_range_iterator_impl
<MockClassWithoutIterators
&&>(false);
46 void test_has_range_const_iterator()
48 test_has_range_const_iterator_impl
< std::vector
<int> >(true);
49 test_has_range_const_iterator_impl
< MockClassWithoutIterators
>(false);
51 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
52 test_has_range_const_iterator_impl
<std::vector
<int>&&>(true);
53 test_has_range_const_iterator_impl
<MockClassWithoutIterators
&&>(false);
58 boost::unit_test::test_suite
*
59 init_unit_test_suite(int argc
, char* argv
[])
61 boost::unit_test::test_suite
* test
62 = BOOST_TEST_SUITE( "RangeTestSuite.has_range_iterator" );
64 test
->add(BOOST_TEST_CASE(&test_has_range_iterator
));
65 test
->add(BOOST_TEST_CASE(&test_has_range_const_iterator
));