Unit tests are compatible with new plugin API.
This commit is contained in:
parent
e26a5cc392
commit
a44a75b211
@ -214,9 +214,10 @@ int main(int argc, const char *argv[]) try
|
||||
auto NUM = 100;
|
||||
for (int i = 0; i < NUM; ++i)
|
||||
{
|
||||
json::Object result;
|
||||
engine::api::ResultT result = json::Object();
|
||||
const auto rc = osrm.Match(params, result);
|
||||
if (rc != Status::Ok || result.values.at("matchings").get<json::Array>().values.size() != 1)
|
||||
auto& json_result=result.get<json::Object>();
|
||||
if (rc != Status::Ok || json_result.values.at("matchings").get<json::Array>().values.size() != 1)
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
@ -39,14 +39,15 @@ BOOST_AUTO_TEST_CASE(test_trip_limits)
|
||||
params.coordinates.emplace_back(getZeroCoordinate());
|
||||
params.coordinates.emplace_back(getZeroCoordinate());
|
||||
|
||||
json::Object result;
|
||||
engine::api::ResultT result = json::Object();
|
||||
|
||||
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;
|
||||
auto& json_result=result.get<json::Object>();
|
||||
const auto code = json_result.values["code"].get<json::String>().value;
|
||||
BOOST_CHECK(code == "TooBig"); // per the New-Server API spec
|
||||
}
|
||||
|
||||
@ -66,14 +67,15 @@ BOOST_AUTO_TEST_CASE(test_route_limits)
|
||||
params.coordinates.emplace_back(getZeroCoordinate());
|
||||
params.coordinates.emplace_back(getZeroCoordinate());
|
||||
|
||||
json::Object result;
|
||||
engine::api::ResultT result = json::Object();
|
||||
|
||||
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;
|
||||
auto& json_result=result.get<json::Object>();
|
||||
const auto code = json_result.values["code"].get<json::String>().value;
|
||||
BOOST_CHECK(code == "TooBig"); // per the New-Server API spec
|
||||
}
|
||||
|
||||
@ -93,14 +95,15 @@ BOOST_AUTO_TEST_CASE(test_table_limits)
|
||||
params.coordinates.emplace_back(getZeroCoordinate());
|
||||
params.coordinates.emplace_back(getZeroCoordinate());
|
||||
|
||||
json::Object result;
|
||||
engine::api::ResultT result = json::Object();
|
||||
|
||||
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;
|
||||
auto& json_result=result.get<json::Object>();
|
||||
const auto code = json_result.values["code"].get<json::String>().value;
|
||||
BOOST_CHECK(code == "TooBig"); // per the New-Server API spec
|
||||
}
|
||||
|
||||
@ -120,14 +123,15 @@ BOOST_AUTO_TEST_CASE(test_match_coordinate_limits)
|
||||
params.coordinates.emplace_back(getZeroCoordinate());
|
||||
params.coordinates.emplace_back(getZeroCoordinate());
|
||||
|
||||
json::Object result;
|
||||
engine::api::ResultT result = json::Object();
|
||||
|
||||
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;
|
||||
auto& json_result=result.get<json::Object>();
|
||||
const auto code = json_result.values["code"].get<json::String>().value;
|
||||
BOOST_CHECK(code == "TooBig"); // per the New-Server API spec
|
||||
}
|
||||
|
||||
@ -152,14 +156,15 @@ BOOST_AUTO_TEST_CASE(test_match_radiuses_limits)
|
||||
params.radiuses.emplace_back(3.0);
|
||||
params.radiuses.emplace_back(2.0);
|
||||
|
||||
json::Object result;
|
||||
engine::api::ResultT result = json::Object();
|
||||
|
||||
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;
|
||||
auto& json_result=result.get<json::Object>();
|
||||
const auto code = json_result.values["code"].get<json::String>().value;
|
||||
BOOST_CHECK(code == "TooBig"); // per the New-Server API spec
|
||||
}
|
||||
|
||||
@ -178,14 +183,15 @@ BOOST_AUTO_TEST_CASE(test_nearest_limits)
|
||||
params.coordinates.emplace_back(getZeroCoordinate());
|
||||
params.number_of_results = 10000;
|
||||
|
||||
json::Object result;
|
||||
engine::api::ResultT result = json::Object();
|
||||
|
||||
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;
|
||||
auto& json_result=result.get<json::Object>();
|
||||
const auto code = json_result.values["code"].get<json::String>().value;
|
||||
BOOST_CHECK(code == "TooBig"); // per the New-Server API spec
|
||||
}
|
||||
|
||||
|
@ -26,18 +26,19 @@ BOOST_AUTO_TEST_CASE(test_match)
|
||||
params.coordinates.push_back(get_dummy_location());
|
||||
params.coordinates.push_back(get_dummy_location());
|
||||
|
||||
json::Object result;
|
||||
engine::api::ResultT result = json::Object();
|
||||
|
||||
const auto rc = osrm.Match(params, result);
|
||||
|
||||
auto& json_result=result.get<json::Object>();
|
||||
BOOST_CHECK(rc == Status::Ok || rc == Status::Error);
|
||||
const auto code = result.values.at("code").get<json::String>().value;
|
||||
const auto code = json_result.values.at("code").get<json::String>().value;
|
||||
BOOST_CHECK_EQUAL(code, "Ok");
|
||||
|
||||
const auto &tracepoints = result.values.at("tracepoints").get<json::Array>().values;
|
||||
const auto &tracepoints = json_result.values.at("tracepoints").get<json::Array>().values;
|
||||
BOOST_CHECK_EQUAL(tracepoints.size(), params.coordinates.size());
|
||||
|
||||
const auto &matchings = result.values.at("matchings").get<json::Array>().values;
|
||||
const auto &matchings = json_result.values.at("matchings").get<json::Array>().values;
|
||||
const auto &number_of_matchings = matchings.size();
|
||||
for (const auto &waypoint : tracepoints)
|
||||
{
|
||||
@ -74,18 +75,19 @@ BOOST_AUTO_TEST_CASE(test_match_split)
|
||||
params.coordinates = get_split_trace_locations();
|
||||
params.timestamps = {1, 2, 1700, 1800};
|
||||
|
||||
json::Object result;
|
||||
engine::api::ResultT result = json::Object();
|
||||
|
||||
const auto rc = osrm.Match(params, result);
|
||||
|
||||
auto& json_result=result.get<json::Object>();
|
||||
BOOST_CHECK(rc == Status::Ok || rc == Status::Error);
|
||||
const auto code = result.values.at("code").get<json::String>().value;
|
||||
const auto code = json_result.values.at("code").get<json::String>().value;
|
||||
BOOST_CHECK_EQUAL(code, "Ok");
|
||||
|
||||
const auto &tracepoints = result.values.at("tracepoints").get<json::Array>().values;
|
||||
const auto &tracepoints = json_result.values.at("tracepoints").get<json::Array>().values;
|
||||
BOOST_CHECK_EQUAL(tracepoints.size(), params.coordinates.size());
|
||||
|
||||
const auto &matchings = result.values.at("matchings").get<json::Array>().values;
|
||||
const auto &matchings = json_result.values.at("matchings").get<json::Array>().values;
|
||||
const auto &number_of_matchings = matchings.size();
|
||||
BOOST_CHECK_EQUAL(number_of_matchings, 2);
|
||||
std::size_t current_matchings_index = 0, expected_waypoint_index = 0;
|
||||
|
@ -23,14 +23,15 @@ BOOST_AUTO_TEST_CASE(test_nearest_response)
|
||||
NearestParameters params;
|
||||
params.coordinates.push_back(get_dummy_location());
|
||||
|
||||
json::Object result;
|
||||
engine::api::ResultT result = json::Object();
|
||||
const auto rc = osrm.Nearest(params, result);
|
||||
BOOST_REQUIRE(rc == Status::Ok);
|
||||
|
||||
const auto code = result.values.at("code").get<json::String>().value;
|
||||
auto& json_result=result.get<json::Object>();
|
||||
const auto code = json_result.values.at("code").get<json::String>().value;
|
||||
BOOST_CHECK_EQUAL(code, "Ok");
|
||||
|
||||
const auto &waypoints = result.values.at("waypoints").get<json::Array>().values;
|
||||
const auto &waypoints = json_result.values.at("waypoints").get<json::Array>().values;
|
||||
BOOST_CHECK(!waypoints.empty()); // the dataset has at least one nearest coordinate
|
||||
|
||||
for (const auto &waypoint : waypoints)
|
||||
@ -49,11 +50,12 @@ BOOST_AUTO_TEST_CASE(test_nearest_response_no_coordinates)
|
||||
|
||||
NearestParameters params;
|
||||
|
||||
json::Object result;
|
||||
engine::api::ResultT result = json::Object();
|
||||
const auto rc = osrm.Nearest(params, result);
|
||||
BOOST_REQUIRE(rc == Status::Error);
|
||||
|
||||
const auto code = result.values.at("code").get<json::String>().value;
|
||||
auto& json_result=result.get<json::Object>();
|
||||
const auto code = json_result.values.at("code").get<json::String>().value;
|
||||
BOOST_CHECK_EQUAL(code, "InvalidOptions");
|
||||
}
|
||||
|
||||
@ -67,11 +69,12 @@ BOOST_AUTO_TEST_CASE(test_nearest_response_multiple_coordinates)
|
||||
params.coordinates.push_back(get_dummy_location());
|
||||
params.coordinates.push_back(get_dummy_location());
|
||||
|
||||
json::Object result;
|
||||
engine::api::ResultT result = json::Object();
|
||||
const auto rc = osrm.Nearest(params, result);
|
||||
BOOST_REQUIRE(rc == Status::Error);
|
||||
|
||||
const auto code = result.values.at("code").get<json::String>().value;
|
||||
auto& json_result=result.get<json::Object>();
|
||||
const auto code = json_result.values.at("code").get<json::String>().value;
|
||||
BOOST_CHECK_EQUAL(code, "InvalidOptions");
|
||||
}
|
||||
|
||||
@ -87,14 +90,15 @@ BOOST_AUTO_TEST_CASE(test_nearest_response_for_location_in_small_component)
|
||||
params.coordinates.push_back(locations.at(0));
|
||||
params.number_of_results = 3;
|
||||
|
||||
json::Object result;
|
||||
engine::api::ResultT result = json::Object();
|
||||
const auto rc = osrm.Nearest(params, result);
|
||||
BOOST_REQUIRE(rc == Status::Ok);
|
||||
|
||||
const auto code = result.values.at("code").get<json::String>().value;
|
||||
auto& json_result=result.get<json::Object>();
|
||||
const auto code = json_result.values.at("code").get<json::String>().value;
|
||||
BOOST_CHECK_EQUAL(code, "Ok");
|
||||
|
||||
const auto &waypoints = result.values.at("waypoints").get<json::Array>().values;
|
||||
const auto &waypoints = json_result.values.at("waypoints").get<json::Array>().values;
|
||||
BOOST_CHECK(!waypoints.empty());
|
||||
|
||||
for (const auto &waypoint : waypoints)
|
||||
|
@ -28,12 +28,13 @@ BOOST_AUTO_TEST_CASE(test_route_same_coordinates_fixture)
|
||||
params.coordinates.push_back(get_dummy_location());
|
||||
params.coordinates.push_back(get_dummy_location());
|
||||
|
||||
json::Object result;
|
||||
engine::api::ResultT result = json::Object();
|
||||
const auto rc = osrm.Route(params, result);
|
||||
BOOST_CHECK(rc == Status::Ok);
|
||||
|
||||
auto& json_result=result.get<json::Object>();
|
||||
// unset snapping dependent hint
|
||||
for (auto &itr : result.values["waypoints"].get<json::Array>().values)
|
||||
for (auto &itr : json_result.values["waypoints"].get<json::Array>().values)
|
||||
{
|
||||
// Hint values aren't stable, so blank it out
|
||||
itr.get<json::Object>().values["hint"] = "";
|
||||
@ -112,7 +113,7 @@ BOOST_AUTO_TEST_CASE(test_route_same_coordinates_fixture)
|
||||
|
||||
}}}}}}}}}}}}}}}}};
|
||||
|
||||
CHECK_EQUAL_JSON(reference, result);
|
||||
CHECK_EQUAL_JSON(reference, json_result);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_route_same_coordinates)
|
||||
@ -127,14 +128,15 @@ BOOST_AUTO_TEST_CASE(test_route_same_coordinates)
|
||||
params.coordinates.push_back(get_dummy_location());
|
||||
params.coordinates.push_back(get_dummy_location());
|
||||
|
||||
json::Object result;
|
||||
engine::api::ResultT result = json::Object();
|
||||
const auto rc = osrm.Route(params, result);
|
||||
BOOST_CHECK(rc == Status::Ok);
|
||||
|
||||
const auto code = result.values.at("code").get<json::String>().value;
|
||||
auto& json_result=result.get<json::Object>();
|
||||
const auto code = json_result.values.at("code").get<json::String>().value;
|
||||
BOOST_CHECK_EQUAL(code, "Ok");
|
||||
|
||||
const auto &waypoints = result.values.at("waypoints").get<json::Array>().values;
|
||||
const auto &waypoints = json_result.values.at("waypoints").get<json::Array>().values;
|
||||
BOOST_CHECK(waypoints.size() == params.coordinates.size());
|
||||
|
||||
for (const auto &waypoint : waypoints)
|
||||
@ -155,7 +157,7 @@ BOOST_AUTO_TEST_CASE(test_route_same_coordinates)
|
||||
BOOST_CHECK(!hint.empty());
|
||||
}
|
||||
|
||||
const auto &routes = result.values.at("routes").get<json::Array>().values;
|
||||
const auto &routes = json_result.values.at("routes").get<json::Array>().values;
|
||||
BOOST_REQUIRE_GT(routes.size(), 0);
|
||||
|
||||
for (const auto &route : routes)
|
||||
@ -280,14 +282,15 @@ BOOST_AUTO_TEST_CASE(test_route_response_for_locations_in_small_component)
|
||||
params.coordinates.push_back(locations.at(1));
|
||||
params.coordinates.push_back(locations.at(2));
|
||||
|
||||
json::Object result;
|
||||
engine::api::ResultT result = json::Object();
|
||||
const auto rc = osrm.Route(params, result);
|
||||
BOOST_CHECK(rc == Status::Ok);
|
||||
|
||||
const auto code = result.values.at("code").get<json::String>().value;
|
||||
auto& json_result=result.get<json::Object>();
|
||||
const auto code = json_result.values.at("code").get<json::String>().value;
|
||||
BOOST_CHECK_EQUAL(code, "Ok");
|
||||
|
||||
const auto &waypoints = result.values.at("waypoints").get<json::Array>().values;
|
||||
const auto &waypoints = json_result.values.at("waypoints").get<json::Array>().values;
|
||||
BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size());
|
||||
|
||||
for (const auto &waypoint : waypoints)
|
||||
@ -315,14 +318,15 @@ BOOST_AUTO_TEST_CASE(test_route_response_for_locations_in_big_component)
|
||||
params.coordinates.push_back(locations.at(1));
|
||||
params.coordinates.push_back(locations.at(2));
|
||||
|
||||
json::Object result;
|
||||
engine::api::ResultT result = json::Object();
|
||||
const auto rc = osrm.Route(params, result);
|
||||
BOOST_CHECK(rc == Status::Ok);
|
||||
|
||||
const auto code = result.values.at("code").get<json::String>().value;
|
||||
auto& json_result=result.get<json::Object>();
|
||||
const auto code = json_result.values.at("code").get<json::String>().value;
|
||||
BOOST_CHECK_EQUAL(code, "Ok");
|
||||
|
||||
const auto &waypoints = result.values.at("waypoints").get<json::Array>().values;
|
||||
const auto &waypoints = json_result.values.at("waypoints").get<json::Array>().values;
|
||||
BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size());
|
||||
|
||||
for (const auto &waypoint : waypoints)
|
||||
@ -352,14 +356,15 @@ BOOST_AUTO_TEST_CASE(test_route_response_for_locations_across_components)
|
||||
params.coordinates.push_back(small_component.at(1));
|
||||
params.coordinates.push_back(big_component.at(1));
|
||||
|
||||
json::Object result;
|
||||
engine::api::ResultT result = json::Object();
|
||||
const auto rc = osrm.Route(params, result);
|
||||
BOOST_CHECK(rc == Status::Ok);
|
||||
|
||||
const auto code = result.values.at("code").get<json::String>().value;
|
||||
auto& json_result=result.get<json::Object>();
|
||||
const auto code = json_result.values.at("code").get<json::String>().value;
|
||||
BOOST_CHECK_EQUAL(code, "Ok");
|
||||
|
||||
const auto &waypoints = result.values.at("waypoints").get<json::Array>().values;
|
||||
const auto &waypoints = json_result.values.at("waypoints").get<json::Array>().values;
|
||||
BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size());
|
||||
|
||||
for (const auto &waypoint : waypoints)
|
||||
@ -386,11 +391,12 @@ BOOST_AUTO_TEST_CASE(test_route_user_disables_generating_hints)
|
||||
params.coordinates.push_back(get_dummy_location());
|
||||
params.generate_hints = false;
|
||||
|
||||
json::Object result;
|
||||
engine::api::ResultT result = json::Object();
|
||||
const auto rc = osrm.Route(params, result);
|
||||
BOOST_CHECK(rc == Status::Ok);
|
||||
|
||||
for (auto waypoint : result.values["waypoints"].get<json::Array>().values)
|
||||
auto& json_result=result.get<json::Object>();
|
||||
for (auto waypoint : json_result.values["waypoints"].get<json::Array>().values)
|
||||
BOOST_CHECK_EQUAL(waypoint.get<json::Object>().values.count("hint"), 0);
|
||||
}
|
||||
|
||||
@ -407,11 +413,12 @@ BOOST_AUTO_TEST_CASE(speed_annotation_matches_duration_and_distance)
|
||||
params.coordinates.push_back(get_dummy_location());
|
||||
params.coordinates.push_back(get_dummy_location());
|
||||
|
||||
json::Object result;
|
||||
engine::api::ResultT result = json::Object();
|
||||
const auto rc = osrm.Route(params, result);
|
||||
BOOST_CHECK(rc == Status::Ok);
|
||||
|
||||
const auto &routes = result.values["routes"].get<json::Array>().values;
|
||||
auto& json_result=result.get<json::Object>();
|
||||
const auto &routes = json_result.values["routes"].get<json::Array>().values;
|
||||
const auto &legs = routes[0].get<json::Object>().values.at("legs").get<json::Array>().values;
|
||||
const auto &annotation =
|
||||
legs[0].get<json::Object>().values.at("annotation").get<json::Object>();
|
||||
@ -447,14 +454,15 @@ BOOST_AUTO_TEST_CASE(test_manual_setting_of_annotations_property)
|
||||
params.coordinates.push_back(get_dummy_location());
|
||||
params.coordinates.push_back(get_dummy_location());
|
||||
|
||||
json::Object result;
|
||||
engine::api::ResultT result = json::Object();
|
||||
const auto rc = osrm.Route(params, result);
|
||||
BOOST_CHECK(rc == Status::Ok);
|
||||
|
||||
const auto code = result.values.at("code").get<json::String>().value;
|
||||
auto& json_result=result.get<json::Object>();
|
||||
const auto code = json_result.values.at("code").get<json::String>().value;
|
||||
BOOST_CHECK_EQUAL(code, "Ok");
|
||||
|
||||
auto annotations = result.values["routes"]
|
||||
auto annotations = json_result.values["routes"]
|
||||
.get<json::Array>()
|
||||
.values[0]
|
||||
.get<json::Object>()
|
||||
|
@ -29,17 +29,18 @@ BOOST_AUTO_TEST_CASE(test_table_three_coords_one_source_one_dest_matrix)
|
||||
params.destinations.push_back(2);
|
||||
params.annotations = TableParameters::AnnotationsType::All;
|
||||
|
||||
json::Object result;
|
||||
engine::api::ResultT result = json::Object();
|
||||
|
||||
const auto rc = osrm.Table(params, result);
|
||||
|
||||
auto& json_result=result.get<json::Object>();
|
||||
BOOST_CHECK(rc == Status::Ok || rc == Status::Error);
|
||||
const auto code = result.values.at("code").get<json::String>().value;
|
||||
const auto code = json_result.values.at("code").get<json::String>().value;
|
||||
BOOST_CHECK_EQUAL(code, "Ok");
|
||||
|
||||
// check that returned durations error is expected size and proportions
|
||||
// this test expects a 1x1 matrix
|
||||
const auto &durations_array = result.values.at("durations").get<json::Array>().values;
|
||||
const auto &durations_array = json_result.values.at("durations").get<json::Array>().values;
|
||||
BOOST_CHECK_EQUAL(durations_array.size(), params.sources.size());
|
||||
for (unsigned int i = 0; i < durations_array.size(); i++)
|
||||
{
|
||||
@ -50,7 +51,7 @@ BOOST_AUTO_TEST_CASE(test_table_three_coords_one_source_one_dest_matrix)
|
||||
|
||||
// check that returned distances error is expected size and proportions
|
||||
// this test expects a 1x1 matrix
|
||||
const auto &distances_array = result.values.at("distances").get<json::Array>().values;
|
||||
const auto &distances_array = json_result.values.at("distances").get<json::Array>().values;
|
||||
BOOST_CHECK_EQUAL(distances_array.size(), params.sources.size());
|
||||
for (unsigned int i = 0; i < distances_array.size(); i++)
|
||||
{
|
||||
@ -60,14 +61,14 @@ BOOST_AUTO_TEST_CASE(test_table_three_coords_one_source_one_dest_matrix)
|
||||
}
|
||||
|
||||
// check destinations array of waypoint objects
|
||||
const auto &destinations_array = result.values.at("destinations").get<json::Array>().values;
|
||||
const auto &destinations_array = json_result.values.at("destinations").get<json::Array>().values;
|
||||
BOOST_CHECK_EQUAL(destinations_array.size(), params.destinations.size());
|
||||
for (const auto &destination : destinations_array)
|
||||
{
|
||||
BOOST_CHECK(waypoint_check(destination));
|
||||
}
|
||||
// check sources array of waypoint objects
|
||||
const auto &sources_array = result.values.at("sources").get<json::Array>().values;
|
||||
const auto &sources_array = json_result.values.at("sources").get<json::Array>().values;
|
||||
BOOST_CHECK_EQUAL(sources_array.size(), params.sources.size());
|
||||
for (const auto &source : sources_array)
|
||||
{
|
||||
@ -86,17 +87,18 @@ BOOST_AUTO_TEST_CASE(test_table_three_coords_one_source_matrix)
|
||||
params.coordinates.push_back(get_dummy_location());
|
||||
params.coordinates.push_back(get_dummy_location());
|
||||
params.sources.push_back(0);
|
||||
json::Object result;
|
||||
engine::api::ResultT result = json::Object();
|
||||
|
||||
const auto rc = osrm.Table(params, result);
|
||||
|
||||
auto& json_result=result.get<json::Object>();
|
||||
BOOST_CHECK(rc == Status::Ok || rc == Status::Error);
|
||||
const auto code = result.values.at("code").get<json::String>().value;
|
||||
const auto code = json_result.values.at("code").get<json::String>().value;
|
||||
BOOST_CHECK_EQUAL(code, "Ok");
|
||||
|
||||
// check that returned durations error is expected size and proportions
|
||||
// this test expects a 1x3 matrix
|
||||
const auto &durations_array = result.values.at("durations").get<json::Array>().values;
|
||||
const auto &durations_array = json_result.values.at("durations").get<json::Array>().values;
|
||||
BOOST_CHECK_EQUAL(durations_array.size(), params.sources.size());
|
||||
for (unsigned int i = 0; i < durations_array.size(); i++)
|
||||
{
|
||||
@ -106,14 +108,14 @@ BOOST_AUTO_TEST_CASE(test_table_three_coords_one_source_matrix)
|
||||
params.sources.size() * params.coordinates.size());
|
||||
}
|
||||
// check destinations array of waypoint objects
|
||||
const auto &destinations_array = result.values.at("destinations").get<json::Array>().values;
|
||||
const auto &destinations_array = json_result.values.at("destinations").get<json::Array>().values;
|
||||
BOOST_CHECK_EQUAL(destinations_array.size(), params.coordinates.size());
|
||||
for (const auto &destination : destinations_array)
|
||||
{
|
||||
BOOST_CHECK(waypoint_check(destination));
|
||||
}
|
||||
// check sources array of waypoint objects
|
||||
const auto &sources_array = result.values.at("sources").get<json::Array>().values;
|
||||
const auto &sources_array = json_result.values.at("sources").get<json::Array>().values;
|
||||
BOOST_CHECK_EQUAL(sources_array.size(), params.sources.size());
|
||||
for (const auto &source : sources_array)
|
||||
{
|
||||
@ -133,17 +135,18 @@ BOOST_AUTO_TEST_CASE(test_table_three_coordinates_matrix)
|
||||
params.coordinates.push_back(get_dummy_location());
|
||||
params.annotations = TableParameters::AnnotationsType::Duration;
|
||||
|
||||
json::Object result;
|
||||
engine::api::ResultT result = json::Object();
|
||||
|
||||
const auto rc = osrm.Table(params, result);
|
||||
|
||||
auto& json_result=result.get<json::Object>();
|
||||
BOOST_CHECK(rc == Status::Ok || rc == Status::Error);
|
||||
const auto code = result.values.at("code").get<json::String>().value;
|
||||
const auto code = json_result.values.at("code").get<json::String>().value;
|
||||
BOOST_CHECK_EQUAL(code, "Ok");
|
||||
|
||||
// check that returned durations error is expected size and proportions
|
||||
// this test expects a 3x3 matrix
|
||||
const auto &durations_array = result.values.at("durations").get<json::Array>().values;
|
||||
const auto &durations_array = json_result.values.at("durations").get<json::Array>().values;
|
||||
BOOST_CHECK_EQUAL(durations_array.size(), params.coordinates.size());
|
||||
for (unsigned int i = 0; i < durations_array.size(); i++)
|
||||
{
|
||||
@ -151,12 +154,12 @@ BOOST_AUTO_TEST_CASE(test_table_three_coordinates_matrix)
|
||||
BOOST_CHECK_EQUAL(durations_matrix[i].get<json::Number>().value, 0);
|
||||
BOOST_CHECK_EQUAL(durations_matrix.size(), params.coordinates.size());
|
||||
}
|
||||
const auto &destinations_array = result.values.at("destinations").get<json::Array>().values;
|
||||
const auto &destinations_array = json_result.values.at("destinations").get<json::Array>().values;
|
||||
for (const auto &destination : destinations_array)
|
||||
{
|
||||
BOOST_CHECK(waypoint_check(destination));
|
||||
}
|
||||
const auto &sources_array = result.values.at("sources").get<json::Array>().values;
|
||||
const auto &sources_array = json_result.values.at("sources").get<json::Array>().values;
|
||||
BOOST_CHECK_EQUAL(sources_array.size(), params.coordinates.size());
|
||||
for (const auto &source : sources_array)
|
||||
{
|
||||
@ -178,12 +181,13 @@ BOOST_AUTO_TEST_CASE(test_table_no_segment_for_some_coordinates)
|
||||
params.radiuses.push_back(boost::make_optional(0.));
|
||||
params.radiuses.push_back(boost::none);
|
||||
|
||||
json::Object result;
|
||||
engine::api::ResultT result = json::Object();
|
||||
|
||||
const auto rc = osrm.Table(params, result);
|
||||
|
||||
auto& json_result=result.get<json::Object>();
|
||||
BOOST_CHECK(rc == Status::Error);
|
||||
const auto code = result.values.at("code").get<json::String>().value;
|
||||
const auto code = json_result.values.at("code").get<json::String>().value;
|
||||
BOOST_CHECK_EQUAL(code, "NoSegment");
|
||||
}
|
||||
|
||||
|
@ -161,13 +161,15 @@ void validate_tile(const osrm::OSRM &osrm)
|
||||
// This tile should contain most of monaco
|
||||
TileParameters params{17059, 11948, 15};
|
||||
|
||||
std::string result;
|
||||
engine::api::ResultT result = std::string();
|
||||
|
||||
const auto rc = osrm.Tile(params, result);
|
||||
BOOST_CHECK(rc == Status::Ok);
|
||||
|
||||
BOOST_CHECK(result.size() > 114000);
|
||||
auto& str_result = result.get<std::string>();
|
||||
BOOST_CHECK(str_result.size() > 114000);
|
||||
|
||||
vtzero::vector_tile tile{result};
|
||||
vtzero::vector_tile tile{str_result};
|
||||
|
||||
validate_feature_layer(tile.next_layer());
|
||||
validate_turn_layer(tile.next_layer());
|
||||
@ -206,13 +208,14 @@ void test_tile_turns(const osrm::OSRM &osrm)
|
||||
// Small tile where we can test all the values
|
||||
TileParameters params{272953, 191177, 19};
|
||||
|
||||
std::string result;
|
||||
engine::api::ResultT result = std::string();
|
||||
const auto rc = osrm.Tile(params, result);
|
||||
BOOST_CHECK(rc == Status::Ok);
|
||||
|
||||
BOOST_CHECK_GT(result.size(), 128);
|
||||
auto& str_result = result.get<std::string>();
|
||||
BOOST_CHECK_GT(str_result.size(), 128);
|
||||
|
||||
vtzero::vector_tile tile{result};
|
||||
vtzero::vector_tile tile{str_result};
|
||||
|
||||
tile.next_layer();
|
||||
auto layer = tile.next_layer();
|
||||
@ -347,13 +350,14 @@ void test_tile_speeds(const osrm::OSRM &osrm)
|
||||
// TileParameters params{272953, 191177, 19};
|
||||
TileParameters params{136477, 95580, 18};
|
||||
|
||||
std::string result;
|
||||
engine::api::ResultT result = std::string();
|
||||
const auto rc = osrm.Tile(params, result);
|
||||
BOOST_CHECK(rc == Status::Ok);
|
||||
|
||||
BOOST_CHECK_GT(result.size(), 128);
|
||||
auto& str_result = result.get<std::string>();
|
||||
BOOST_CHECK_GT(str_result.size(), 128);
|
||||
|
||||
vtzero::vector_tile tile{result};
|
||||
vtzero::vector_tile tile{str_result};
|
||||
|
||||
auto layer = tile.next_layer();
|
||||
BOOST_CHECK_EQUAL(to_string(layer.name()), "speeds");
|
||||
@ -427,13 +431,14 @@ void test_tile_nodes(const osrm::OSRM &osrm)
|
||||
// Small tile where we can test all the values
|
||||
TileParameters params{272953, 191177, 19};
|
||||
|
||||
std::string result;
|
||||
engine::api::ResultT result = std::string();
|
||||
const auto rc = osrm.Tile(params, result);
|
||||
BOOST_CHECK(rc == Status::Ok);
|
||||
|
||||
BOOST_CHECK_GT(result.size(), 128);
|
||||
auto& str_result = result.get<std::string>();
|
||||
BOOST_CHECK_GT(str_result.size(), 128);
|
||||
|
||||
vtzero::vector_tile tile{result};
|
||||
vtzero::vector_tile tile{str_result};
|
||||
|
||||
tile.next_layer();
|
||||
tile.next_layer();
|
||||
|
@ -26,17 +26,18 @@ BOOST_AUTO_TEST_CASE(test_roundtrip_response_for_locations_in_small_component)
|
||||
params.coordinates.push_back(locations.at(1));
|
||||
params.coordinates.push_back(locations.at(2));
|
||||
|
||||
json::Object result;
|
||||
engine::api::ResultT result = json::Object();
|
||||
const auto rc = osrm.Trip(params, result);
|
||||
BOOST_CHECK(rc == Status::Ok);
|
||||
|
||||
const auto code = result.values.at("code").get<json::String>().value;
|
||||
auto& json_result=result.get<json::Object>();
|
||||
const auto code = json_result.values.at("code").get<json::String>().value;
|
||||
BOOST_CHECK_EQUAL(code, "Ok");
|
||||
|
||||
const auto &waypoints = result.values.at("waypoints").get<json::Array>().values;
|
||||
const auto &waypoints = json_result.values.at("waypoints").get<json::Array>().values;
|
||||
BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size());
|
||||
|
||||
const auto &trips = result.values.at("trips").get<json::Array>().values;
|
||||
const auto &trips = json_result.values.at("trips").get<json::Array>().values;
|
||||
BOOST_CHECK_EQUAL(trips.size(), 1);
|
||||
|
||||
for (const auto &waypoint : waypoints)
|
||||
@ -68,17 +69,18 @@ BOOST_AUTO_TEST_CASE(test_roundtrip_response_for_locations_in_big_component)
|
||||
params.coordinates.push_back(locations.at(1));
|
||||
params.coordinates.push_back(locations.at(2));
|
||||
|
||||
json::Object result;
|
||||
engine::api::ResultT result = json::Object();
|
||||
const auto rc = osrm.Trip(params, result);
|
||||
BOOST_CHECK(rc == Status::Ok);
|
||||
|
||||
const auto code = result.values.at("code").get<json::String>().value;
|
||||
auto& json_result=result.get<json::Object>();
|
||||
const auto code = json_result.values.at("code").get<json::String>().value;
|
||||
BOOST_CHECK_EQUAL(code, "Ok");
|
||||
|
||||
const auto &waypoints = result.values.at("waypoints").get<json::Array>().values;
|
||||
const auto &waypoints = json_result.values.at("waypoints").get<json::Array>().values;
|
||||
BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size());
|
||||
|
||||
const auto &trips = result.values.at("trips").get<json::Array>().values;
|
||||
const auto &trips = json_result.values.at("trips").get<json::Array>().values;
|
||||
BOOST_CHECK_EQUAL(trips.size(), 1);
|
||||
|
||||
for (const auto &waypoint : waypoints)
|
||||
@ -112,17 +114,18 @@ BOOST_AUTO_TEST_CASE(test_roundtrip_response_for_locations_across_components)
|
||||
params.coordinates.push_back(small.at(1));
|
||||
params.coordinates.push_back(big.at(1));
|
||||
|
||||
json::Object result;
|
||||
engine::api::ResultT result = json::Object();
|
||||
const auto rc = osrm.Trip(params, result);
|
||||
BOOST_CHECK(rc == Status::Ok);
|
||||
|
||||
const auto code = result.values.at("code").get<json::String>().value;
|
||||
auto& json_result=result.get<json::Object>();
|
||||
const auto code = json_result.values.at("code").get<json::String>().value;
|
||||
BOOST_CHECK_EQUAL(code, "Ok");
|
||||
|
||||
const auto &waypoints = result.values.at("waypoints").get<json::Array>().values;
|
||||
const auto &waypoints = json_result.values.at("waypoints").get<json::Array>().values;
|
||||
BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size());
|
||||
|
||||
const auto &trips = result.values.at("trips").get<json::Array>().values;
|
||||
const auto &trips = json_result.values.at("trips").get<json::Array>().values;
|
||||
BOOST_CHECK_EQUAL(trips.size(), 1);
|
||||
// ^ First snapping, then SCC decomposition (see plugins/trip.cpp). Therefore only a single
|
||||
// trip.
|
||||
@ -160,17 +163,18 @@ BOOST_AUTO_TEST_CASE(test_tfse_1)
|
||||
params.destination = TripParameters::DestinationType::Last;
|
||||
params.roundtrip = false;
|
||||
|
||||
json::Object result;
|
||||
engine::api::ResultT result = json::Object();
|
||||
const auto rc = osrm.Trip(params, result);
|
||||
BOOST_CHECK(rc == Status::Ok);
|
||||
|
||||
const auto code = result.values.at("code").get<json::String>().value;
|
||||
auto& json_result=result.get<json::Object>();
|
||||
const auto code = json_result.values.at("code").get<json::String>().value;
|
||||
BOOST_CHECK_EQUAL(code, "Ok");
|
||||
|
||||
const auto &waypoints = result.values.at("waypoints").get<json::Array>().values;
|
||||
const auto &waypoints = json_result.values.at("waypoints").get<json::Array>().values;
|
||||
BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size());
|
||||
|
||||
const auto &trips = result.values.at("trips").get<json::Array>().values;
|
||||
const auto &trips = json_result.values.at("trips").get<json::Array>().values;
|
||||
BOOST_CHECK_EQUAL(trips.size(), 1);
|
||||
|
||||
for (const auto &waypoint : waypoints)
|
||||
@ -206,17 +210,18 @@ BOOST_AUTO_TEST_CASE(test_tfse_2)
|
||||
params.destination = TripParameters::DestinationType::Last;
|
||||
params.roundtrip = false;
|
||||
|
||||
json::Object result;
|
||||
engine::api::ResultT result = json::Object();
|
||||
const auto rc = osrm.Trip(params, result);
|
||||
BOOST_CHECK(rc == Status::Ok);
|
||||
|
||||
const auto code = result.values.at("code").get<json::String>().value;
|
||||
auto& json_result=result.get<json::Object>();
|
||||
const auto code = json_result.values.at("code").get<json::String>().value;
|
||||
BOOST_CHECK_EQUAL(code, "Ok");
|
||||
|
||||
const auto &waypoints = result.values.at("waypoints").get<json::Array>().values;
|
||||
const auto &waypoints = json_result.values.at("waypoints").get<json::Array>().values;
|
||||
BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size());
|
||||
|
||||
const auto &trips = result.values.at("trips").get<json::Array>().values;
|
||||
const auto &trips = json_result.values.at("trips").get<json::Array>().values;
|
||||
BOOST_CHECK_EQUAL(trips.size(), 1);
|
||||
|
||||
for (const auto &waypoint : waypoints)
|
||||
@ -245,19 +250,23 @@ void ResetParams(const Locations &locations, osrm::TripParameters ¶ms)
|
||||
}
|
||||
void CheckNotImplemented(const osrm::OSRM &osrm, osrm::TripParameters ¶ms)
|
||||
{
|
||||
osrm::json::Object result;
|
||||
using namespace osrm;
|
||||
engine::api::ResultT result = json::Object();
|
||||
auto rc = osrm.Trip(params, result);
|
||||
BOOST_REQUIRE(rc == osrm::Status::Error);
|
||||
auto code = result.values.at("code").get<osrm::json::String>().value;
|
||||
auto& json_result=result.get<json::Object>();
|
||||
auto code = json_result.values.at("code").get<osrm::json::String>().value;
|
||||
BOOST_CHECK_EQUAL(code, "NotImplemented");
|
||||
}
|
||||
|
||||
void CheckOk(const osrm::OSRM &osrm, osrm::TripParameters ¶ms)
|
||||
{
|
||||
osrm::json::Object result;
|
||||
using namespace osrm;
|
||||
engine::api::ResultT result = json::Object();
|
||||
auto rc = osrm.Trip(params, result);
|
||||
BOOST_REQUIRE(rc == osrm::Status::Ok);
|
||||
auto code = result.values.at("code").get<osrm::json::String>().value;
|
||||
auto& json_result=result.get<json::Object>();
|
||||
auto code = json_result.values.at("code").get<osrm::json::String>().value;
|
||||
BOOST_CHECK_EQUAL(code, "Ok");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user