return error code when no feature can be read from shapefile + update unit test.

This commit is contained in:
artemp 2017-06-01 15:27:17 +02:00
parent dfa8f100b2
commit 82a7d07b7f
2 changed files with 9 additions and 4 deletions

View file

@ -162,9 +162,13 @@ TEST_CASE("shapeindex")
// count features // count features
std::size_t feature_count = count_shapefile_features(path); std::size_t feature_count = count_shapefile_features(path);
// create *.index // create *.index
REQUIRE(create_shapefile_index(path, index_parts) == 0); if (feature_count > 0)
if (feature_count == 0)
{ {
REQUIRE(create_shapefile_index(path, index_parts) == EXIT_SUCCESS);
}
else
{
REQUIRE(create_shapefile_index(path, index_parts) != EXIT_SUCCESS);
REQUIRE(!mapnik::util::exists(index_path)); // index won't be created if there's no features REQUIRE(!mapnik::util::exists(index_path)); // index won't be created if there's no features
} }
// count features // count features

View file

@ -281,7 +281,8 @@ int main (int argc,char** argv)
} }
else else
{ {
std::clog << "No non-empty geometries in shapefile" << std::endl; std::clog << "Failed to read any features from \"" << filename << "\"" << std::endl;
return EXIT_FAILURE;
} }
} }