]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/geometry/index/test/rtree/exceptions/test_exceptions.hpp
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / boost / libs / geometry / index / test / rtree / exceptions / test_exceptions.hpp
CommitLineData
7c673cae
FG
1// Boost.Geometry Index
2//
3// R-tree nodes based on runtime-polymorphism, storing static-size containers
4// test version throwing exceptions on creation
5//
6// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
7//
f67539c2
TL
8// This file was modified by Oracle on 2019.
9// Modifications copyright (c) 2019 Oracle and/or its affiliates.
10// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
11//
7c673cae
FG
12// Use, modification and distribution is subject to the Boost Software License,
13// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
14// http://www.boost.org/LICENSE_1_0.txt)
15
16#ifndef BOOST_GEOMETRY_INDEX_TEST_RTREE_EXCEPTIONS_HPP
17#define BOOST_GEOMETRY_INDEX_TEST_RTREE_EXCEPTIONS_HPP
18
19#include <rtree/test_rtree.hpp>
20
21#include <rtree/exceptions/test_throwing.hpp>
22#include <rtree/exceptions/test_throwing_node.hpp>
23
24#include <boost/geometry/geometries/point.hpp>
25#include <boost/geometry/geometries/box.hpp>
26
27// test value exceptions
28template <typename Parameters>
29void test_rtree_value_exceptions(Parameters const& parameters = Parameters())
30{
31 typedef std::pair<bg::model::point<float, 2, bg::cs::cartesian>, throwing_value> Value;
32 typedef bgi::rtree<Value, Parameters> Tree;
33 typedef typename Tree::bounds_type B;
34
35 throwing_value::reset_calls_counter();
36 throwing_value::set_max_calls((std::numeric_limits<size_t>::max)());
37 std::vector<Value> input;
38 B qbox;
39 generate::input<2>::apply(input, qbox);
40
41 for ( size_t i = 0 ; i < 50 ; i += 2 )
42 {
43 throwing_value::reset_calls_counter();
44 throwing_value::set_max_calls(10000);
45
46 Tree tree(parameters);
47
48 throwing_value::reset_calls_counter();
49 throwing_value::set_max_calls(i);
50
51 BOOST_CHECK_THROW( tree.insert(input.begin(), input.end()), throwing_value_copy_exception );
f67539c2
TL
52
53 BOOST_CHECK(bgi::detail::rtree::utilities::are_counts_ok(tree, false));
7c673cae
FG
54 }
55
56 for ( size_t i = 0 ; i < 20 ; i += 1 )
57 {
58 throwing_value::reset_calls_counter();
59 throwing_value::set_max_calls(i);
60
61 BOOST_CHECK_THROW( Tree tree(input.begin(), input.end(), parameters), throwing_value_copy_exception );
62 }
63
64 for ( size_t i = 0 ; i < 10 ; i += 1 )
65 {
66 throwing_value::reset_calls_counter();
67 throwing_value::set_max_calls(10000);
68
69 Tree tree(parameters);
70
71 tree.insert(input.begin(), input.end());
72
73 throwing_value::reset_calls_counter();
74 throwing_value::set_max_calls(i);
75
76 BOOST_CHECK_THROW( tree.remove(input.begin(), input.end()), throwing_value_copy_exception );
f67539c2
TL
77
78 BOOST_CHECK(bgi::detail::rtree::utilities::are_counts_ok(tree, false));
7c673cae
FG
79 }
80
81 for ( size_t i = 0 ; i < 20 ; i += 2 )
82 {
83 throwing_value::reset_calls_counter();
84 throwing_value::set_max_calls(10000);
85
86 Tree tree(parameters);
87
88 tree.insert(input.begin(), input.end());
89
90 throwing_value::reset_calls_counter();
91 throwing_value::set_max_calls(i);
92
93 BOOST_CHECK_THROW( Tree tree2(tree), throwing_value_copy_exception );
94 }
95
96 for ( size_t i = 0 ; i < 20 ; i += 2 )
97 {
98 throwing_value::reset_calls_counter();
99 throwing_value::set_max_calls(10000);
100
101 Tree tree(parameters);
102 Tree tree2(parameters);
103
104 tree.insert(input.begin(), input.end());
105
106 throwing_value::reset_calls_counter();
107 throwing_value::set_max_calls(i);
108
109 BOOST_CHECK_THROW(tree2 = tree, throwing_value_copy_exception );
f67539c2
TL
110
111 BOOST_CHECK(tree2.empty());
7c673cae
FG
112 }
113}
114
115// test value exceptions
116template <typename Parameters>
117void test_rtree_elements_exceptions(Parameters const& parameters = Parameters())
118{
119 typedef std::pair<bg::model::point<float, 2, bg::cs::cartesian>, throwing_value> Value;
120 typedef bgi::rtree<Value, Parameters> Tree;
121 typedef typename Tree::bounds_type B;
122
123 throwing_value::reset_calls_counter();
124 throwing_value::set_max_calls((std::numeric_limits<size_t>::max)());
125
126 std::vector<Value> input;
127 B qbox;
128 generate::input<2>::apply(input, qbox, 2);
129
130 for ( size_t i = 0 ; i < 100 ; i += 2 )
131 {
132 throwing_varray_settings::reset_calls_counter();
133 throwing_varray_settings::set_max_calls(10000);
134
135 Tree tree(parameters);
136
137 throwing_varray_settings::reset_calls_counter();
138 throwing_varray_settings::set_max_calls(i);
139
140 BOOST_CHECK_THROW( tree.insert(input.begin(), input.end()), throwing_varray_exception );
f67539c2
TL
141
142 BOOST_CHECK(bgi::detail::rtree::utilities::are_counts_ok(tree, false));
7c673cae
FG
143 }
144
145 for ( size_t i = 0 ; i < 100 ; i += 2 )
146 {
147 throwing_varray_settings::reset_calls_counter();
148 throwing_varray_settings::set_max_calls(i);
149
150 throwing_nodes_stats::reset_counters();
151
152 BOOST_CHECK_THROW( Tree tree(input.begin(), input.end(), parameters), throwing_varray_exception );
153
154 BOOST_CHECK_EQUAL(throwing_nodes_stats::internal_nodes_count(), 0u);
155 BOOST_CHECK_EQUAL(throwing_nodes_stats::leafs_count(), 0u);
156 }
157
158 for ( size_t i = 0 ; i < 50 ; i += 2 )
159 {
160 throwing_varray_settings::reset_calls_counter();
161 throwing_varray_settings::set_max_calls(10000);
162
163 Tree tree(parameters);
164
165 tree.insert(input.begin(), input.end());
166
167 throwing_varray_settings::reset_calls_counter();
168 throwing_varray_settings::set_max_calls(i);
169
170 BOOST_CHECK_THROW( tree.remove(input.begin(), input.end()), throwing_varray_exception );
f67539c2
TL
171
172 BOOST_CHECK(bgi::detail::rtree::utilities::are_counts_ok(tree, false));
7c673cae
FG
173 }
174
175 for ( size_t i = 0 ; i < 50 ; i += 2 )
176 {
177 throwing_varray_settings::reset_calls_counter();
178 throwing_varray_settings::set_max_calls(10000);
179
180 Tree tree(parameters);
181
182 tree.insert(input.begin(), input.end());
183
184 throwing_varray_settings::reset_calls_counter();
185 throwing_varray_settings::set_max_calls(i);
186
187 BOOST_CHECK_THROW( Tree tree2(tree), throwing_varray_exception );
188 }
189
190 for ( size_t i = 0 ; i < 50 ; i += 2 )
191 {
192 throwing_varray_settings::reset_calls_counter();
193 throwing_varray_settings::set_max_calls(10000);
194
195 Tree tree(parameters);
196 Tree tree2(parameters);
197
198 tree.insert(input.begin(), input.end());
199
200 throwing_varray_settings::reset_calls_counter();
201 throwing_varray_settings::set_max_calls(i);
202
203 BOOST_CHECK_THROW(tree2 = tree, throwing_varray_exception );
f67539c2
TL
204
205 BOOST_CHECK(tree2.empty());
7c673cae
FG
206 }
207}
208
209#endif // BOOST_GEOMETRY_INDEX_TEST_RTREE_EXCEPTIONS_HPP