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

Function BOOST_AUTO_TEST_CASE

unit_tests/library/json.cpp:15–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13BOOST_AUTO_TEST_SUITE(json)
14
15BOOST_AUTO_TEST_CASE(test_json_linestring)
16{
17 const std::vector<util::Coordinate> locations{get_dummy_location(), //
18 get_dummy_location(), //
19 get_dummy_location()}; //
20
21 auto geom = engine::api::json::makeGeoJSONGeometry(begin(locations), end(locations));
22
23 const auto type = std::get<util::json::String>(geom.values["type"]).value;
24 BOOST_CHECK_EQUAL(type, "LineString");
25
26 const auto coords = std::get<util::json::Array>(geom.values["coordinates"]).values;
27 BOOST_CHECK_EQUAL(coords.size(), 3); // array of three location arrays
28
29 for (const auto &each : coords)
30 {
31 const auto loc = std::get<util::json::Array>(each).values;
32 BOOST_CHECK_EQUAL(loc.size(), 2);
33
34 const auto lon = std::get<util::json::Number>(loc[0]).value;
35 const auto lat = std::get<util::json::Number>(loc[1]).value;
36
37 (void)lon;
38 (void)lat;
39 // cast fails if type do not match
40 }
41}
42
43BOOST_AUTO_TEST_CASE(test_json_single_point)
44{

Callers

nothing calls this directly

Calls 3

get_dummy_locationFunction · 0.85
makeGeoJSONGeometryFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected