From 9940193c0bf118f75014c2868c05eb36b46aca6f Mon Sep 17 00:00:00 2001 From: artemp Date: Thu, 1 Jun 2017 15:27:17 +0200 Subject: [PATCH] return error code when no feature can be read from shapefile + update unit test (ref #3198) --- test/unit/datasource/shapeindex.cpp | 8 ++++++-- utils/shapeindex/shapeindex.cpp | 5 +++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/test/unit/datasource/shapeindex.cpp b/test/unit/datasource/shapeindex.cpp index 51f47ac7c..494bba2d7 100644 --- a/test/unit/datasource/shapeindex.cpp +++ b/test/unit/datasource/shapeindex.cpp @@ -162,9 +162,13 @@ TEST_CASE("shapeindex") // count features std::size_t feature_count = count_shapefile_features(path); // 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 } // count features diff --git a/utils/shapeindex/shapeindex.cpp b/utils/shapeindex/shapeindex.cpp index 9dcff1189..bad45d236 100644 --- a/utils/shapeindex/shapeindex.cpp +++ b/utils/shapeindex/shapeindex.cpp @@ -37,7 +37,7 @@ #pragma GCC diagnostic pop const int DEFAULT_DEPTH = 8; -const double DEFAULT_RATIO=0.55; +const double DEFAULT_RATIO = 0.55; int main (int argc,char** argv) { @@ -278,7 +278,8 @@ int main (int argc,char** argv) } 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; } }