1 #ifndef BOOST_CONTAINER_TEST_INSERT_TEST_HPP
2 #define BOOST_CONTAINER_TEST_INSERT_TEST_HPP
3
4 // Copyright (C) 2013 Cromwell D. Enage
5 // Distributed under the Boost Software License, Version 1.0.
6 // (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8
9 #include <deque>
10 #include <boost/core/lightweight_test.hpp>
11 #include "check_equal_containers.hpp"
12
13 namespace boost {
14 namespace container {
15 namespace test {
16
17 template<class SeqContainer>
18 void
test_insert_range(std::deque<int> & std_deque,SeqContainer & seq_container,std::deque<int> const & input_deque,std::size_t index)19 test_insert_range(
20 std::deque<int> &std_deque
21 , SeqContainer &seq_container
22 , std::deque<int> const& input_deque
23 , std::size_t index
24 )
25 {
26 BOOST_TEST(CheckEqualContainers(std_deque, seq_container));
27
28 std_deque.insert(
29 std_deque.begin() + index
30 , input_deque.begin()
31 , input_deque.end()
32 );
33
34 seq_container.insert(
35 seq_container.begin() + index
36 , input_deque.begin()
37 , input_deque.end()
38 );
39 BOOST_TEST(CheckEqualContainers(std_deque, seq_container));
40 }
41
42 template<class SeqContainer>
test_range_insertion()43 bool test_range_insertion()
44 {
45 int err_count = boost::report_errors();
46 typedef typename SeqContainer::value_type value_type;
47 std::deque<int> input_deque;
48 for (int element = -10; element < 10; ++element)
49 {
50 input_deque.push_back(element + 20);
51 }
52
53 for (std::size_t i = 0; i <= input_deque.size(); ++i)
54 {
55 std::deque<int> std_deque;
56 ::boost::movelib::unique_ptr<SeqContainer> const pseqcontainer = ::boost::movelib::make_unique<SeqContainer>();
57 SeqContainer &seq_container = *pseqcontainer;
58
59 for (int element = -10; element < 10; ++element)
60 {
61 std_deque.push_back(element);
62 seq_container.push_back(value_type(element));
63 }
64 test_insert_range(std_deque, seq_container, input_deque, i);
65 }
66
67 return err_count == boost::report_errors();
68 }
69
70
71 } //namespace test {
72 } //namespace container {
73 } //namespace boost {
74
75 #endif //#ifndef BOOST_CONTAINER_TEST_INSERT_TEST_HPP
76