From d05c13d8491025ebd7b49ac2182fcde3e8eb87b6 Mon Sep 17 00:00:00 2001 From: artemp Date: Wed, 29 Jul 2015 15:42:53 +0200 Subject: [PATCH] unit test - cope with incorrectly encoded geometries --- test/data | 2 +- test/unit/svg/svg_parser_test.cpp | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/test/data b/test/data index 503856319..e0058873d 160000 --- a/test/data +++ b/test/data @@ -1 +1 @@ -Subproject commit 5038563194e75b95af155a337ce48f6478534022 +Subproject commit e0058873df6a16b1eeef15c3ae0be09d3c0d700b diff --git a/test/unit/svg/svg_parser_test.cpp b/test/unit/svg/svg_parser_test.cpp index 2378deb55..16748a3ad 100644 --- a/test/unit/svg/svg_parser_test.cpp +++ b/test/unit/svg/svg_parser_test.cpp @@ -95,6 +95,27 @@ TEST_CASE("SVG parser") { } } + SECTION("SVG - cope with erroneous geometries") + { + std::string svg_name("./test/data/svg/errors.svg"); + std::ifstream in(svg_name.c_str()); + std::string svg_str((std::istreambuf_iterator(in)), + std::istreambuf_iterator()); + + using namespace mapnik::svg; + mapnik::svg_storage_type path; + vertex_stl_adapter stl_storage(path.source()); + svg_path_adapter svg_path(stl_storage); + svg_converter_type svg(svg_path, path.attributes()); + svg_parser p(svg); + + if (!p.parse_from_string(svg_str)) + { + auto const& errors = p.error_messages(); + REQUIRE(errors.size() == 10); + } + } + SECTION("SVG parser display=none") {