From 69829e028d3795eaf72c73cb64e54e1fc7a4361a Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 23 Oct 2015 14:11:17 +0100 Subject: [PATCH] add simple I/O error test when file does not exist --- test/unit/datasource/csv.cpp | 21 +++++++++++++++++++++ test/unit/datasource/geojson.cpp | 25 +++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/test/unit/datasource/csv.cpp b/test/unit/datasource/csv.cpp index ff5eba49c..eee9b91bf 100644 --- a/test/unit/datasource/csv.cpp +++ b/test/unit/datasource/csv.cpp @@ -223,6 +223,27 @@ TEST_CASE("csv") { const bool have_csv_plugin = std::find(plugin_names.begin(), plugin_names.end(), "csv") != plugin_names.end(); + SECTION("CSV I/O errors") + { + std::string filename = "does_not_exist.csv"; + for (auto create_index : { true, false }) + { + if (create_index) + { + int ret = create_disk_index(filename); + int ret_posix = (ret >> 8) & 0x000000ff; + INFO(ret); + INFO(ret_posix); + // index wont be created + CHECK(!mapnik::util::exists(filename + ".index")); + } + mapnik::parameters params; + params["type"] = "csv"; + params["file"] = filename; + REQUIRE_THROWS(mapnik::datasource_cache::instance().create(params)); + } + } + SECTION("broken files") { for (auto create_index : { false, true }) diff --git a/test/unit/datasource/geojson.cpp b/test/unit/datasource/geojson.cpp index db167a844..6158a0def 100644 --- a/test/unit/datasource/geojson.cpp +++ b/test/unit/datasource/geojson.cpp @@ -80,6 +80,31 @@ TEST_CASE("geojson") { std::string geojson_plugin("./plugins/input/geojson.input"); if (mapnik::util::exists(geojson_plugin)) { + SECTION("GeoJSON I/O errors") + { + std::string filename = "does_not_exist.geojson"; + for (auto create_index : { true, false }) + { + if (create_index) + { + int ret = create_disk_index(filename); + int ret_posix = (ret >> 8) & 0x000000ff; + INFO(ret); + INFO(ret_posix); + // index wont be created + CHECK(!mapnik::util::exists(filename + ".index")); + } + + for (auto cache_features : {true, false}) + { + mapnik::parameters params; + params["type"] = "geojson"; + params["file"] = filename; + params["cache_features"] = cache_features; + REQUIRE_THROWS(mapnik::datasource_cache::instance().create(params)); + } + } + } SECTION("GeoJSON Point") { for (auto cache_features : {true, false})