2 // Copyright 2006-2009 Daniel James.
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 #include "./containers.hpp"
8 #include "../helpers/input_iterator.hpp"
9 #include "../helpers/invariants.hpp"
10 #include "../helpers/random_values.hpp"
11 #include "../helpers/tracker.hpp"
13 template <typename T
> inline void avoid_unused_warning(T
const&) {}
15 test::seed_t
initialize_seed(91274);
19 test::exception::object obj
;
20 test::exception::hash hash
;
21 test::exception::equal_to equal_to
;
22 test::exception::allocator
<test::exception::object
> allocator
;
25 template <class T
> struct construct_test1
: public objects
, test::exception_base
32 BOOST_TEST(x
.empty());
33 test::check_equivalent_keys(x
);
37 template <class T
> struct construct_test2
: public objects
, test::exception_base
44 BOOST_TEST(x
.empty());
45 test::check_equivalent_keys(x
);
49 template <class T
> struct construct_test3
: public objects
, test::exception_base
56 BOOST_TEST(x
.empty());
57 test::check_equivalent_keys(x
);
61 template <class T
> struct construct_test4
: public objects
, test::exception_base
65 T
x(0, hash
, equal_to
);
68 BOOST_TEST(x
.empty());
69 test::check_equivalent_keys(x
);
73 template <class T
> struct construct_test5
: public objects
, test::exception_base
77 T
x(50, hash
, equal_to
, allocator
);
80 BOOST_TEST(x
.empty());
81 test::check_equivalent_keys(x
);
85 template <class T
> struct construct_test6
: public objects
, test::exception_base
92 BOOST_TEST(x
.empty());
93 test::check_equivalent_keys(x
);
97 template <class T
> struct range
: public test::exception_base
99 test::random_values
<T
> values
;
101 range() : values(5, test::limited_range
) {}
102 range(unsigned int count
) : values(count
, test::limited_range
) {}
105 template <class T
> struct range_construct_test1
: public range
<T
>, objects
109 T
x(this->values
.begin(), this->values
.end());
112 test::check_container(x
, this->values
);
113 test::check_equivalent_keys(x
);
117 template <class T
> struct range_construct_test2
: public range
<T
>, objects
121 T
x(this->values
.begin(), this->values
.end(), 0);
124 test::check_container(x
, this->values
);
125 test::check_equivalent_keys(x
);
129 template <class T
> struct range_construct_test3
: public range
<T
>, objects
133 T
x(this->values
.begin(), this->values
.end(), 0, hash
);
136 test::check_container(x
, this->values
);
137 test::check_equivalent_keys(x
);
141 template <class T
> struct range_construct_test4
: public range
<T
>, objects
145 T
x(this->values
.begin(), this->values
.end(), 100, hash
, equal_to
);
148 test::check_container(x
, this->values
);
149 test::check_equivalent_keys(x
);
153 // Need to run at least one test with a fairly large number
154 // of objects in case it triggers a rehash.
155 template <class T
> struct range_construct_test5
: public range
<T
>, objects
157 range_construct_test5() : range
<T
>(60) {}
161 T
x(this->values
.begin(), this->values
.end(), 0, hash
, equal_to
, allocator
);
164 test::check_container(x
, this->values
);
165 test::check_equivalent_keys(x
);
169 template <class T
> struct input_range_construct_test
: public range
<T
>, objects
171 input_range_construct_test() : range
<T
>(60) {}
175 BOOST_DEDUCED_TYPENAME
test::random_values
<T
>::const_iterator
176 begin
= this->values
.begin(),
177 end
= this->values
.end();
178 T
x(test::input_iterator(begin
), test::input_iterator(end
), 0, hash
,
179 equal_to
, allocator
);
182 test::check_container(x
, this->values
);
183 test::check_equivalent_keys(x
);
187 template <class T
> struct copy_range_construct_test
: public range
<T
>, objects
189 copy_range_construct_test() : range
<T
>(60) {}
193 T
x(test::copy_iterator(this->values
.begin()),
194 test::copy_iterator(this->values
.end()), 0, hash
, equal_to
, allocator
);
197 test::check_container(x
, this->values
);
198 test::check_equivalent_keys(x
);
204 (construct_test1
)(construct_test2
)(construct_test3
)(construct_test4
)
205 (construct_test5
)(construct_test6
)(range_construct_test1
)
206 (range_construct_test2
)(range_construct_test3
)(range_construct_test4
)
207 (range_construct_test5
)(input_range_construct_test
)
208 (copy_range_construct_test
),