]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/range/test/has_range_iterator.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / range / test / has_range_iterator.cpp
1 // Boost.Range library
2 //
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)
7 //
8 //
9 // For more information, see http://www.boost.org/libs/range/
10 //
11 #include <boost/range/has_range_iterator.hpp>
12 #include <boost/config.hpp>
13
14 #include <boost/test/test_tools.hpp>
15 #include <boost/test/unit_test.hpp>
16
17 #include <vector>
18
19 namespace
20 {
21 class MockClassWithoutIterators {};
22
23 template<typename Container>
24 void test_has_range_iterator_impl(const bool expected_value)
25 {
26 BOOST_CHECK_EQUAL( boost::has_range_iterator<Container>::value, expected_value );
27 }
28
29 template<typename Container>
30 void test_has_range_const_iterator_impl(const bool expected_value)
31 {
32 BOOST_CHECK_EQUAL( boost::has_range_const_iterator<Container>::value, expected_value );
33 }
34
35 void test_has_range_iterator()
36 {
37 test_has_range_iterator_impl< std::vector<int> >(true);
38 test_has_range_iterator_impl< MockClassWithoutIterators >(false);
39
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);
43 #endif
44 }
45
46 void test_has_range_const_iterator()
47 {
48 test_has_range_const_iterator_impl< std::vector<int> >(true);
49 test_has_range_const_iterator_impl< MockClassWithoutIterators >(false);
50
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);
54 #endif
55 }
56 }
57
58 boost::unit_test::test_suite*
59 init_unit_test_suite(int argc, char* argv[])
60 {
61 boost::unit_test::test_suite* test
62 = BOOST_TEST_SUITE( "RangeTestSuite.has_range_iterator" );
63
64 test->add(BOOST_TEST_CASE(&test_has_range_iterator));
65 test->add(BOOST_TEST_CASE(&test_has_range_const_iterator));
66
67 return test;
68 }