2016-03-16 09:53:14 -04:00
|
|
|
#include <boost/test/test_case_template.hpp>
|
2016-05-27 15:05:04 -04:00
|
|
|
#include <boost/test/unit_test.hpp>
|
2016-03-16 09:53:14 -04:00
|
|
|
|
2016-05-27 15:05:04 -04:00
|
|
|
#include "osrm/match_parameters.hpp"
|
2016-09-12 05:47:22 -04:00
|
|
|
#include "osrm/nearest_parameters.hpp"
|
2016-03-16 09:53:14 -04:00
|
|
|
#include "osrm/route_parameters.hpp"
|
|
|
|
#include "osrm/table_parameters.hpp"
|
2016-05-27 15:05:04 -04:00
|
|
|
#include "osrm/trip_parameters.hpp"
|
2016-03-16 09:53:14 -04:00
|
|
|
|
|
|
|
#include "osrm/coordinate.hpp"
|
|
|
|
#include "osrm/engine_config.hpp"
|
|
|
|
#include "osrm/json_container.hpp"
|
|
|
|
#include "osrm/osrm.hpp"
|
2016-05-27 15:05:04 -04:00
|
|
|
#include "osrm/status.hpp"
|
2016-03-16 09:53:14 -04:00
|
|
|
|
2016-12-19 10:50:17 -05:00
|
|
|
namespace
|
|
|
|
{
|
2016-12-20 08:57:08 -05:00
|
|
|
osrm::util::Coordinate getZeroCoordinate()
|
|
|
|
{
|
|
|
|
return {osrm::util::FloatLongitude{0}, osrm::util::FloatLatitude{0}};
|
|
|
|
}
|
2016-12-19 10:50:17 -05:00
|
|
|
}
|
|
|
|
|
2016-03-16 09:53:14 -04:00
|
|
|
BOOST_AUTO_TEST_SUITE(limits)
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(test_trip_limits)
|
|
|
|
{
|
|
|
|
using namespace osrm;
|
|
|
|
|
2016-03-24 12:45:14 -04:00
|
|
|
EngineConfig config;
|
2017-07-07 10:42:07 -04:00
|
|
|
config.storage_config = {OSRM_TEST_DATA_DIR "/ch/monaco.osrm"};
|
2016-03-16 09:53:14 -04:00
|
|
|
config.use_shared_memory = false;
|
|
|
|
config.max_locations_trip = 2;
|
|
|
|
|
|
|
|
OSRM osrm{config};
|
|
|
|
|
|
|
|
TripParameters params;
|
2016-12-19 10:50:17 -05:00
|
|
|
params.coordinates.emplace_back(getZeroCoordinate());
|
|
|
|
params.coordinates.emplace_back(getZeroCoordinate());
|
|
|
|
params.coordinates.emplace_back(getZeroCoordinate());
|
2016-03-16 09:53:14 -04:00
|
|
|
|
|
|
|
json::Object result;
|
|
|
|
|
|
|
|
const auto rc = osrm.Trip(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_CASE(test_route_limits)
|
|
|
|
{
|
|
|
|
using namespace osrm;
|
|
|
|
|
2016-03-24 12:45:14 -04:00
|
|
|
EngineConfig config;
|
2017-07-07 10:42:07 -04:00
|
|
|
config.storage_config = {OSRM_TEST_DATA_DIR "/ch/monaco.osrm"};
|
2016-03-16 09:53:14 -04:00
|
|
|
config.use_shared_memory = false;
|
|
|
|
config.max_locations_viaroute = 2;
|
|
|
|
|
|
|
|
OSRM osrm{config};
|
|
|
|
|
|
|
|
RouteParameters params;
|
2016-12-19 10:50:17 -05:00
|
|
|
params.coordinates.emplace_back(getZeroCoordinate());
|
|
|
|
params.coordinates.emplace_back(getZeroCoordinate());
|
|
|
|
params.coordinates.emplace_back(getZeroCoordinate());
|
2016-03-16 09:53:14 -04:00
|
|
|
|
|
|
|
json::Object result;
|
|
|
|
|
|
|
|
const auto rc = osrm.Route(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_CASE(test_table_limits)
|
|
|
|
{
|
|
|
|
using namespace osrm;
|
|
|
|
|
2016-03-24 12:45:14 -04:00
|
|
|
EngineConfig config;
|
2017-07-07 10:42:07 -04:00
|
|
|
config.storage_config = {OSRM_TEST_DATA_DIR "/ch/monaco.osrm"};
|
2016-03-16 09:53:14 -04:00
|
|
|
config.use_shared_memory = false;
|
|
|
|
config.max_locations_distance_table = 2;
|
|
|
|
|
|
|
|
OSRM osrm{config};
|
|
|
|
|
|
|
|
TableParameters params;
|
2016-12-19 10:50:17 -05:00
|
|
|
params.coordinates.emplace_back(getZeroCoordinate());
|
|
|
|
params.coordinates.emplace_back(getZeroCoordinate());
|
|
|
|
params.coordinates.emplace_back(getZeroCoordinate());
|
2016-03-16 09:53:14 -04:00
|
|
|
|
|
|
|
json::Object result;
|
|
|
|
|
|
|
|
const auto rc = osrm.Table(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_CASE(test_match_limits)
|
|
|
|
{
|
|
|
|
using namespace osrm;
|
|
|
|
|
2016-03-24 12:45:14 -04:00
|
|
|
EngineConfig config;
|
2017-07-07 10:42:07 -04:00
|
|
|
config.storage_config = {OSRM_TEST_DATA_DIR "/ch/monaco.osrm"};
|
2016-03-16 09:53:14 -04:00
|
|
|
config.use_shared_memory = false;
|
|
|
|
config.max_locations_map_matching = 2;
|
|
|
|
|
|
|
|
OSRM osrm{config};
|
|
|
|
|
|
|
|
MatchParameters params;
|
2016-12-19 10:50:17 -05:00
|
|
|
params.coordinates.emplace_back(getZeroCoordinate());
|
|
|
|
params.coordinates.emplace_back(getZeroCoordinate());
|
|
|
|
params.coordinates.emplace_back(getZeroCoordinate());
|
2016-03-16 09:53:14 -04:00
|
|
|
|
|
|
|
json::Object result;
|
|
|
|
|
|
|
|
const auto rc = osrm.Match(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
|
|
|
|
}
|
|
|
|
|
2016-09-12 05:47:22 -04:00
|
|
|
BOOST_AUTO_TEST_CASE(test_nearest_limits)
|
|
|
|
{
|
|
|
|
using namespace osrm;
|
|
|
|
|
|
|
|
EngineConfig config;
|
2017-07-07 10:42:07 -04:00
|
|
|
config.storage_config = {OSRM_TEST_DATA_DIR "/ch/monaco.osrm"};
|
2016-09-12 05:47:22 -04:00
|
|
|
config.use_shared_memory = false;
|
|
|
|
config.max_results_nearest = 2;
|
|
|
|
|
|
|
|
OSRM osrm{config};
|
|
|
|
|
|
|
|
NearestParameters params;
|
2016-12-19 10:50:17 -05:00
|
|
|
params.coordinates.emplace_back(getZeroCoordinate());
|
2016-09-12 05:47:22 -04:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2016-03-16 09:53:14 -04:00
|
|
|
BOOST_AUTO_TEST_SUITE_END()
|