From 573b6958e11df95ef69bba92b247da1cc6b4f2eb Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sun, 18 Sep 2011 23:17:07 +0000 Subject: [PATCH] more rtree_function tests added. [SVN r74462] --- tests/rtree_function.hpp | 138 ++++++++++++++------------------------- 1 file changed, 48 insertions(+), 90 deletions(-) diff --git a/tests/rtree_function.hpp b/tests/rtree_function.hpp index 0a05a9fca..eec1d22d6 100644 --- a/tests/rtree_function.hpp +++ b/tests/rtree_function.hpp @@ -278,17 +278,17 @@ struct tests_rtree_function_queries } }; -template -void tests_rtree_function() +template +void tests_rtree_function(Translator const& tr = Translator()) { namespace bg = boost::geometry; namespace bgi = bg::index; - bgi::rtree t; + bgi::rtree t(tr); std::vector v; - typedef typename bgi::rtree::indexable_type I; - typedef typename bgi::rtree::box_type B; + typedef typename bgi::rtree::indexable_type I; + typedef typename bgi::rtree::box_type B; typedef typename bgi::traits::point_type::type P ; helpers::random_insert(t, v, 10, helpers::value_randomizer(10, 1)); @@ -305,11 +305,11 @@ BOOST_AUTO_TEST_CASE(tests_rtree_function_box3f) typedef bg::model::point P; typedef bg::model::box

B; - typedef B val_t; + typedef B V; - tests_rtree_function< val_t, bgi::linear<4, 2> >(); - tests_rtree_function< val_t, bgi::quadratic<4, 2> >(); - tests_rtree_function< val_t, bgi::rstar<4, 2> >(); + tests_rtree_function< V, bgi::linear<4, 2>, bgi::translator::def >(); + tests_rtree_function< V, bgi::quadratic<4, 2>, bgi::translator::def >(); + tests_rtree_function< V, bgi::rstar<4, 2>, bgi::translator::def >(); } BOOST_AUTO_TEST_CASE(tests_rtree_function_box2f) @@ -321,11 +321,11 @@ BOOST_AUTO_TEST_CASE(tests_rtree_function_box2f) typedef bg::model::point P; typedef bg::model::box

B; - typedef B val_t; + typedef B V; - tests_rtree_function< val_t, bgi::linear<4, 2> >(); - tests_rtree_function< val_t, bgi::quadratic<4, 2> >(); - tests_rtree_function< val_t, bgi::rstar<4, 2> >(); + tests_rtree_function< V, bgi::linear<4, 2>, bgi::translator::def >(); + tests_rtree_function< V, bgi::quadratic<4, 2>, bgi::translator::def >(); + tests_rtree_function< V, bgi::rstar<4, 2>, bgi::translator::def >(); } BOOST_AUTO_TEST_CASE(tests_rtree_function_point2f) @@ -336,11 +336,11 @@ BOOST_AUTO_TEST_CASE(tests_rtree_function_point2f) namespace bgi = bg::index; typedef bg::model::point P; - typedef P val_t; + typedef P V; - tests_rtree_function< val_t, bgi::linear<4, 2> >(); - tests_rtree_function< val_t, bgi::quadratic<4, 2> >(); - tests_rtree_function< val_t, bgi::rstar<4, 2> >(); + tests_rtree_function< V, bgi::linear<4, 2>, bgi::translator::def >(); + tests_rtree_function< V, bgi::quadratic<4, 2>, bgi::translator::def >(); + tests_rtree_function< V, bgi::rstar<4, 2>, bgi::translator::def >(); } namespace helpers { @@ -377,90 +377,48 @@ BOOST_AUTO_TEST_CASE(tests_rtree_function_pair_box2f_int) typedef bg::model::box

B; typedef std::pair V; - tests_rtree_function< V, bgi::linear<4, 2> >(); - tests_rtree_function< V, bgi::quadratic<4, 2> >(); - tests_rtree_function< V, bgi::rstar<4, 2> >(); + tests_rtree_function< V, bgi::linear<4, 2>, bgi::translator::def >(); + tests_rtree_function< V, bgi::quadratic<4, 2>, bgi::translator::def >(); + tests_rtree_function< V, bgi::rstar<4, 2>, bgi::translator::def >(); } - // std::cout << "-------------------------------------------------\n"; - // std::cout << "-------------------------------------------------\n"; +namespace helpers { - // std::cout << "boost::shared_ptr< std::pair >\n"; - // { - // typedef bg::model::point P; - // typedef bg::model::box

B; - // - // typedef boost::shared_ptr< std::pair > V; +template +struct value_randomizer< boost::shared_ptr< std::pair > > +{ + typedef boost::shared_ptr< std::pair > value_type; - // V v1( new std::pair(B(P(0, 0), P(1, 1)), 0) ); - // V v2( new std::pair(B(P(2, 2), P(3, 3)), 1) ); - // V v3( new std::pair(B(P(4, 4), P(5, 5)), 2) ); - // V v4( new std::pair(B(P(6, 6), P(7, 7)), 3) ); - // V v5( new std::pair(B(P(8, 8), P(9, 9)), 4) ); + typedef typename boost::geometry::index::traits::coordinate_type::type coord_t; - // bgi::rtree t; - // bgi::insert(t, v1); - // bgi::insert(t, v2); - // bgi::insert(t, v3); - // bgi::insert(t, v4); - // bgi::insert(t, v5); - // std::cerr << t; - // } + inline value_randomizer(coord_t mm, coord_t ww) + : r(mm, ww) + {} - // std::cout << "-------------------------------------------------\n"; - // std::cout << "-------------------------------------------------\n"; + inline value_type operator()() const + { + return value_type(new std::pair(r(), ::rand())); + } - // std::cout << "std::map::iterator\n"; - // { - // typedef bg::model::point P; - // typedef bg::model::box

B; - // - // typedef std::map::iterator V; + value_randomizer r; +}; - // std::map m; - // m.insert(std::pair(0, B(P(0, 0), P(1, 1)))); - // m.insert(std::pair(1, B(P(2, 2), P(3, 3)))); - // m.insert(std::pair(2, B(P(4, 4), P(5, 5)))); - // m.insert(std::pair(3, B(P(6, 6), P(7, 7)))); - // m.insert(std::pair(4, B(P(8, 8), P(9, 9)))); +} // namespace helpers - // bgi::rtree t; - // V vit = m.begin(); - // bgi::insert(t, vit++); - // bgi::insert(t, vit++); - // bgi::insert(t, vit++); - // bgi::insert(t, vit++); - // bgi::insert(t, vit); - // std::cerr << t; - // } +BOOST_AUTO_TEST_CASE(tests_rtree_function_shared_ptr_pair_box2f_int) +{ + std::cout << "tests/rtree_function_shared_ptr_pair_box2f_int\n"; - // std::cout << "-------------------------------------------------\n"; - // std::cout << "-------------------------------------------------\n"; + namespace bg = boost::geometry; + namespace bgi = bg::index; - // std::cout << "size_t\n"; - // { - // typedef bg::model::point P; - // typedef bg::model::box

B; + typedef bg::model::point P; + typedef bg::model::box

B; + typedef boost::shared_ptr< std::pair > V; - // typedef size_t V; - // typedef bgi::translator::index > Tr; - - // std::vector v; - // v.push_back(B(P(0, 0), P(1, 1))); - // v.push_back(B(P(2, 2), P(3, 3))); - // v.push_back(B(P(4, 4), P(5, 5))); - // v.push_back(B(P(6, 6), P(7, 7))); - // v.push_back(B(P(8, 8), P(9, 9))); - - //Tr tr(v); - // bgi::rtree t(tr); - - // bgi::insert(t, 0u); - // bgi::insert(t, 1u); - // bgi::insert(t, 2u); - // bgi::insert(t, 3u); - // bgi::insert(t, 4u); - // std::cerr << t; - // } + tests_rtree_function< V, bgi::linear<4, 2>, bgi::translator::def >(); + tests_rtree_function< V, bgi::quadratic<4, 2>, bgi::translator::def >(); + tests_rtree_function< V, bgi::rstar<4, 2>, bgi::translator::def >(); +} #endif // TESTS_RTREE_FUNCTION_HPP