| 13 | BOOST_AUTO_TEST_SUITE(json) |
| 14 | |
| 15 | BOOST_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 | |
| 43 | BOOST_AUTO_TEST_CASE(test_json_single_point) |
| 44 | { |
nothing calls this directly
no test coverage detected