Skip to content

Commit

Permalink
Missing tzid property wasn't a geojson validation issue, shouldn't ha…
Browse files Browse the repository at this point in the history
…ve been tested there.
  • Loading branch information
danpat committed Oct 26, 2018
1 parent 0779046 commit 7376697
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 30 deletions.
14 changes: 0 additions & 14 deletions include/util/geojson_validation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down
14 changes: 14 additions & 0 deletions unit_tests/updater/timezoner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
16 changes: 0 additions & 16 deletions unit_tests/updater/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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\", "
Expand Down

0 comments on commit 7376697

Please sign in to comment.