add unit test for annotations=true returning all annotations

This commit is contained in:
karenzshea
2017-02-13 12:53:05 +01:00
committed by Patrick Niklaus
parent c7ce758e1c
commit cfee0f1109
4 changed files with 47 additions and 19 deletions
+1 -6
View File
@@ -4,9 +4,9 @@
#include "util/log.hpp"
#include <boost/filesystem.hpp>
#include <iostream>
#include <iostream>
#include <string>
#include <vector>
#include <iostream>
inline std::vector<std::string> get_args()
{
@@ -26,11 +26,6 @@ inline std::vector<std::string> get_args()
const auto argc = boost::unit_test::framework::master_test_suite().argc - 1;
const auto argv = boost::unit_test::framework::master_test_suite().argv + 1;
if (argc == 0)
{
std::cout << "You must provide a path to the test data, please see the unit testing docs" << std::endl;
}
return {argv, argv + argc};
}
+34 -1
View File
@@ -394,7 +394,7 @@ BOOST_AUTO_TEST_CASE(speed_annotation_matches_duration_and_distance)
using namespace osrm;
RouteParameters params{};
RouteParameters params;
params.annotations_type = RouteParameters::AnnotationsType::Duration |
RouteParameters::AnnotationsType::Distance |
RouteParameters::AnnotationsType::Speed;
@@ -422,4 +422,37 @@ BOOST_AUTO_TEST_CASE(speed_annotation_matches_duration_and_distance)
}
}
BOOST_AUTO_TEST_CASE(test_manual_setting_of_annotations_property)
{
const auto args = get_args();
auto osrm = getOSRM(args.at(0));
using namespace osrm;
RouteParameters params{};
params.annotations = true;
params.coordinates.push_back(get_dummy_location());
params.coordinates.push_back(get_dummy_location());
json::Object result;
const auto rc = osrm.Route(params, result);
BOOST_CHECK(rc == Status::Ok);
const auto code = result.values.at("code").get<json::String>().value;
BOOST_CHECK_EQUAL(code, "Ok");
auto annotations = result.values["routes"]
.get<json::Array>()
.values[0]
.get<json::Object>()
.values["legs"]
.get<json::Array>()
.values[0]
.get<json::Object>()
.values["annotation"]
.get<json::Object>()
.values;
BOOST_CHECK_EQUAL(annotations.size(), 5);
}
BOOST_AUTO_TEST_SUITE_END()