Skip to content

Commit

Permalink
Add distance value to library routing test.
Browse files Browse the repository at this point in the history
  • Loading branch information
danpat committed Nov 1, 2018
1 parent a01c761 commit a640837
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions unit_tests/library/route.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <boost/test/test_case_template.hpp>
#include <boost/test/unit_test.hpp>

#include <cmath>

#include "coordinates.hpp"
#include "equal_json.hpp"
#include "fixture.hpp"
Expand Down Expand Up @@ -32,18 +34,28 @@ BOOST_AUTO_TEST_CASE(test_route_same_coordinates_fixture)

// unset snapping dependent hint
for (auto &itr : result.values["waypoints"].get<json::Array>().values)
{
// Hint values aren't stable, so blank it out
itr.get<json::Object>().values["hint"] = "";

// Round value to 6 decimal places for double comparison later
itr.get<json::Object>().values["distance"] =
round(itr.get<json::Object>().values["distance"].get<json::Number>().value * 1000000);
}

const auto location = json::Array{{{7.437070}, {43.749248}}};

json::Object reference{
{{"code", "Ok"},
{"waypoints",
json::Array{
{json::Object{
{{"name", "Boulevard du Larvotto"}, {"location", location}, {"hint", ""}}},
json::Object{
{{"name", "Boulevard du Larvotto"}, {"location", location}, {"hint", ""}}}}}},
json::Array{{json::Object{{{"name", "Boulevard du Larvotto"},
{"location", location},
{"distance", round(0.137249 * 1000000)},
{"hint", ""}}},
json::Object{{{"name", "Boulevard du Larvotto"},
{"location", location},
{"distance", round(0.137249 * 1000000)},
{"hint", ""}}}}}},
{"routes",
json::Array{{json::Object{
{{"distance", 0.},
Expand Down

0 comments on commit a640837

Please sign in to comment.