1 // Copyright Neil Groves 2013. Use, modification and
2 // distribution is subject to the Boost Software License, Version
3 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
5 //
6 //
7 // For more information, see http://www.boost.org/libs/range/
8 //
9 // Acknowledgments:
10 // Implemented by Andy in response to Ticket 6888 - unique fix
11 //
12 #ifndef BOOST_RANGE_TEST_TEST_DRIVER_RANGE_OVERLOAD_TEST_DRIVER_HPP_INCLUDED
13 #define BOOST_RANGE_TEST_TEST_DRIVER_RANGE_OVERLOAD_TEST_DRIVER_HPP_INCLUDED
14
15 #include "range_return_test_driver.hpp"
16 #include <boost/assert.hpp>
17 #include <boost/test/test_tools.hpp>
18 #include <boost/test/unit_test.hpp>
19
20 namespace boost
21 {
22 namespace range_test
23 {
24
25 // A test driver to exercise a test through range_return_test_driver
26 // plus the overload that determines the return_type by overload
27 //
28 // The test driver also contains the code required to check the
29 // return value correctness.
30 //
31 // The TestPolicy needs to implement all those required by
32 // range_return_test_driver, and additionally
33 //
34 // - perform the boost range version of the algorithm that determines
35 // the return_type by overload
36 class range_overload_test_driver : range_return_test_driver
37 {
38 public:
39 template< class Container,
40 class TestPolicy >
41 void operator()(Container& cont, TestPolicy policy)
42 {
43 range_return_test_driver::operator()(cont, policy);
44 test_range_overload<Container, TestPolicy>()(cont, policy);
45 }
46
47 private:
48 template< class Container, class TestPolicy >
49 struct test_range_overload
50 {
51 void operator()(Container& cont, TestPolicy policy)
52 {
53 typedef BOOST_DEDUCED_TYPENAME range_iterator<Container>::type iterator_t;
54 typedef BOOST_DEDUCED_TYPENAME TestPolicy::template test_range_overload<Container> test_range_overload_t;
55 const range_return_value result_type = test_range_overload_t::result_type;
56 typedef BOOST_DEDUCED_TYPENAME range_return<Container, result_type>::type range_return_t;
57
58 Container reference(cont);
59 Container test_cont(cont);
60
61 test_range_overload_t test_range_overload_fn;
62 range_return_t range_result = test_range_overload_fn(policy, test_cont);
63
64 iterator_t reference_it = policy.reference(reference);
65
66 check_results<result_type>::test(test_cont, reference,
67 range_result, reference_it);
68 }
69 };
70 };
71 }
72 }
73
74 #endif // include guard

source code of boost/libs/range/test/test_driver/range_overload_test_driver.hpp