Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r84046 - trunk/libs/geometry/index/test/rtree/exceptions
From: adam.wulkiewicz_at_[hidden]
Date: 2013-04-25 10:09:04


Author: awulkiew
Date: 2013-04-25 10:09:02 EDT (Thu, 25 Apr 2013)
New Revision: 84046
URL: http://svn.boost.org/trac/boost/changeset/84046

Log:
geometry.index test: rtree exceptions test divided into smaller ones.
Added:
   trunk/libs/geometry/index/test/rtree/exceptions/rtree_exceptions_lin.cpp (contents, props changed)
   trunk/libs/geometry/index/test/rtree/exceptions/rtree_exceptions_qua.cpp (contents, props changed)
   trunk/libs/geometry/index/test/rtree/exceptions/rtree_exceptions_rst.cpp (contents, props changed)
   trunk/libs/geometry/index/test/rtree/exceptions/test_exceptions.hpp (contents, props changed)
   trunk/libs/geometry/index/test/rtree/exceptions/test_throwing_node.hpp (contents, props changed)
Removed:
   trunk/libs/geometry/index/test/rtree/exceptions/rtree_exceptions.cpp
   trunk/libs/geometry/index/test/rtree/exceptions/test_rtree_exceptions.hpp
Text files modified:
   trunk/libs/geometry/index/test/rtree/exceptions/Jamfile.v2 | 16 ++++++++++++----
   1 files changed, 12 insertions(+), 4 deletions(-)

Modified: trunk/libs/geometry/index/test/rtree/exceptions/Jamfile.v2
==============================================================================
--- trunk/libs/geometry/index/test/rtree/exceptions/Jamfile.v2 (original)
+++ trunk/libs/geometry/index/test/rtree/exceptions/Jamfile.v2 2013-04-25 10:09:02 EDT (Thu, 25 Apr 2013)
@@ -6,8 +6,16 @@
 # Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 # http://www.boost.org/LICENSE_1_0.txt)
 
-test-suite boost-geometry-index-rtree-exceptions
- :
- [ run rtree_exceptions.cpp ]
- ;
+rule test_all
+{
+ local all_rules = ;
 
+ for local fileb in [ glob *.cpp ]
+ {
+ all_rules += [ run $(fileb) ] ;
+ }
+
+ return $(all_rules) ;
+}
+
+test-suite boost-geometry-index-rtree-exceptions : [ test_all r ] ;

Deleted: trunk/libs/geometry/index/test/rtree/exceptions/rtree_exceptions.cpp
==============================================================================
--- trunk/libs/geometry/index/test/rtree/exceptions/rtree_exceptions.cpp 2013-04-25 10:09:02 EDT (Thu, 25 Apr 2013)
+++ (empty file)
@@ -1,179 +0,0 @@
-// Boost.Geometry Index
-// Unit Test
-
-// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
-
-// Use, modification and distribution is subject to the Boost Software License,
-// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#include <rtree/exceptions/test_rtree_exceptions.hpp>
-
-#include <boost/geometry/geometries/point_xy.hpp>
-#include <boost/geometry/geometries/point.hpp>
-#include <boost/geometry/geometries/box.hpp>
-
-// test value exceptions
-template <typename Parameters>
-void test_rtree_value_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);
-
- for ( size_t i = 0 ; i < 50 ; i += 2 )
- {
- throwing_value::reset_calls_counter();
- throwing_value::set_max_calls(10000);
-
- Tree tree(parameters);
-
- throwing_value::reset_calls_counter();
- throwing_value::set_max_calls(i);
-
- BOOST_CHECK_THROW( tree.insert(input.begin(), input.end()), throwing_value_copy_exception );
- }
-
- for ( size_t i = 0 ; i < 20 ; i += 2 )
- {
- throwing_value::reset_calls_counter();
- throwing_value::set_max_calls(10000);
-
- Tree tree(parameters);
-
- tree.insert(input.begin(), input.end());
-
- throwing_value::reset_calls_counter();
- throwing_value::set_max_calls(i);
-
- BOOST_CHECK_THROW( tree.remove(input.begin(), input.end()), throwing_value_copy_exception );
- }
-
- for ( size_t i = 0 ; i < 20 ; i += 2 )
- {
- throwing_value::reset_calls_counter();
- throwing_value::set_max_calls(10000);
-
- Tree tree(parameters);
-
- tree.insert(input.begin(), input.end());
-
- throwing_value::reset_calls_counter();
- throwing_value::set_max_calls(i);
-
- BOOST_CHECK_THROW( Tree tree2(tree), throwing_value_copy_exception );
- }
-
- for ( size_t i = 0 ; i < 20 ; i += 2 )
- {
- throwing_value::reset_calls_counter();
- throwing_value::set_max_calls(10000);
-
- Tree tree(parameters);
- Tree tree2(parameters);
-
- tree.insert(input.begin(), input.end());
-
- throwing_value::reset_calls_counter();
- throwing_value::set_max_calls(i);
-
- BOOST_CHECK_THROW(tree2 = tree, throwing_value_copy_exception );
- }
-}
-
-// 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_varray_settings::reset_calls_counter();
- throwing_varray_settings::set_max_calls(10000);
-
- Tree tree(parameters);
-
- throwing_varray_settings::reset_calls_counter();
- throwing_varray_settings::set_max_calls(i);
-
- BOOST_CHECK_THROW( tree.insert(input.begin(), input.end()), throwing_varray_exception );
- }
-
- for ( size_t i = 0 ; i < 50 ; i += 2 )
- {
- throwing_varray_settings::reset_calls_counter();
- throwing_varray_settings::set_max_calls(10000);
-
- Tree tree(parameters);
-
- tree.insert(input.begin(), input.end());
-
- throwing_varray_settings::reset_calls_counter();
- throwing_varray_settings::set_max_calls(i);
-
- BOOST_CHECK_THROW( tree.remove(input.begin(), input.end()), throwing_varray_exception );
- }
-
- for ( size_t i = 0 ; i < 50 ; i += 2 )
- {
- throwing_varray_settings::reset_calls_counter();
- throwing_varray_settings::set_max_calls(10000);
-
- Tree tree(parameters);
-
- tree.insert(input.begin(), input.end());
-
- throwing_varray_settings::reset_calls_counter();
- throwing_varray_settings::set_max_calls(i);
-
- BOOST_CHECK_THROW( Tree tree2(tree), throwing_varray_exception );
- }
-
- for ( size_t i = 0 ; i < 50 ; i += 2 )
- {
- throwing_varray_settings::reset_calls_counter();
- throwing_varray_settings::set_max_calls(10000);
-
- Tree tree(parameters);
- Tree tree2(parameters);
-
- tree.insert(input.begin(), input.end());
-
- throwing_varray_settings::reset_calls_counter();
- throwing_varray_settings::set_max_calls(i);
-
- BOOST_CHECK_THROW(tree2 = tree, throwing_varray_exception );
- }
-}
-
-int test_main(int, char* [])
-{
- test_rtree_value_exceptions< bgi::linear<4, 2> >();
- test_rtree_value_exceptions(bgi::dynamic_linear(4, 2));
- test_rtree_value_exceptions< bgi::quadratic<4, 2> >();
- test_rtree_value_exceptions(bgi::dynamic_quadratic(4, 2));
- test_rtree_value_exceptions< bgi::rstar<4, 2, 0, 2> >();
- test_rtree_value_exceptions(bgi::dynamic_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;
-}

Added: trunk/libs/geometry/index/test/rtree/exceptions/rtree_exceptions_lin.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/geometry/index/test/rtree/exceptions/rtree_exceptions_lin.cpp 2013-04-25 10:09:02 EDT (Thu, 25 Apr 2013)
@@ -0,0 +1,20 @@
+// Boost.Geometry Index
+// Unit Test
+
+// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <rtree/exceptions/test_exceptions.hpp>
+
+int test_main(int, char* [])
+{
+ test_rtree_value_exceptions< bgi::linear<4, 2> >();
+ test_rtree_value_exceptions(bgi::dynamic_linear(4, 2));
+
+ test_rtree_elements_exceptions< bgi::linear_throwing<4, 2> >();
+
+ return 0;
+}

Added: trunk/libs/geometry/index/test/rtree/exceptions/rtree_exceptions_qua.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/geometry/index/test/rtree/exceptions/rtree_exceptions_qua.cpp 2013-04-25 10:09:02 EDT (Thu, 25 Apr 2013)
@@ -0,0 +1,20 @@
+// Boost.Geometry Index
+// Unit Test
+
+// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <rtree/exceptions/test_exceptions.hpp>
+
+int test_main(int, char* [])
+{
+ test_rtree_value_exceptions< bgi::quadratic<4, 2> >();
+ test_rtree_value_exceptions(bgi::dynamic_quadratic(4, 2));
+
+ test_rtree_elements_exceptions< bgi::quadratic_throwing<4, 2> >();
+
+ return 0;
+}

Added: trunk/libs/geometry/index/test/rtree/exceptions/rtree_exceptions_rst.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/geometry/index/test/rtree/exceptions/rtree_exceptions_rst.cpp 2013-04-25 10:09:02 EDT (Thu, 25 Apr 2013)
@@ -0,0 +1,20 @@
+// Boost.Geometry Index
+// Unit Test
+
+// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <rtree/exceptions/test_exceptions.hpp>
+
+int test_main(int, char* [])
+{
+ test_rtree_value_exceptions< bgi::rstar<4, 2, 0, 2> >();
+ test_rtree_value_exceptions(bgi::dynamic_rstar(4, 2, 0, 2));
+
+ test_rtree_elements_exceptions< bgi::rstar_throwing<4, 2, 0, 2> >();
+
+ return 0;
+}

Added: trunk/libs/geometry/index/test/rtree/exceptions/test_exceptions.hpp
==============================================================================
--- (empty file)
+++ trunk/libs/geometry/index/test/rtree/exceptions/test_exceptions.hpp 2013-04-25 10:09:02 EDT (Thu, 25 Apr 2013)
@@ -0,0 +1,172 @@
+// Boost.Geometry Index
+//
+// R-tree nodes based on runtime-polymorphism, storing static-size containers
+// test version throwing exceptions on creation
+//
+// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+//
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_INDEX_TEST_RTREE_EXCEPTIONS_HPP
+#define BOOST_GEOMETRY_INDEX_TEST_RTREE_EXCEPTIONS_HPP
+
+#include <rtree/test_rtree.hpp>
+
+#include <rtree/exceptions/test_throwing.hpp>
+#include <rtree/exceptions/test_throwing_node.hpp>
+
+#include <boost/geometry/geometries/point.hpp>
+#include <boost/geometry/geometries/box.hpp>
+
+// test value exceptions
+template <typename Parameters>
+void test_rtree_value_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);
+
+ for ( size_t i = 0 ; i < 50 ; i += 2 )
+ {
+ throwing_value::reset_calls_counter();
+ throwing_value::set_max_calls(10000);
+
+ Tree tree(parameters);
+
+ throwing_value::reset_calls_counter();
+ throwing_value::set_max_calls(i);
+
+ BOOST_CHECK_THROW( tree.insert(input.begin(), input.end()), throwing_value_copy_exception );
+ }
+
+ for ( size_t i = 0 ; i < 20 ; i += 2 )
+ {
+ throwing_value::reset_calls_counter();
+ throwing_value::set_max_calls(10000);
+
+ Tree tree(parameters);
+
+ tree.insert(input.begin(), input.end());
+
+ throwing_value::reset_calls_counter();
+ throwing_value::set_max_calls(i);
+
+ BOOST_CHECK_THROW( tree.remove(input.begin(), input.end()), throwing_value_copy_exception );
+ }
+
+ for ( size_t i = 0 ; i < 20 ; i += 2 )
+ {
+ throwing_value::reset_calls_counter();
+ throwing_value::set_max_calls(10000);
+
+ Tree tree(parameters);
+
+ tree.insert(input.begin(), input.end());
+
+ throwing_value::reset_calls_counter();
+ throwing_value::set_max_calls(i);
+
+ BOOST_CHECK_THROW( Tree tree2(tree), throwing_value_copy_exception );
+ }
+
+ for ( size_t i = 0 ; i < 20 ; i += 2 )
+ {
+ throwing_value::reset_calls_counter();
+ throwing_value::set_max_calls(10000);
+
+ Tree tree(parameters);
+ Tree tree2(parameters);
+
+ tree.insert(input.begin(), input.end());
+
+ throwing_value::reset_calls_counter();
+ throwing_value::set_max_calls(i);
+
+ BOOST_CHECK_THROW(tree2 = tree, throwing_value_copy_exception );
+ }
+}
+
+// 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_varray_settings::reset_calls_counter();
+ throwing_varray_settings::set_max_calls(10000);
+
+ Tree tree(parameters);
+
+ throwing_varray_settings::reset_calls_counter();
+ throwing_varray_settings::set_max_calls(i);
+
+ BOOST_CHECK_THROW( tree.insert(input.begin(), input.end()), throwing_varray_exception );
+ }
+
+ for ( size_t i = 0 ; i < 50 ; i += 2 )
+ {
+ throwing_varray_settings::reset_calls_counter();
+ throwing_varray_settings::set_max_calls(10000);
+
+ Tree tree(parameters);
+
+ tree.insert(input.begin(), input.end());
+
+ throwing_varray_settings::reset_calls_counter();
+ throwing_varray_settings::set_max_calls(i);
+
+ BOOST_CHECK_THROW( tree.remove(input.begin(), input.end()), throwing_varray_exception );
+ }
+
+ for ( size_t i = 0 ; i < 50 ; i += 2 )
+ {
+ throwing_varray_settings::reset_calls_counter();
+ throwing_varray_settings::set_max_calls(10000);
+
+ Tree tree(parameters);
+
+ tree.insert(input.begin(), input.end());
+
+ throwing_varray_settings::reset_calls_counter();
+ throwing_varray_settings::set_max_calls(i);
+
+ BOOST_CHECK_THROW( Tree tree2(tree), throwing_varray_exception );
+ }
+
+ for ( size_t i = 0 ; i < 50 ; i += 2 )
+ {
+ throwing_varray_settings::reset_calls_counter();
+ throwing_varray_settings::set_max_calls(10000);
+
+ Tree tree(parameters);
+ Tree tree2(parameters);
+
+ tree.insert(input.begin(), input.end());
+
+ throwing_varray_settings::reset_calls_counter();
+ throwing_varray_settings::set_max_calls(i);
+
+ BOOST_CHECK_THROW(tree2 = tree, throwing_varray_exception );
+ }
+}
+
+#endif // BOOST_GEOMETRY_INDEX_TEST_RTREE_EXCEPTIONS_HPP

Deleted: trunk/libs/geometry/index/test/rtree/exceptions/test_rtree_exceptions.hpp
==============================================================================
--- trunk/libs/geometry/index/test/rtree/exceptions/test_rtree_exceptions.hpp 2013-04-25 10:09:02 EDT (Thu, 25 Apr 2013)
+++ (empty file)
@@ -1,295 +0,0 @@
-// Boost.Geometry Index
-//
-// R-tree nodes based on runtime-polymorphism, storing static-size containers
-// test version throwing exceptions on creation
-//
-// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
-//
-// Use, modification and distribution is subject to the Boost Software License,
-// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#ifndef BOOST_GEOMETRY_INDEX_TEST_RTREE_EXCEPTIONS_HPP
-#define BOOST_GEOMETRY_INDEX_TEST_RTREE_EXCEPTIONS_HPP
-
-#include <rtree/test_rtree.hpp>
-
-#include <boost/geometry/index/detail/rtree/node/dynamic_visitor.hpp>
-
-#include <rtree/exceptions/test_throwing.hpp>
-
-namespace boost { namespace geometry { namespace index {
-
-template <size_t MaxElements, size_t MinElements>
-struct linear_throwing : public linear<MaxElements, MinElements> {};
-
-template <size_t MaxElements, size_t MinElements>
-struct quadratic_throwing : public quadratic<MaxElements, MinElements> {};
-
-template <size_t MaxElements, size_t MinElements, size_t OverlapCostThreshold = 0, size_t ReinsertedElements = detail::default_rstar_reinserted_elements_s<MaxElements>::value>
-struct rstar_throwing : public rstar<MaxElements, MinElements, OverlapCostThreshold, ReinsertedElements> {};
-
-namespace detail { namespace rtree {
-
-// options implementation (from options.hpp)
-
-struct node_throwing_d_mem_static_tag {};
-
-template <size_t MaxElements, size_t MinElements>
-struct options_type< linear_throwing<MaxElements, MinElements> >
-{
- typedef options<
- linear_throwing<MaxElements, MinElements>,
- insert_default_tag, choose_by_content_diff_tag, split_default_tag, linear_tag,
- node_throwing_d_mem_static_tag
- > type;
-};
-
-template <size_t MaxElements, size_t MinElements>
-struct options_type< quadratic_throwing<MaxElements, MinElements> >
-{
- typedef options<
- quadratic_throwing<MaxElements, MinElements>,
- insert_default_tag, choose_by_content_diff_tag, split_default_tag, quadratic_tag,
- node_throwing_d_mem_static_tag
- > type;
-};
-
-template <size_t MaxElements, size_t MinElements, size_t OverlapCostThreshold, size_t ReinsertedElements>
-struct options_type< rstar_throwing<MaxElements, MinElements, OverlapCostThreshold, ReinsertedElements> >
-{
- typedef options<
- rstar_throwing<MaxElements, MinElements, OverlapCostThreshold, ReinsertedElements>,
- insert_reinsert_tag, choose_by_overlap_diff_tag, split_default_tag, rstar_tag,
- node_throwing_d_mem_static_tag
- > type;
-};
-
-}} // namespace detail::rtree
-
-// node implementation
-
-namespace detail { namespace rtree {
-
-template <typename Value, typename Parameters, typename Box, typename Allocators>
-struct dynamic_internal_node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
- : public dynamic_node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
-{
- typedef throwing_varray<
- rtree::ptr_pair<Box, typename Allocators::node_pointer>,
- Parameters::max_elements + 1
- > elements_type;
-
- template <typename Dummy>
- inline dynamic_internal_node(Dummy const&) {}
-
- void apply_visitor(dynamic_visitor<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag, false> & v) { v(*this); }
- void apply_visitor(dynamic_visitor<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag, true> & v) const { v(*this); }
-
- elements_type elements;
-};
-
-template <typename Value, typename Parameters, typename Box, typename Allocators>
-struct dynamic_leaf<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
- : public dynamic_node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
-{
- typedef throwing_varray<Value, Parameters::max_elements + 1> elements_type;
-
- template <typename Dummy>
- inline dynamic_leaf(Dummy const&) {}
-
- void apply_visitor(dynamic_visitor<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag, false> & v) { v(*this); }
- void apply_visitor(dynamic_visitor<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag, true> & v) const { v(*this); }
-
- elements_type elements;
-};
-
-// elements derived type
-template <typename OldValue, size_t N, typename NewValue>
-struct container_from_elements_type<throwing_varray<OldValue, N>, NewValue>
-{
- typedef throwing_varray<NewValue, N> type;
-};
-
-// nodes traits
-
-template <typename Value, typename Parameters, typename Box, typename Allocators>
-struct node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
-{
- typedef dynamic_node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag> type;
-};
-
-template <typename Value, typename Parameters, typename Box, typename Allocators>
-struct internal_node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
-{
- typedef dynamic_internal_node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag> type;
-};
-
-template <typename Value, typename Parameters, typename Box, typename Allocators>
-struct leaf<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
-{
- typedef dynamic_leaf<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag> type;
-};
-
-template <typename Value, typename Parameters, typename Box, typename Allocators, bool IsVisitableConst>
-struct visitor<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag, IsVisitableConst>
-{
- typedef dynamic_visitor<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag, IsVisitableConst> type;
-};
-
-// allocators
-
-template <typename Allocator, typename Value, typename Parameters, typename Box>
-class allocators<Allocator, Value, Parameters, Box, node_throwing_d_mem_static_tag>
- : public Allocator::template rebind<
- typename internal_node<
- Value, Parameters, Box,
- allocators<Allocator, Value, Parameters, Box, node_throwing_d_mem_static_tag>,
- node_throwing_d_mem_static_tag
- >::type
- >::other
- , Allocator::template rebind<
- typename leaf<
- Value, Parameters, Box,
- allocators<Allocator, Value, Parameters, Box, node_throwing_d_mem_static_tag>,
- node_throwing_d_mem_static_tag
- >::type
- >::other
-{
-public:
- typedef typename Allocator::size_type size_type;
-
- typedef typename Allocator::template rebind<
- typename node<Value, Parameters, Box, allocators, node_throwing_d_mem_static_tag>::type
- >::other::pointer node_pointer;
-
- typedef typename Allocator::template rebind<
- typename internal_node<Value, Parameters, Box, allocators, node_throwing_d_mem_static_tag>::type
- >::other::pointer internal_node_pointer;
-
- typedef typename Allocator::template rebind<
- typename internal_node<Value, Parameters, Box, allocators, node_throwing_d_mem_static_tag>::type
- >::other internal_node_allocator_type;
-
- typedef typename Allocator::template rebind<
- typename leaf<Value, Parameters, Box, allocators, node_throwing_d_mem_static_tag>::type
- >::other leaf_allocator_type;
-
- inline allocators()
- : internal_node_allocator_type()
- , leaf_allocator_type()
- {}
-
- template <typename Alloc>
- inline explicit allocators(Alloc const& alloc)
- : internal_node_allocator_type(alloc)
- , leaf_allocator_type(alloc)
- {}
-
- inline allocators(BOOST_FWD_REF(allocators) a)
- : internal_node_allocator_type(boost::move(a.internal_node_allocator()))
- , leaf_allocator_type(boost::move(a.leaf_allocator()))
- {}
-
- inline allocators & operator=(BOOST_FWD_REF(allocators) a)
- {
- internal_node_allocator() = ::boost::move(a.internal_node_allocator());
- leaf_allocator() = ::boost::move(a.leaf_allocator());
- return *this;
- }
-
-#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- inline allocators & operator=(allocators const& a)
- {
- internal_node_allocator() = a.internal_node_allocator();
- leaf_allocator() = a.leaf_allocator();
- return *this;
- }
-#endif
-
- void swap(allocators & a)
- {
- boost::swap(internal_node_allocator(), a.internal_node_allocator());
- boost::swap(leaf_allocator(), a.leaf_allocator());
- }
-
- bool operator==(allocators const& a) const { return leaf_allocator() == a.leaf_allocator(); }
- template <typename Alloc>
- bool operator==(Alloc const& a) const { return leaf_allocator() == leaf_allocator_type(a); }
-
- Allocator allocator() const { return Allocator(leaf_allocator()); }
-
- internal_node_allocator_type & internal_node_allocator() { return *this; }
- internal_node_allocator_type const& internal_node_allocator() const { return *this; }
- leaf_allocator_type & leaf_allocator() { return *this; }
- leaf_allocator_type const& leaf_allocator() const { return *this; }
-};
-
-struct node_bad_alloc : public std::exception
-{
- const char * what() const throw() { return "internal node creation failed."; }
-};
-
-struct throwing_node_settings
-{
- static void throw_if_required()
- {
- // throw if counter meets max count
- if ( get_max_calls_ref() <= get_calls_counter_ref() )
- throw node_bad_alloc();
- else
- ++get_calls_counter_ref();
- }
-
- static void reset_calls_counter() { get_calls_counter_ref() = 0; }
- static void set_max_calls(size_t mc) { get_max_calls_ref() = mc; }
-
- static size_t & get_calls_counter_ref() { static size_t cc = 0; return cc; }
- static size_t & get_max_calls_ref() { static size_t mc = (std::numeric_limits<size_t>::max)(); return mc; }
-};
-
-// create_node
-
-template <typename Allocators, typename Value, typename Parameters, typename Box>
-struct create_node<
- Allocators,
- dynamic_internal_node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
->
-{
- static inline typename Allocators::node_pointer
- apply(Allocators & allocators)
- {
- // throw if counter meets max count
- throwing_node_settings::throw_if_required();
-
- return create_dynamic_node<
- typename Allocators::node_pointer,
- dynamic_internal_node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
- >::apply(allocators.internal_node_allocator());
- }
-};
-
-template <typename Allocators, typename Value, typename Parameters, typename Box>
-struct create_node<
- Allocators,
- dynamic_leaf<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
->
-{
- static inline typename Allocators::node_pointer
- apply(Allocators & allocators)
- {
- // throw if counter meets max count
- throwing_node_settings::throw_if_required();
-
- return create_dynamic_node<
- typename Allocators::node_pointer,
- dynamic_leaf<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
- >::apply(allocators.leaf_allocator());
- }
-};
-
-}} // namespace detail::rtree
-
-}}} // namespace boost::geometry::index
-
-#endif // BOOST_GEOMETRY_INDEX_TEST_RTREE_EXCEPTIONS_HPP

Added: trunk/libs/geometry/index/test/rtree/exceptions/test_throwing_node.hpp
==============================================================================
--- (empty file)
+++ trunk/libs/geometry/index/test/rtree/exceptions/test_throwing_node.hpp 2013-04-25 10:09:02 EDT (Thu, 25 Apr 2013)
@@ -0,0 +1,293 @@
+// Boost.Geometry Index
+//
+// R-tree nodes based on runtime-polymorphism, storing static-size containers
+// test version throwing exceptions on creation
+//
+// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+//
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_INDEX_TEST_RTREE_THROWING_NODE_HPP
+#define BOOST_GEOMETRY_INDEX_TEST_RTREE_THROWING_NODE_HPP
+
+#include <boost/geometry/index/detail/rtree/node/dynamic_visitor.hpp>
+
+#include <rtree/exceptions/test_throwing.hpp>
+
+namespace boost { namespace geometry { namespace index {
+
+template <size_t MaxElements, size_t MinElements>
+struct linear_throwing : public linear<MaxElements, MinElements> {};
+
+template <size_t MaxElements, size_t MinElements>
+struct quadratic_throwing : public quadratic<MaxElements, MinElements> {};
+
+template <size_t MaxElements, size_t MinElements, size_t OverlapCostThreshold = 0, size_t ReinsertedElements = detail::default_rstar_reinserted_elements_s<MaxElements>::value>
+struct rstar_throwing : public rstar<MaxElements, MinElements, OverlapCostThreshold, ReinsertedElements> {};
+
+namespace detail { namespace rtree {
+
+// options implementation (from options.hpp)
+
+struct node_throwing_d_mem_static_tag {};
+
+template <size_t MaxElements, size_t MinElements>
+struct options_type< linear_throwing<MaxElements, MinElements> >
+{
+ typedef options<
+ linear_throwing<MaxElements, MinElements>,
+ insert_default_tag, choose_by_content_diff_tag, split_default_tag, linear_tag,
+ node_throwing_d_mem_static_tag
+ > type;
+};
+
+template <size_t MaxElements, size_t MinElements>
+struct options_type< quadratic_throwing<MaxElements, MinElements> >
+{
+ typedef options<
+ quadratic_throwing<MaxElements, MinElements>,
+ insert_default_tag, choose_by_content_diff_tag, split_default_tag, quadratic_tag,
+ node_throwing_d_mem_static_tag
+ > type;
+};
+
+template <size_t MaxElements, size_t MinElements, size_t OverlapCostThreshold, size_t ReinsertedElements>
+struct options_type< rstar_throwing<MaxElements, MinElements, OverlapCostThreshold, ReinsertedElements> >
+{
+ typedef options<
+ rstar_throwing<MaxElements, MinElements, OverlapCostThreshold, ReinsertedElements>,
+ insert_reinsert_tag, choose_by_overlap_diff_tag, split_default_tag, rstar_tag,
+ node_throwing_d_mem_static_tag
+ > type;
+};
+
+}} // namespace detail::rtree
+
+// node implementation
+
+namespace detail { namespace rtree {
+
+template <typename Value, typename Parameters, typename Box, typename Allocators>
+struct dynamic_internal_node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
+ : public dynamic_node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
+{
+ typedef throwing_varray<
+ rtree::ptr_pair<Box, typename Allocators::node_pointer>,
+ Parameters::max_elements + 1
+ > elements_type;
+
+ template <typename Dummy>
+ inline dynamic_internal_node(Dummy const&) {}
+
+ void apply_visitor(dynamic_visitor<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag, false> & v) { v(*this); }
+ void apply_visitor(dynamic_visitor<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag, true> & v) const { v(*this); }
+
+ elements_type elements;
+};
+
+template <typename Value, typename Parameters, typename Box, typename Allocators>
+struct dynamic_leaf<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
+ : public dynamic_node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
+{
+ typedef throwing_varray<Value, Parameters::max_elements + 1> elements_type;
+
+ template <typename Dummy>
+ inline dynamic_leaf(Dummy const&) {}
+
+ void apply_visitor(dynamic_visitor<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag, false> & v) { v(*this); }
+ void apply_visitor(dynamic_visitor<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag, true> & v) const { v(*this); }
+
+ elements_type elements;
+};
+
+// elements derived type
+template <typename OldValue, size_t N, typename NewValue>
+struct container_from_elements_type<throwing_varray<OldValue, N>, NewValue>
+{
+ typedef throwing_varray<NewValue, N> type;
+};
+
+// nodes traits
+
+template <typename Value, typename Parameters, typename Box, typename Allocators>
+struct node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
+{
+ typedef dynamic_node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag> type;
+};
+
+template <typename Value, typename Parameters, typename Box, typename Allocators>
+struct internal_node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
+{
+ typedef dynamic_internal_node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag> type;
+};
+
+template <typename Value, typename Parameters, typename Box, typename Allocators>
+struct leaf<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
+{
+ typedef dynamic_leaf<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag> type;
+};
+
+template <typename Value, typename Parameters, typename Box, typename Allocators, bool IsVisitableConst>
+struct visitor<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag, IsVisitableConst>
+{
+ typedef dynamic_visitor<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag, IsVisitableConst> type;
+};
+
+// allocators
+
+template <typename Allocator, typename Value, typename Parameters, typename Box>
+class allocators<Allocator, Value, Parameters, Box, node_throwing_d_mem_static_tag>
+ : public Allocator::template rebind<
+ typename internal_node<
+ Value, Parameters, Box,
+ allocators<Allocator, Value, Parameters, Box, node_throwing_d_mem_static_tag>,
+ node_throwing_d_mem_static_tag
+ >::type
+ >::other
+ , Allocator::template rebind<
+ typename leaf<
+ Value, Parameters, Box,
+ allocators<Allocator, Value, Parameters, Box, node_throwing_d_mem_static_tag>,
+ node_throwing_d_mem_static_tag
+ >::type
+ >::other
+{
+public:
+ typedef typename Allocator::size_type size_type;
+
+ typedef typename Allocator::template rebind<
+ typename node<Value, Parameters, Box, allocators, node_throwing_d_mem_static_tag>::type
+ >::other::pointer node_pointer;
+
+ typedef typename Allocator::template rebind<
+ typename internal_node<Value, Parameters, Box, allocators, node_throwing_d_mem_static_tag>::type
+ >::other::pointer internal_node_pointer;
+
+ typedef typename Allocator::template rebind<
+ typename internal_node<Value, Parameters, Box, allocators, node_throwing_d_mem_static_tag>::type
+ >::other internal_node_allocator_type;
+
+ typedef typename Allocator::template rebind<
+ typename leaf<Value, Parameters, Box, allocators, node_throwing_d_mem_static_tag>::type
+ >::other leaf_allocator_type;
+
+ inline allocators()
+ : internal_node_allocator_type()
+ , leaf_allocator_type()
+ {}
+
+ template <typename Alloc>
+ inline explicit allocators(Alloc const& alloc)
+ : internal_node_allocator_type(alloc)
+ , leaf_allocator_type(alloc)
+ {}
+
+ inline allocators(BOOST_FWD_REF(allocators) a)
+ : internal_node_allocator_type(boost::move(a.internal_node_allocator()))
+ , leaf_allocator_type(boost::move(a.leaf_allocator()))
+ {}
+
+ inline allocators & operator=(BOOST_FWD_REF(allocators) a)
+ {
+ internal_node_allocator() = ::boost::move(a.internal_node_allocator());
+ leaf_allocator() = ::boost::move(a.leaf_allocator());
+ return *this;
+ }
+
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+ inline allocators & operator=(allocators const& a)
+ {
+ internal_node_allocator() = a.internal_node_allocator();
+ leaf_allocator() = a.leaf_allocator();
+ return *this;
+ }
+#endif
+
+ void swap(allocators & a)
+ {
+ boost::swap(internal_node_allocator(), a.internal_node_allocator());
+ boost::swap(leaf_allocator(), a.leaf_allocator());
+ }
+
+ bool operator==(allocators const& a) const { return leaf_allocator() == a.leaf_allocator(); }
+ template <typename Alloc>
+ bool operator==(Alloc const& a) const { return leaf_allocator() == leaf_allocator_type(a); }
+
+ Allocator allocator() const { return Allocator(leaf_allocator()); }
+
+ internal_node_allocator_type & internal_node_allocator() { return *this; }
+ internal_node_allocator_type const& internal_node_allocator() const { return *this; }
+ leaf_allocator_type & leaf_allocator() { return *this; }
+ leaf_allocator_type const& leaf_allocator() const { return *this; }
+};
+
+struct node_bad_alloc : public std::exception
+{
+ const char * what() const throw() { return "internal node creation failed."; }
+};
+
+struct throwing_node_settings
+{
+ static void throw_if_required()
+ {
+ // throw if counter meets max count
+ if ( get_max_calls_ref() <= get_calls_counter_ref() )
+ throw node_bad_alloc();
+ else
+ ++get_calls_counter_ref();
+ }
+
+ static void reset_calls_counter() { get_calls_counter_ref() = 0; }
+ static void set_max_calls(size_t mc) { get_max_calls_ref() = mc; }
+
+ static size_t & get_calls_counter_ref() { static size_t cc = 0; return cc; }
+ static size_t & get_max_calls_ref() { static size_t mc = (std::numeric_limits<size_t>::max)(); return mc; }
+};
+
+// create_node
+
+template <typename Allocators, typename Value, typename Parameters, typename Box>
+struct create_node<
+ Allocators,
+ dynamic_internal_node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
+>
+{
+ static inline typename Allocators::node_pointer
+ apply(Allocators & allocators)
+ {
+ // throw if counter meets max count
+ throwing_node_settings::throw_if_required();
+
+ return create_dynamic_node<
+ typename Allocators::node_pointer,
+ dynamic_internal_node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
+ >::apply(allocators.internal_node_allocator());
+ }
+};
+
+template <typename Allocators, typename Value, typename Parameters, typename Box>
+struct create_node<
+ Allocators,
+ dynamic_leaf<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
+>
+{
+ static inline typename Allocators::node_pointer
+ apply(Allocators & allocators)
+ {
+ // throw if counter meets max count
+ throwing_node_settings::throw_if_required();
+
+ return create_dynamic_node<
+ typename Allocators::node_pointer,
+ dynamic_leaf<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
+ >::apply(allocators.leaf_allocator());
+ }
+};
+
+}} // namespace detail::rtree
+
+}}} // namespace boost::geometry::index
+
+#endif // BOOST_GEOMETRY_INDEX_TEST_RTREE_THROWING_NODE_HPP


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk