Adds a limit for number of results returned in Nearest service, resolves #2872

This commit is contained in:
Daniel J. Hofmann
2016-09-12 11:47:22 +02:00
committed by Moritz Kobitzsch
parent e6fe9d0d67
commit e3c1b133bf
8 changed files with 68 additions and 11 deletions
+30
View File
@@ -4,6 +4,7 @@
#include "args.hpp"
#include "osrm/match_parameters.hpp"
#include "osrm/nearest_parameters.hpp"
#include "osrm/route_parameters.hpp"
#include "osrm/table_parameters.hpp"
#include "osrm/trip_parameters.hpp"
@@ -136,4 +137,33 @@ BOOST_AUTO_TEST_CASE(test_match_limits)
BOOST_CHECK(code == "TooBig"); // per the New-Server API spec
}
BOOST_AUTO_TEST_CASE(test_nearest_limits)
{
const auto args = get_args();
BOOST_REQUIRE_EQUAL(args.size(), 1);
using namespace osrm;
EngineConfig config;
config.storage_config = {args[0]};
config.use_shared_memory = false;
config.max_results_nearest = 2;
OSRM osrm{config};
NearestParameters params;
params.coordinates.emplace_back(util::FloatLongitude{}, util::FloatLatitude{});
params.number_of_results = 10000;
json::Object result;
const auto rc = osrm.Nearest(params, result);
BOOST_CHECK(rc == Status::Error);
// Make sure we're not accidentally hitting a guard code path before
const auto code = result.values["code"].get<json::String>().value;
BOOST_CHECK(code == "TooBig"); // per the New-Server API spec
}
BOOST_AUTO_TEST_SUITE_END()