]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/unordered/test/exception/constructor_exception_tests.cpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / libs / unordered / test / exception / constructor_exception_tests.cpp
CommitLineData
7c673cae
FG
1
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)
5
6#include "./containers.hpp"
b32b8144 7
7c673cae 8#include "../helpers/input_iterator.hpp"
b32b8144
FG
9#include "../helpers/invariants.hpp"
10#include "../helpers/random_values.hpp"
11#include "../helpers/tracker.hpp"
7c673cae
FG
12
13template <typename T> inline void avoid_unused_warning(T const&) {}
14
15test::seed_t initialize_seed(91274);
16
17struct objects
18{
b32b8144
FG
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;
7c673cae
FG
23};
24
b32b8144 25template <class T> struct construct_test1 : public objects, test::exception_base
7c673cae 26{
b32b8144
FG
27 void run() const
28 {
29 T x;
30
31 DISABLE_EXCEPTIONS;
32 BOOST_TEST(x.empty());
33 test::check_equivalent_keys(x);
34 }
7c673cae
FG
35};
36
b32b8144 37template <class T> struct construct_test2 : public objects, test::exception_base
7c673cae 38{
b32b8144
FG
39 void run() const
40 {
41 T x(300);
42
43 DISABLE_EXCEPTIONS;
44 BOOST_TEST(x.empty());
45 test::check_equivalent_keys(x);
46 }
7c673cae
FG
47};
48
b32b8144 49template <class T> struct construct_test3 : public objects, test::exception_base
7c673cae 50{
b32b8144
FG
51 void run() const
52 {
53 T x(0, hash);
54
55 DISABLE_EXCEPTIONS;
56 BOOST_TEST(x.empty());
57 test::check_equivalent_keys(x);
58 }
7c673cae
FG
59};
60
b32b8144 61template <class T> struct construct_test4 : public objects, test::exception_base
7c673cae 62{
b32b8144
FG
63 void run() const
64 {
65 T x(0, hash, equal_to);
66
67 DISABLE_EXCEPTIONS;
68 BOOST_TEST(x.empty());
69 test::check_equivalent_keys(x);
70 }
7c673cae
FG
71};
72
b32b8144 73template <class T> struct construct_test5 : public objects, test::exception_base
7c673cae 74{
b32b8144
FG
75 void run() const
76 {
77 T x(50, hash, equal_to, allocator);
78
79 DISABLE_EXCEPTIONS;
80 BOOST_TEST(x.empty());
81 test::check_equivalent_keys(x);
82 }
7c673cae
FG
83};
84
b32b8144 85template <class T> struct construct_test6 : public objects, test::exception_base
7c673cae 86{
b32b8144
FG
87 void run() const
88 {
89 T x(allocator);
90
91 DISABLE_EXCEPTIONS;
92 BOOST_TEST(x.empty());
93 test::check_equivalent_keys(x);
94 }
7c673cae
FG
95};
96
b32b8144 97template <class T> struct range : public test::exception_base
7c673cae 98{
b32b8144 99 test::random_values<T> values;
7c673cae 100
b32b8144
FG
101 range() : values(5, test::limited_range) {}
102 range(unsigned int count) : values(count, test::limited_range) {}
7c673cae
FG
103};
104
b32b8144 105template <class T> struct range_construct_test1 : public range<T>, objects
7c673cae 106{
b32b8144
FG
107 void run() const
108 {
109 T x(this->values.begin(), this->values.end());
110
111 DISABLE_EXCEPTIONS;
112 test::check_container(x, this->values);
113 test::check_equivalent_keys(x);
114 }
7c673cae
FG
115};
116
b32b8144 117template <class T> struct range_construct_test2 : public range<T>, objects
7c673cae 118{
b32b8144
FG
119 void run() const
120 {
121 T x(this->values.begin(), this->values.end(), 0);
122
123 DISABLE_EXCEPTIONS;
124 test::check_container(x, this->values);
125 test::check_equivalent_keys(x);
126 }
7c673cae
FG
127};
128
b32b8144 129template <class T> struct range_construct_test3 : public range<T>, objects
7c673cae 130{
b32b8144
FG
131 void run() const
132 {
133 T x(this->values.begin(), this->values.end(), 0, hash);
134
135 DISABLE_EXCEPTIONS;
136 test::check_container(x, this->values);
137 test::check_equivalent_keys(x);
138 }
7c673cae
FG
139};
140
b32b8144 141template <class T> struct range_construct_test4 : public range<T>, objects
7c673cae 142{
b32b8144
FG
143 void run() const
144 {
145 T x(this->values.begin(), this->values.end(), 100, hash, equal_to);
146
147 DISABLE_EXCEPTIONS;
148 test::check_container(x, this->values);
149 test::check_equivalent_keys(x);
150 }
7c673cae
FG
151};
152
153// Need to run at least one test with a fairly large number
154// of objects in case it triggers a rehash.
b32b8144 155template <class T> struct range_construct_test5 : public range<T>, objects
7c673cae 156{
b32b8144
FG
157 range_construct_test5() : range<T>(60) {}
158
159 void run() const
160 {
161 T x(this->values.begin(), this->values.end(), 0, hash, equal_to, allocator);
7c673cae 162
b32b8144
FG
163 DISABLE_EXCEPTIONS;
164 test::check_container(x, this->values);
165 test::check_equivalent_keys(x);
166 }
7c673cae
FG
167};
168
b32b8144 169template <class T> struct input_range_construct_test : public range<T>, objects
7c673cae 170{
b32b8144
FG
171 input_range_construct_test() : range<T>(60) {}
172
173 void run() const
174 {
11fdf7f2
TL
175 typename test::random_values<T>::const_iterator begin =
176 this->values.begin(),
177 end = this->values.end();
b32b8144
FG
178 T x(test::input_iterator(begin), test::input_iterator(end), 0, hash,
179 equal_to, allocator);
180
181 DISABLE_EXCEPTIONS;
182 test::check_container(x, this->values);
183 test::check_equivalent_keys(x);
184 }
7c673cae
FG
185};
186
b32b8144 187template <class T> struct copy_range_construct_test : public range<T>, objects
7c673cae 188{
b32b8144
FG
189 copy_range_construct_test() : range<T>(60) {}
190
191 void run() const
192 {
193 T x(test::copy_iterator(this->values.begin()),
194 test::copy_iterator(this->values.end()), 0, hash, equal_to, allocator);
195
196 DISABLE_EXCEPTIONS;
197 test::check_container(x, this->values);
198 test::check_equivalent_keys(x);
199 }
7c673cae
FG
200};
201
b32b8144 202// clang-format off
7c673cae 203EXCEPTION_TESTS(
b32b8144
FG
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),
209 CONTAINER_SEQ)
210// clang-format on
211
7c673cae 212RUN_TESTS()