From 5e5c52ff0aa48812fbe1ce7a7b4a6c8a457197f7 Mon Sep 17 00:00:00 2001 From: Patrick Niklaus Date: Wed, 24 Feb 2016 05:07:39 +0100 Subject: [PATCH] Simplify static_rtree tests --- unit_tests/util/static_rtree.cpp | 36 +++++++++++--------------------- 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/unit_tests/util/static_rtree.cpp b/unit_tests/util/static_rtree.cpp index c51aa070b..026ca62ce 100644 --- a/unit_tests/util/static_rtree.cpp +++ b/unit_tests/util/static_rtree.cpp @@ -1,7 +1,6 @@ #include "util/coordinate_calculation.hpp" #include "engine/geospatial_query.hpp" #include "util/static_rtree.hpp" -#include "extractor/query_node.hpp" #include "extractor/edge_based_node.hpp" #include "util/typedefs.hpp" #include "util/rectangle.hpp" @@ -115,12 +114,10 @@ template struct RandomGraphFixture { int lon = lon_udist(g); int lat = lat_udist(g); - nodes.emplace_back( - extractor::QueryNode(FixedLongitude(lat), FixedLatitude(lon), OSMNodeID(i))); coords->emplace_back(Coordinate(FixedLongitude(lon), FixedLatitude(lat))); } - std::uniform_int_distribution<> edge_udist(0, nodes.size() - 1); + std::uniform_int_distribution<> edge_udist(0, coords->size() - 1); std::unordered_set, TupleHash> used_edges; @@ -139,7 +136,6 @@ template struct RandomGraphFixture } } - std::vector nodes; std::shared_ptr> coords; std::vector edges; }; @@ -154,8 +150,6 @@ struct GraphFixture for (unsigned i = 0; i < input_coords.size(); i++) { coords->emplace_back(input_coords[i].first, input_coords[i].second); - nodes.emplace_back(extractor::QueryNode(toFixed(input_coords[i].first), - toFixed(input_coords[i].second), OSMNodeID(i))); } for (const auto &pair : input_edges) @@ -173,7 +167,6 @@ struct GraphFixture } } - std::vector nodes; std::shared_ptr> coords; std::vector edges; }; @@ -190,6 +183,7 @@ typedef RandomGraphFixture TestRandomGraphFixture_MultipleLevels; +typedef RandomGraphFixture<10, 30> TestRandomGraphFixture_10_30; template void simple_verify_rtree(RTreeT &rtree, @@ -254,17 +248,11 @@ void build_rtree(const std::string &prefix, { nodes_path = prefix + ".ramIndex"; leaves_path = prefix + ".fileIndex"; - const std::string coords_path = prefix + ".nodes"; - boost::filesystem::ofstream node_stream(coords_path, std::ios::binary); - const auto num_nodes = static_cast(fixture->nodes.size()); - node_stream.write((char *)&num_nodes, sizeof(unsigned)); - node_stream.write((char *)&(fixture->nodes[0]), num_nodes * sizeof(extractor::QueryNode)); - - RTreeT r(fixture->edges, nodes_path, leaves_path, fixture->nodes); + RTreeT r(fixture->edges, nodes_path, leaves_path, *fixture->coords); } -template +template void construction_test(const std::string &prefix, FixtureT *fixture) { std::string leaves_path; @@ -277,6 +265,12 @@ void construction_test(const std::string &prefix, FixtureT *fixture) sampling_verify_rtree(rtree, lsnn, *fixture->coords, 100); } +BOOST_FIXTURE_TEST_CASE(construct_tiny, TestRandomGraphFixture_10_30) +{ + using TinyTestTree = StaticRTree, false, 2, 1>; + construction_test("test_tiny", this); +} + BOOST_FIXTURE_TEST_CASE(construct_half_leaf_test, TestRandomGraphFixture_LeafHalfFull) { construction_test("test_1", this); @@ -312,14 +306,8 @@ BOOST_AUTO_TEST_CASE(regression_test) { Coord{FloatLongitude{0.0}, FloatLatitude{40.0}}, // Coord{FloatLongitude{5.0}, FloatLatitude{35.0}}, // - Coord{FloatLongitude{5.0}, - FloatLatitude{ - 5.0, - }}, // - Coord{FloatLongitude{10.0}, - FloatLatitude{ - 0.0, - }}, // + Coord{FloatLongitude{5.0}, FloatLatitude{5.0,}}, // + Coord{FloatLongitude{10.0}, FloatLatitude{0.0}}, // Coord{FloatLongitude{10.0}, FloatLatitude{20.0}}, // Coord{FloatLongitude{5.0}, FloatLatitude{20.0}}, // Coord{FloatLongitude{100.0}, FloatLatitude{40.0}}, //