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/invariants.hpp"
9 #include "../helpers/random_values.hpp"
10 #include "../helpers/tracker.hpp"
12 #if defined(BOOST_MSVC)
14 disable : 4512) // move_assignment operator could not be generated
17 test::seed_t
initialize_seed(12847);
19 template <class T
> struct move_assign_base
: public test::exception_base
21 test::random_values
<T
> x_values
, y_values
;
24 typedef BOOST_DEDUCED_TYPENAME
T::hasher hasher
;
25 typedef BOOST_DEDUCED_TYPENAME
T::key_equal key_equal
;
26 typedef BOOST_DEDUCED_TYPENAME
T::allocator_type allocator_type
;
28 move_assign_base(int tag1
, int tag2
, float mlf1
= 1.0, float mlf2
= 1.0)
29 : x_values(), y_values(),
30 x(0, hasher(tag1
), key_equal(tag1
), allocator_type(tag1
)),
31 y(0, hasher(tag2
), key_equal(tag2
), allocator_type(tag2
))
33 x
.max_load_factor(mlf1
);
34 y
.max_load_factor(mlf2
);
38 T
init() const { return T(x
); }
41 test::exceptions_enable
disable_exceptions(false);
43 disable_exceptions
.release();
47 test::check_container(x1
, y_values
);
48 test::check_equivalent_keys(x1
);
51 void check
BOOST_PREVENT_MACRO_SUBSTITUTION(T
const& x1
) const
53 test::check_equivalent_keys(x1
);
55 // If the container is empty at the point of the exception, the
56 // internal structure is hidden, this exposes it, at the cost of
57 // messing up the data.
58 if (x_values
.size()) {
59 T
& x2
= const_cast<T
&>(x1
);
60 x2
.emplace(*x_values
.begin());
61 test::check_equivalent_keys(x2
);
66 template <class T
> struct move_assign_values
: move_assign_base
<T
>
68 move_assign_values(unsigned int count1
, unsigned int count2
, int tag1
,
69 int tag2
, float mlf1
= 1.0, float mlf2
= 1.0)
70 : move_assign_base
<T
>(tag1
, tag2
, mlf1
, mlf2
)
72 this->x_values
.fill(count1
, test::limited_range
);
73 this->y_values
.fill(count2
, test::limited_range
);
74 this->x
.insert(this->x_values
.begin(), this->x_values
.end());
75 this->y
.insert(this->y_values
.begin(), this->y_values
.end());
79 template <class T
> struct move_assign_test1
: move_assign_values
<T
>
81 move_assign_test1() : move_assign_values
<T
>(0, 0, 0, 0) {}
84 template <class T
> struct move_assign_test2
: move_assign_values
<T
>
86 move_assign_test2() : move_assign_values
<T
>(60, 0, 0, 0) {}
89 template <class T
> struct move_assign_test3
: move_assign_values
<T
>
91 move_assign_test3() : move_assign_values
<T
>(0, 60, 0, 0) {}
94 template <class T
> struct move_assign_test4
: move_assign_values
<T
>
96 move_assign_test4() : move_assign_values
<T
>(10, 10, 1, 2) {}
99 template <class T
> struct move_assign_test4a
: move_assign_values
<T
>
101 move_assign_test4a() : move_assign_values
<T
>(10, 100, 1, 2) {}
104 template <class T
> struct move_assign_test5
: move_assign_values
<T
>
106 move_assign_test5() : move_assign_values
<T
>(5, 60, 0, 0, 1.0f
, 0.1f
) {}
109 template <class T
> struct equivalent_test1
: move_assign_base
<T
>
111 equivalent_test1() : move_assign_base
<T
>(0, 0)
113 test::random_values
<T
> x_values2(10, test::limited_range
);
114 this->x_values
.insert(x_values2
.begin(), x_values2
.end());
115 this->x_values
.insert(x_values2
.begin(), x_values2
.end());
116 test::random_values
<T
> y_values2(10, test::limited_range
);
117 this->y_values
.insert(y_values2
.begin(), y_values2
.end());
118 this->y_values
.insert(y_values2
.begin(), y_values2
.end());
119 this->x
.insert(this->x_values
.begin(), this->x_values
.end());
120 this->y
.insert(this->y_values
.begin(), this->y_values
.end());
126 (move_assign_test1
)(move_assign_test2
)(move_assign_test3
)
127 (move_assign_test4
)(move_assign_test4a
)(move_assign_test5
)