Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r83881 - trunk/libs/geometry/test/index/rtree
From: adam.wulkiewicz_at_[hidden]
Date: 2013-04-13 16:31:38


Author: awulkiew
Date: 2013-04-13 16:31:37 EDT (Sat, 13 Apr 2013)
New Revision: 83881
URL: http://svn.boost.org/trac/boost/changeset/83881

Log:
geometry.test.index: added smaller testsets
Text files modified:
   trunk/libs/geometry/test/index/rtree/rtree_test_generator.cpp | 100 +++++++++++++++++++----------------
   trunk/libs/geometry/test/index/rtree/test_rtree.hpp | 111 +++++++++++++++++++++++++++++++++------
   2 files changed, 149 insertions(+), 62 deletions(-)

Modified: trunk/libs/geometry/test/index/rtree/rtree_test_generator.cpp
==============================================================================
--- trunk/libs/geometry/test/index/rtree/rtree_test_generator.cpp (original)
+++ trunk/libs/geometry/test/index/rtree/rtree_test_generator.cpp 2013-04-13 16:31:37 EDT (Sat, 13 Apr 2013)
@@ -20,8 +20,8 @@
     typedef boost::tuple<std::string, std::string, std::string> CT;
     std::vector<CT> coordinate_types;
     coordinate_types.push_back(boost::make_tuple("double", "d", ""));
- //coordinate_types.push_back(boost::make_tuple("float", "f", ""));
     coordinate_types.push_back(boost::make_tuple("int", "i", ""));
+ //coordinate_types.push_back(boost::make_tuple("float", "f", ""));
     //coordinate_types.push_back(boost::make_tuple("ttmath_big", "tt", "HAVE_TTMATH"));
 
     std::vector<std::string> dimensions;
@@ -30,17 +30,23 @@
 
     typedef boost::tuple<std::string, std::string> P;
     std::vector<P> parameters;
- parameters.push_back(boost::make_tuple("bgi::linear<8, 3>()", "linear"));
- parameters.push_back(boost::make_tuple("bgi::quadratic<8, 3>()", "quadratic"));
- parameters.push_back(boost::make_tuple("bgi::rstar<8, 3>()", "rstar"));
- parameters.push_back(boost::make_tuple("bgi::dynamic_linear(8, 3)", "linear_dyn"));
- parameters.push_back(boost::make_tuple("bgi::dynamic_quadratic(8, 3)", "quadratic_dyn"));
- parameters.push_back(boost::make_tuple("bgi::dynamic_rstar(8, 3)","rstar_dyn"));
+ parameters.push_back(boost::make_tuple("bgi::linear<8, 3>()", "lin"));
+ parameters.push_back(boost::make_tuple("bgi::quadratic<8, 3>()", "qua"));
+ parameters.push_back(boost::make_tuple("bgi::rstar<8, 3>()", "rst"));
+ parameters.push_back(boost::make_tuple("bgi::dynamic_linear(8, 3)", "dlin"));
+ parameters.push_back(boost::make_tuple("bgi::dynamic_quadratic(8, 3)", "dqua"));
+ parameters.push_back(boost::make_tuple("bgi::dynamic_rstar(8, 3)","drst"));
     
     std::vector<std::string> indexables;
     indexables.push_back("p");
     indexables.push_back("b");
 
+ typedef std::pair<std::string, std::string> TS;
+ std::vector<TS> testsets;
+ testsets.push_back(std::make_pair("testset::modifiers<Indexable>(parameters, std::allocator<int>())", "mod"));
+ testsets.push_back(std::make_pair("testset::queries<Indexable>(parameters, std::allocator<int>())", "que"));
+ testsets.push_back(std::make_pair("testset::additional<Indexable>(parameters, std::allocator<int>())", "add"));
+
     BOOST_FOREACH(std::string const& d, dimensions)
     {
         BOOST_FOREACH(CT const& c, coordinate_types)
@@ -49,45 +55,49 @@
             {
                 BOOST_FOREACH(std::string const& i, indexables)
                 {
- std::string point_type = std::string() +
- "bg::model::point<" + boost::get<0>(c) + ", " + d + ", bg::cs::cartesian>";
-
- std::string filename = std::string() +
- "rtree_" + i + d + boost::get<1>(c) + '_' + boost::get<1>(p) + ".cpp";
-
- std::ofstream f(filename.c_str(), std::ios::trunc);
+ BOOST_FOREACH(TS const& ts, testsets)
+ {
+ std::string point_type = std::string() +
+ "bg::model::point<" + boost::get<0>(c) + ", " + d + ", bg::cs::cartesian>";
+ std::string box_type = std::string("bg::model::box<") + point_type + ">";
+
+ std::string filename = std::string() +
+ "rtree_" + i + d + boost::get<1>(c) + '_' + boost::get<1>(p) + "_" + ts.first + ".cpp";
+
+ std::ofstream f(filename.c_str(), std::ios::trunc);
+
+ f <<
+ "// Boost.Geometry Index\n" <<
+ "// Unit Test\n" <<
+ "\n" <<
+ "// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.\n" <<
+ "\n" <<
+ "// Use, modification and distribution is subject to the Boost Software License,\n" <<
+ "// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at\n" <<
+ "// http://www.boost.org/LICENSE_1_0.txt)\n" <<
+ "\n";
+
+ f <<
+ "#include <rtree/test_rtree.hpp>\n" <<
+ "\n" <<
+ "#include <boost/geometry/geometries/point.hpp>\n" <<
+ (i == "p" ? "" : "#include <boost/geometry/geometries/box.hpp>\n") <<
+ "\n";
+
+ f <<
+ "int test_main(int, char* [])\n" <<
+ "{\n" <<
+ (boost::get<2>(c).empty() ? "" : "#ifdef HAVE_TTMATH\n") <<
+ " typedef " << point_type << " Point;\n" <<
+ " " <<
+ (i == "p" ? "test_rtree_for_point" : "test_rtree_for_box" ) <<
+ "<Point>(" << boost::get<0>(p) << ");\n" <<
+ (boost::get<2>(c).empty() ? "" : "#endif\n") <<
+ " return 0;\n" <<
+ "}\n";
 
- f <<
- "// Boost.Geometry Index\n" <<
- "// Unit Test\n" <<
- "\n" <<
- "// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.\n" <<
- "\n" <<
- "// Use, modification and distribution is subject to the Boost Software License,\n" <<
- "// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at\n" <<
- "// http://www.boost.org/LICENSE_1_0.txt)\n" <<
- "\n";
-
- f <<
- "#include <rtree/test_rtree.hpp>\n" <<
- "\n" <<
- "#include <boost/geometry/geometries/point.hpp>\n" <<
- (i == "p" ? "" : "#include <boost/geometry/geometries/box.hpp>\n") <<
- "\n";
-
- f <<
- "int test_main(int, char* [])\n" <<
- "{\n" <<
- (boost::get<2>(c).empty() ? "" : "#ifdef HAVE_TTMATH\n") <<
- " typedef " << point_type << " Point;\n" <<
- " " <<
- (i == "p" ? "test_rtree_for_point" : "test_rtree_for_box" ) <<
- "<Point>(" << boost::get<0>(p) << ");\n" <<
- (boost::get<2>(c).empty() ? "" : "#endif\n") <<
- " return 0;\n" <<
- "}\n";
-
- generated_files.push_back(filename);
+ generated_files.push_back(filename);
+ }
                 }
             }
 

Modified: trunk/libs/geometry/test/index/rtree/test_rtree.hpp
==============================================================================
--- trunk/libs/geometry/test/index/rtree/test_rtree.hpp (original)
+++ trunk/libs/geometry/test/index/rtree/test_rtree.hpp 2013-04-13 16:31:37 EDT (Sat, 13 Apr 2013)
@@ -1266,11 +1266,8 @@
 
 } // namespace basictest
 
-// run all tests for a single Algorithm and single rtree
-// defined by Value
-
 template <typename Value, typename Parameters, typename Allocator>
-void test_rtree_by_value(Parameters const& parameters, Allocator const& allocator)
+void test_rtree_queries(Parameters const& parameters, Allocator const& allocator)
 {
     typedef bgi::indexable<Value> I;
     typedef bgi::equal_to<Value> E;
@@ -1278,8 +1275,6 @@
     typedef bgi::rtree<Value, Parameters, I, E, A> Tree;
     typedef typename Tree::box_type B;
 
- // not empty tree test
-
     Tree tree(parameters, I(), E(), allocator);
     std::vector<Value> input;
     B qbox;
@@ -1287,18 +1282,46 @@
     generate::rtree(tree, input, qbox);
 
     basictest::queries(tree, input, qbox);
- basictest::modifiers(tree, input, qbox);
-
- // empty tree test
 
     Tree empty_tree(parameters, I(), E(), allocator);
     std::vector<Value> empty_input;
 
     basictest::queries(empty_tree, empty_input, qbox);
+}
+
+template <typename Value, typename Parameters, typename Allocator>
+void test_rtree_modifiers(Parameters const& parameters, Allocator const& allocator)
+{
+ typedef bgi::indexable<Value> I;
+ typedef bgi::equal_to<Value> E;
+ typedef typename Allocator::template rebind<Value>::other A;
+ typedef bgi::rtree<Value, Parameters, I, E, A> Tree;
+ typedef typename Tree::box_type B;
+
+ Tree tree(parameters, I(), E(), allocator);
+ std::vector<Value> input;
+ B qbox;
+
+ generate::rtree(tree, input, qbox);
+
+ basictest::modifiers(tree, input, qbox);
+
+ Tree empty_tree(parameters, I(), E(), allocator);
+ std::vector<Value> empty_input;
 
     basictest::copy_swap_move(empty_tree, qbox);
 }
 
+// run all tests for a single Algorithm and single rtree
+// defined by Value
+
+template <typename Value, typename Parameters, typename Allocator>
+void test_rtree_by_value(Parameters const& parameters, Allocator const& allocator)
+{
+ test_rtree_queries<Value>(parameters, allocator);
+ test_rtree_modifiers<Value>(parameters, allocator);
+}
+
 // rtree inserting and removing of counting_value
 
 template <typename Indexable, typename Parameters, typename Allocator>
@@ -1432,6 +1455,14 @@
     BOOST_CHECK(bg::equals(t.bounds(), b));
 }
 
+template <typename Indexable, typename Parameters, typename Allocator>
+void test_rtree_additional(Parameters const& parameters, Allocator const& allocator)
+{
+ test_count_rtree_values<Indexable>(parameters, allocator);
+ test_rtree_count<Indexable>(parameters, allocator);
+ test_rtree_bounds<Indexable>(parameters, allocator);
+}
+
 // run all tests for one Algorithm for some number of rtrees
 // defined by some number of Values constructed from given Point
 
@@ -1450,10 +1481,7 @@
     test_rtree_by_value<SharedPtrP, Parameters>(parameters, allocator);
     test_rtree_by_value<VNoDCtor, Parameters>(parameters, allocator);
 
- test_count_rtree_values<Point>(parameters, allocator);
-
- test_rtree_count<Point>(parameters, allocator);
- test_rtree_bounds<Point>(parameters, allocator);
+ test_rtree_additional<Point>(parameters, allocator);
 
 #if !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
     typedef std::tuple<Point, int, int> StdTupleP;
@@ -1475,10 +1503,7 @@
 
     test_rtree_by_value<VNoDCtor, Parameters>(parameters, allocator);
 
- test_count_rtree_values<Box>(parameters, allocator);
-
- test_rtree_count<Box>(parameters, allocator);
- test_rtree_bounds<Box>(parameters, allocator);
+ test_rtree_additional<Box>(parameters, allocator);
 
 #if !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
     typedef std::tuple<Box, int, int> StdTupleB;
@@ -1498,4 +1523,56 @@
     test_rtree_for_box<Point>(parameters, std::allocator<int>());
 }
 
+namespace testset {
+
+template<typename Indexable, typename Parameters, typename Allocator>
+void modifiers(Parameters const& parameters, Allocator const& allocator)
+{
+ typedef std::pair<Indexable, int> Pair;
+ typedef boost::tuple<Indexable, int, int> Tuple;
+ typedef boost::shared_ptr< test_object<Indexable> > SharedPtr;
+ typedef value_no_dctor<Indexable> VNoDCtor;
+
+ test_rtree_modifiers<Indexable>(parameters, allocator);
+ test_rtree_modifiers<Pair>(parameters, allocator);
+ test_rtree_modifiers<Tuple>(parameters, allocator);
+
+ test_rtree_modifiers<SharedPtr>(parameters, allocator);
+ test_rtree_modifiers<VNoDCtor>(parameters, allocator);
+
+#if !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
+ typedef std::tuple<Indexable, int, int> StdTuple;
+ test_rtree_modifiers<StdTuple>(parameters, allocator);
+#endif
+}
+
+template<typename Indexable, typename Parameters, typename Allocator>
+void queries(Parameters const& parameters, Allocator const& allocator)
+{
+ typedef std::pair<Indexable, int> Pair;
+ typedef boost::tuple<Indexable, int, int> Tuple;
+ typedef boost::shared_ptr< test_object<Indexable> > SharedPtr;
+ typedef value_no_dctor<Indexable> VNoDCtor;
+
+ test_rtree_queries<Indexable>(parameters, allocator);
+ test_rtree_queries<Pair>(parameters, allocator);
+ test_rtree_queries<Tuple>(parameters, allocator);
+
+ test_rtree_queries<SharedPtr>(parameters, allocator);
+ test_rtree_queries<VNoDCtor>(parameters, allocator);
+
+#if !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
+ typedef std::tuple<Indexable, int, int> StdTuple;
+ test_rtree_queries<StdTuple>(parameters, allocator);
+#endif
+}
+
+template<typename Indexable, typename Parameters, typename Allocator>
+void additional(Parameters const& parameters, Allocator const& allocator)
+{
+ test_rtree_additional<Indexable, Parameters>(parameters, allocator);
+}
+
+} // namespace testset
+
 #endif // BOOST_GEOMETRY_INDEX_TEST_RTREE_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