Missing tzid property wasn't a geojson validation issue, shouldn't have been tested there.

This commit is contained in:
Daniel Patterson 2018-10-26 13:54:29 -07:00 committed by Michael Bell
parent 9b3aa33d66
commit 5cfb22d342
3 changed files with 14 additions and 30 deletions

View File

@ -48,20 +48,6 @@ inline void validateFeature(const rapidjson::Value &feature)
{
throw osrm::util::exception("Feature has non-object properties member.");
}
if (feature["properties"].HasMember("tzid"))
{
if (!feature["properties"]["tzid"].IsString())
throw osrm::util::exception("Feature has non-string tzid property");
}
else if (feature["properties"].HasMember("TZID"))
{
if (!feature["properties"]["TZID"].IsString())
throw osrm::util::exception("Feature has non-string TZID property");
}
else
{
throw osrm::util::exception("Feature is missing tzid property.");
}
if (!feature.HasMember("geometry"))
{
throw osrm::util::exception("Feature is missing geometry member.");

View File

@ -53,5 +53,19 @@ BOOST_AUTO_TEST_CASE(timezoner_test)
"48.88277], [8.57757, 49.07206], [8.28369, "
"49.07206], [8.28369, 48.88277]]] }} ]}";
BOOST_CHECK_THROW(Timezoner tz(missing_featc, now), util::exception);
char missing_tzid[] = "{ \"type\" : \"Feature\","
"\"properties\" : { }, \"geometry\" : { \"type\": \"polygon\", "
"\"coordinates\": [[[8.28369,48.88277], [8.57757, "
"48.88277], [8.57757, 49.07206], [8.28369, "
"49.07206], [8.28369, 48.88277]]] }}";
BOOST_CHECK_THROW(Timezoner tz(missing_tzid, now), util::exception);
char tzid_err[] = "{ \"type\" : \"Feature\","
"\"properties\" : { \"TZID\" : []}, \"geometry\" : { \"type\": \"polygon\", "
"\"coordinates\": [[[8.28369,48.88277], [8.57757, "
"48.88277], [8.57757, 49.07206], [8.28369, "
"49.07206], [8.28369, 48.88277]]] }}";
BOOST_CHECK_THROW(Timezoner tz(tzid_err, now), util::exception);
}
BOOST_AUTO_TEST_SUITE_END()

View File

@ -65,22 +65,6 @@ BOOST_AUTO_TEST_CASE(timezone_validation_test)
doc.Parse(nonobj_props);
BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
char missing_tzid[] = "{ \"type\" : \"Feature\","
"\"properties\" : { }, \"geometry\" : { \"type\": \"polygon\", "
"\"coordinates\": [[[8.28369,48.88277], [8.57757, "
"48.88277], [8.57757, 49.07206], [8.28369, "
"49.07206], [8.28369, 48.88277]]] }}";
doc.Parse(missing_tzid);
BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
char tzid_err[] = "{ \"type\" : \"Feature\","
"\"properties\" : { \"TZID\" : []}, \"geometry\" : { \"type\": \"polygon\", "
"\"coordinates\": [[[8.28369,48.88277], [8.57757, "
"48.88277], [8.57757, 49.07206], [8.28369, "
"49.07206], [8.28369, 48.88277]]] }}";
doc.Parse(tzid_err);
BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
char missing_geom[] = "{ \"type\" : \"Feature\","
"\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometries\" : { "
"\"type\": \"polygon\", "