MCPcopy Create free account
hub / github.com/Project-OSRM/osrm-backend / test_nearest_response

Function test_nearest_response

unit_tests/library/nearest.cpp:31–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29BOOST_AUTO_TEST_SUITE(nearest)
30
31void test_nearest_response(bool use_json_only_api)
32{
33 auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
34
35 using namespace osrm;
36
37 NearestParameters params;
38 params.coordinates.push_back(get_dummy_location());
39
40 json::Object json_result;
41 const auto rc = run_nearest_json(osrm, params, json_result, use_json_only_api);
42 BOOST_REQUIRE(rc == Status::Ok);
43
44 const auto code = std::get<json::String>(json_result.values.at("code")).value;
45 BOOST_CHECK_EQUAL(code, "Ok");
46
47 const auto &waypoints = std::get<json::Array>(json_result.values.at("waypoints")).values;
48 BOOST_CHECK(!waypoints.empty()); // the dataset has at least one nearest coordinate
49
50 for (const auto &waypoint : waypoints)
51 {
52 const auto &waypoint_object = std::get<json::Object>(waypoint);
53 const auto distance = std::get<json::Number>(waypoint_object.values.at("distance")).value;
54 BOOST_CHECK(distance >= 0);
55 }
56}
57BOOST_AUTO_TEST_CASE(test_nearest_response_old_api) { test_nearest_response(true); }
58BOOST_AUTO_TEST_CASE(test_nearest_response_new_api) { test_nearest_response(false); }
59

Callers 1

BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 6

getOSRMFunction · 0.85
get_dummy_locationFunction · 0.85
run_nearest_jsonFunction · 0.85
push_backMethod · 0.45
atMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected