mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-13 00:22:10 +00:00
Improved exception safety of the r-tree.
Requirement 'nonthrowing copy constructor of the BoundingObject/CoordinateType' changed to 'exception-safe copy constructor of the BoundingObject/CoordinateType'. From now the r-tree do not use erase() method of the elements containers. It uses copy_from_back() and pop_back() instead. erase() removed from pushable_array. Added various memory leaks fixes taking throwing by Element's copy constructor into account. Tests added. Docs modified. [SVN r81445]
This commit is contained in:
@@ -87,14 +87,93 @@ void test_rtree_value_exceptions(Parameters const& parameters = Parameters())
|
||||
}
|
||||
}
|
||||
|
||||
// test value exceptions
|
||||
template <typename Parameters>
|
||||
void test_rtree_elements_exceptions(Parameters const& parameters = Parameters())
|
||||
{
|
||||
typedef std::pair<bg::model::point<float, 2, bg::cs::cartesian>, throwing_value> Value;
|
||||
typedef bgi::rtree<Value, Parameters> Tree;
|
||||
typedef typename Tree::box_type B;
|
||||
|
||||
throwing_value::reset_calls_counter();
|
||||
throwing_value::set_max_calls((std::numeric_limits<size_t>::max)());
|
||||
|
||||
std::vector<Value> input;
|
||||
B qbox;
|
||||
generate_input<2>::apply(input, qbox, 2);
|
||||
|
||||
for ( size_t i = 0 ; i < 100 ; i += 2 )
|
||||
{
|
||||
throwing_pushable_array_settings::reset_calls_counter();
|
||||
throwing_pushable_array_settings::set_max_calls(10000);
|
||||
|
||||
Tree tree(parameters);
|
||||
|
||||
throwing_pushable_array_settings::reset_calls_counter();
|
||||
throwing_pushable_array_settings::set_max_calls(i);
|
||||
|
||||
BOOST_CHECK_THROW( tree.insert(input.begin(), input.end()), throwing_pushable_array_exception );
|
||||
}
|
||||
|
||||
for ( size_t i = 0 ; i < 50 ; i += 2 )
|
||||
{
|
||||
throwing_pushable_array_settings::reset_calls_counter();
|
||||
throwing_pushable_array_settings::set_max_calls(10000);
|
||||
|
||||
Tree tree(parameters);
|
||||
|
||||
tree.insert(input.begin(), input.end());
|
||||
|
||||
throwing_pushable_array_settings::reset_calls_counter();
|
||||
throwing_pushable_array_settings::set_max_calls(i);
|
||||
|
||||
BOOST_CHECK_THROW( tree.remove(input.begin(), input.end()), throwing_pushable_array_exception );
|
||||
}
|
||||
|
||||
for ( size_t i = 0 ; i < 50 ; i += 2 )
|
||||
{
|
||||
throwing_pushable_array_settings::reset_calls_counter();
|
||||
throwing_pushable_array_settings::set_max_calls(10000);
|
||||
|
||||
Tree tree(parameters);
|
||||
|
||||
tree.insert(input.begin(), input.end());
|
||||
|
||||
throwing_pushable_array_settings::reset_calls_counter();
|
||||
throwing_pushable_array_settings::set_max_calls(i);
|
||||
|
||||
BOOST_CHECK_THROW( Tree tree2(tree), throwing_pushable_array_exception );
|
||||
}
|
||||
|
||||
for ( size_t i = 0 ; i < 50 ; i += 2 )
|
||||
{
|
||||
throwing_pushable_array_settings::reset_calls_counter();
|
||||
throwing_pushable_array_settings::set_max_calls(10000);
|
||||
|
||||
Tree tree(parameters);
|
||||
Tree tree2(parameters);
|
||||
|
||||
tree.insert(input.begin(), input.end());
|
||||
|
||||
throwing_pushable_array_settings::reset_calls_counter();
|
||||
throwing_pushable_array_settings::set_max_calls(i);
|
||||
|
||||
BOOST_CHECK_THROW(tree2 = tree, throwing_pushable_array_exception );
|
||||
}
|
||||
}
|
||||
|
||||
int test_main(int, char* [])
|
||||
{
|
||||
test_rtree_value_exceptions< bgi::linear<4, 2> >();
|
||||
test_rtree_value_exceptions(bgi::runtime::linear(4, 2));
|
||||
test_rtree_value_exceptions< bgi::quadratic<4, 2> >();
|
||||
test_rtree_value_exceptions(bgi::runtime::quadratic(4, 2));
|
||||
test_rtree_value_exceptions< bgi::rstar<4, 2> >();
|
||||
test_rtree_value_exceptions(bgi::runtime::rstar(4, 2));
|
||||
test_rtree_value_exceptions< bgi::rstar<4, 2, 0, 2> >();
|
||||
test_rtree_value_exceptions(bgi::runtime::rstar(4, 2, 0, 2));
|
||||
|
||||
test_rtree_elements_exceptions< bgi::linear_throwing<4, 2> >();
|
||||
test_rtree_elements_exceptions< bgi::quadratic_throwing<4, 2> >();
|
||||
test_rtree_elements_exceptions< bgi::rstar_throwing<4, 2, 0, 2> >();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user