From d22b3a00bf27b464be8d0d0ee79fd76071fbba37 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Thu, 19 Mar 2015 03:54:10 +0100 Subject: [PATCH] [test][index] Add more tests for types convertible to rtree::value_type. Hopefully it'll give info needed to fix wrong results of rtree::count() for types convertible to value_type on Android. --- index/test/rtree/rtree_values.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/index/test/rtree/rtree_values.cpp b/index/test/rtree/rtree_values.cpp index 2059a8141..e9eb13810 100644 --- a/index/test/rtree/rtree_values.cpp +++ b/index/test/rtree/rtree_values.cpp @@ -22,6 +22,30 @@ struct point BOOST_GEOMETRY_REGISTER_POINT_2D(point, double, bg::cs::cartesian, x, y) +template +void check_convertible_to_value(Rtree const& rt, Convertible const& conv) +{ + static const bool + is_conv_to_indexable + = boost::is_convertible::value; + static const bool + is_conv_to_value + = boost::is_convertible::value; + static const bool + is_same_as_indexable + = boost::is_same::value; + static const bool + is_same_as_value + = boost::is_same::value; + + BOOST_CHECK_EQUAL(is_same_as_indexable, false); + BOOST_CHECK_EQUAL(is_same_as_value, false); + BOOST_CHECK_EQUAL(is_conv_to_indexable, false); + BOOST_CHECK_EQUAL(is_conv_to_value, true); + + typename Rtree::value_type const& val = conv; + BOOST_CHECK(rt.value_eq()(val, conv)); +} template void test_pair() @@ -45,6 +69,11 @@ void test_pair() rt.insert(std::make_pair(box, (unsigned short)0)); BOOST_CHECK_EQUAL(rt.size(), 3u); + check_convertible_to_value(rt, std::make_pair(box, 0)); + check_convertible_to_value(rt, std::make_pair(box, (unsigned short)0)); + BOOST_CHECK(bg::covered_by(rt.indexable_get()(std::make_pair(box, 0)), rt.bounds())); + BOOST_CHECK(bg::covered_by(rt.indexable_get()(std::make_pair(box, (unsigned short)0)), rt.bounds())); + BOOST_CHECK_EQUAL(rt.count(val), 3u); BOOST_CHECK_EQUAL(rt.count(std::make_pair(box, 0)), 3u); BOOST_CHECK_EQUAL(rt.count(std::make_pair(box, (unsigned short)0)), 3u);