Merge remote-tracking branch 'origin/master' into geobuf.input
This commit is contained in:
commit
16d952f70b
20 changed files with 228 additions and 61 deletions
|
@ -36,6 +36,7 @@ Released: June 5, 2017
|
|||
- shapeindex - return error code when no features can read from shapefile (#3198)
|
||||
- Upgrade Scons to `2.5.1`
|
||||
- Fixed bug (typo) in `raster_featureset.cpp` (#3696)
|
||||
- Made `freetype_engine` singleton again. This allows for better control of its life-time. Original interface is preserved via adding static methods (#3688)
|
||||
|
||||
## 3.0.13
|
||||
|
||||
|
|
|
@ -164,6 +164,8 @@ struct geometry_type_ : x3::symbols<mapnik::geometry::geometry_types>
|
|||
}
|
||||
} geometry_type_symbols;
|
||||
|
||||
namespace {
|
||||
|
||||
auto assign_name = [](auto const& ctx)
|
||||
{
|
||||
std::get<0>(_val(ctx)) = std::move(_attr(ctx));
|
||||
|
@ -173,6 +175,8 @@ auto assign_value = [](auto const& ctx)
|
|||
std::get<1>(_val(ctx)) = std::move(_attr(ctx));
|
||||
};
|
||||
|
||||
} // VS2017
|
||||
|
||||
auto const assign_geometry_type = [] (auto const& ctx)
|
||||
{
|
||||
std::get<0>(_val(ctx)) = _attr(ctx);
|
||||
|
|
|
@ -31,6 +31,8 @@ namespace mapnik { namespace json { namespace grammar {
|
|||
|
||||
namespace x3 = boost::spirit::x3;
|
||||
|
||||
namespace {
|
||||
|
||||
auto make_null = [] (auto const& ctx)
|
||||
{
|
||||
_val(ctx) = mapnik::value_null{};
|
||||
|
@ -48,19 +50,20 @@ auto make_false = [] (auto const& ctx)
|
|||
|
||||
auto assign = [](auto const& ctx)
|
||||
{
|
||||
_val(ctx) = _attr(ctx);
|
||||
_val(ctx) = std::move(_attr(ctx));
|
||||
};
|
||||
|
||||
auto assign_key = [](auto const& ctx)
|
||||
{
|
||||
std::get<0>(_val(ctx)) = _attr(ctx);
|
||||
std::get<0>(_val(ctx)) = std::move(_attr(ctx));
|
||||
};
|
||||
|
||||
auto assign_value = [](auto const& ctx)
|
||||
{
|
||||
std::get<1>(_val(ctx)) = _attr(ctx);
|
||||
std::get<1>(_val(ctx)) = std::move(_attr(ctx));
|
||||
};
|
||||
|
||||
} // VS2017
|
||||
|
||||
using x3::lit;
|
||||
using x3::string;
|
||||
|
|
|
@ -69,8 +69,8 @@ public:
|
|||
explicit svg_parser(svg_converter_type & path, bool strict = false);
|
||||
~svg_parser();
|
||||
error_handler & err_handler();
|
||||
bool parse(std::string const& filename);
|
||||
bool parse_from_string(std::string const& svg);
|
||||
void parse(std::string const& filename);
|
||||
void parse_from_string(std::string const& svg);
|
||||
svg_converter_type & path_;
|
||||
bool is_defs_;
|
||||
bool strict_;
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include <mapnik/warning_ignore.hpp>
|
||||
#include <harfbuzz/hb.h>
|
||||
#include <harfbuzz/hb-ft.h>
|
||||
#include <unicode/uvernum.h>
|
||||
#include <unicode/uscript.h>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
|
@ -54,7 +55,8 @@ static inline hb_script_t _icu_script_to_script(UScriptCode script)
|
|||
static inline const uint16_t * uchar_to_utf16(const UChar* src)
|
||||
{
|
||||
static_assert(sizeof(UChar) == sizeof(uint16_t),"UChar is eq size to uint16_t");
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) || (U_ICU_VERSION_MAJOR_NUM >= 59)
|
||||
// ^^ http://site.icu-project.org/download/59#TOC-ICU4C-char16_t1
|
||||
return reinterpret_cast<const uint16_t *>(src);
|
||||
#else
|
||||
return src;
|
||||
|
|
|
@ -171,7 +171,7 @@ struct transform_node
|
|||
: base_() {}
|
||||
|
||||
template <typename T>
|
||||
transform_node(T const& val)
|
||||
explicit transform_node(T const& val)
|
||||
: base_(val) {}
|
||||
|
||||
template <typename T>
|
||||
|
|
|
@ -31,6 +31,13 @@
|
|||
// std
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
// icu
|
||||
#if (U_ICU_VERSION_MAJOR_NUM >= 59)
|
||||
#pragma GCC diagnostic push
|
||||
#include <mapnik/warning_ignore.hpp>
|
||||
#include <unicode/unistr.h>
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
struct UConverter;
|
||||
|
||||
|
|
|
@ -545,7 +545,7 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
|
|||
if (alpha)
|
||||
{
|
||||
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: processing alpha band...";
|
||||
if (!raster_has_nodata)
|
||||
if (!raster_has_nodata || (red && green && blue))
|
||||
{
|
||||
raster_io_error = alpha->RasterIO(GF_Read, x_off, y_off, width, height, image.bytes() + 3,
|
||||
image.width(), image.height(), GDT_Byte, 4, 4 * image.width());
|
||||
|
|
|
@ -149,6 +149,7 @@ void cairo_renderer<T>::setup(Map const& map)
|
|||
{
|
||||
cairo_save_restore guard(context_);
|
||||
context_.set_color(*bg);
|
||||
context_.set_operator(composite_mode_e::src);
|
||||
context_.paint();
|
||||
}
|
||||
boost::optional<std::string> const& image_filename = map.background_image();
|
||||
|
|
|
@ -1380,7 +1380,6 @@ void map_parser::parse_raster_symbolizer(rule & rule, xml_node const & node)
|
|||
{
|
||||
found_colorizer = true;
|
||||
raster_colorizer_ptr colorizer = std::make_shared<raster_colorizer>();
|
||||
put(raster_sym, keys::colorizer, colorizer);
|
||||
if (parse_raster_colorizer(colorizer, css))
|
||||
put(raster_sym, keys::colorizer, colorizer);
|
||||
}
|
||||
|
|
|
@ -175,14 +175,14 @@ std::shared_ptr<mapnik::marker const> marker_cache::find(std::string const& uri,
|
|||
svg_path_adapter svg_path(stl_storage);
|
||||
svg_converter_type svg(svg_path, marker_path->attributes());
|
||||
svg_parser p(svg, strict);
|
||||
p.parse_from_string(known_svg_string);
|
||||
|
||||
if (!p.parse_from_string(known_svg_string) && !strict)
|
||||
if (!strict)
|
||||
{
|
||||
for (auto const& msg : p.err_handler().error_messages())
|
||||
{
|
||||
MAPNIK_LOG_ERROR(marker_cache) << "SVG PARSING ERROR:\"" << msg << "\"";
|
||||
}
|
||||
//return std::make_shared<mapnik::marker const>(mapnik::marker_null());
|
||||
}
|
||||
//svg.arrange_orientations();
|
||||
double lox,loy,hix,hiy;
|
||||
|
@ -215,15 +215,14 @@ std::shared_ptr<mapnik::marker const> marker_cache::find(std::string const& uri,
|
|||
svg_path_adapter svg_path(stl_storage);
|
||||
svg_converter_type svg(svg_path, marker_path->attributes());
|
||||
svg_parser p(svg, strict);
|
||||
p.parse(uri);
|
||||
|
||||
|
||||
if (!p.parse(uri) && !strict)
|
||||
if (!strict)
|
||||
{
|
||||
for (auto const& msg : p.err_handler().error_messages())
|
||||
{
|
||||
MAPNIK_LOG_ERROR(marker_cache) << "SVG PARSING ERROR:\"" << msg << "\"";
|
||||
}
|
||||
//return std::make_shared<mapnik::marker const>(mapnik::marker_null());
|
||||
}
|
||||
//svg.arrange_orientations();
|
||||
double lox,loy,hix,hiy;
|
||||
|
|
|
@ -80,7 +80,7 @@ namespace mapnik { namespace svg {
|
|||
|
||||
namespace rapidxml = boost::property_tree::detail::rapidxml;
|
||||
|
||||
bool traverse_tree(svg_parser& parser, rapidxml::xml_node<char> const* node);
|
||||
void traverse_tree(svg_parser& parser, rapidxml::xml_node<char> const* node);
|
||||
void end_element(svg_parser& parser, rapidxml::xml_node<char> const* node);
|
||||
void parse_path(svg_parser& parser, rapidxml::xml_node<char> const* node);
|
||||
void parse_element(svg_parser& parser, char const* name, rapidxml::xml_node<char> const* node);
|
||||
|
@ -112,7 +112,7 @@ static std::array<unsigned, 7> const unsupported_elements
|
|||
name_to_int("a")}
|
||||
};
|
||||
|
||||
|
||||
#if 0 // disable to reduce verbosity
|
||||
static std::array<unsigned, 43> const unsupported_attributes
|
||||
{ {name_to_int("alignment-baseline"),
|
||||
name_to_int("baseline-shift"),
|
||||
|
@ -158,6 +158,8 @@ static std::array<unsigned, 43> const unsupported_attributes
|
|||
name_to_int("writing-mode")}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
template <typename T>
|
||||
void handle_unsupported(svg_parser& parser, T const& ar, char const* name)
|
||||
{
|
||||
|
@ -166,7 +168,7 @@ void handle_unsupported(svg_parser& parser, T const& ar, char const* name)
|
|||
{
|
||||
if (e == element)
|
||||
{
|
||||
parser.err_handler().on_error(std::string("Unsupported:\"") + name);
|
||||
parser.err_handler().on_error(std::string("Unsupported:'") + name + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -368,7 +370,7 @@ bool parse_id_from_url (char const* str, std::string & id)
|
|||
x3::space);
|
||||
}
|
||||
|
||||
bool traverse_tree(svg_parser & parser, rapidxml::xml_node<char> const* node)
|
||||
void traverse_tree(svg_parser & parser, rapidxml::xml_node<char> const* node)
|
||||
{
|
||||
auto const* name = node->name();
|
||||
switch (node->type())
|
||||
|
@ -464,7 +466,6 @@ bool traverse_tree(svg_parser & parser, rapidxml::xml_node<char> const* node)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -697,7 +698,8 @@ void parse_attr(svg_parser & parser, char const* name, char const* value )
|
|||
}
|
||||
break;
|
||||
default:
|
||||
handle_unsupported(parser, unsupported_attributes, name);
|
||||
//handle_unsupported(parser, unsupported_attributes, name);
|
||||
// disable for now to reduce verbosity
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1403,7 +1405,7 @@ svg_parser::svg_parser(svg_converter<svg_path_adapter,
|
|||
|
||||
svg_parser::~svg_parser() {}
|
||||
|
||||
bool svg_parser::parse(std::string const& filename)
|
||||
void svg_parser::parse(std::string const& filename)
|
||||
{
|
||||
#ifdef _WINDOWS
|
||||
std::basic_ifstream<char> stream(mapnik::utf8_to_utf16(filename));
|
||||
|
@ -1414,8 +1416,7 @@ bool svg_parser::parse(std::string const& filename)
|
|||
{
|
||||
std::stringstream ss;
|
||||
ss << "Unable to open '" << filename << "'";
|
||||
err_handler_.on_error(ss.str());
|
||||
return false;
|
||||
throw std::runtime_error(ss.str());
|
||||
}
|
||||
|
||||
stream.unsetf(std::ios::skipws);
|
||||
|
@ -1433,8 +1434,7 @@ bool svg_parser::parse(std::string const& filename)
|
|||
{
|
||||
std::stringstream ss;
|
||||
ss << "svg_parser::parse - Unable to parse '" << filename << "'";
|
||||
err_handler_.on_error(ss.str());
|
||||
return false;
|
||||
throw std::runtime_error(ss.str());
|
||||
}
|
||||
|
||||
for (rapidxml::xml_node<char> const* child = doc.first_node();
|
||||
|
@ -1442,10 +1442,9 @@ bool svg_parser::parse(std::string const& filename)
|
|||
{
|
||||
traverse_tree(*this, child);
|
||||
}
|
||||
return err_handler_.error_messages().empty() ? true : false;
|
||||
}
|
||||
|
||||
bool svg_parser::parse_from_string(std::string const& svg)
|
||||
void svg_parser::parse_from_string(std::string const& svg)
|
||||
{
|
||||
const int flags = rapidxml::parse_trim_whitespace | rapidxml::parse_validate_closing_tags;
|
||||
rapidxml::xml_document<> doc;
|
||||
|
@ -1459,15 +1458,13 @@ bool svg_parser::parse_from_string(std::string const& svg)
|
|||
{
|
||||
std::stringstream ss;
|
||||
ss << "Unable to parse '" << svg << "'";
|
||||
err_handler_.on_error(ss.str());
|
||||
return false;
|
||||
throw std::runtime_error(ss.str());
|
||||
}
|
||||
for (rapidxml::xml_node<char> const* child = doc.first_node();
|
||||
child; child = child->next_sibling())
|
||||
{
|
||||
traverse_tree(*this, child);
|
||||
}
|
||||
return err_handler_.error_messages().empty() ? true : false;
|
||||
}
|
||||
|
||||
svg_parser::error_handler & svg_parser::err_handler()
|
||||
|
|
|
@ -157,6 +157,7 @@ void composite_color_bitmap(T & pixmap, FT_Bitmap *bitmap, int x, int y, double
|
|||
int scaled_height = bitmap->rows * scale;
|
||||
image_rgba8 scaled_image(scaled_width, scaled_height);
|
||||
scale_image_agg(scaled_image, image , SCALING_BILINEAR , scale, scale, 0.0, 0.0, 1.0, 0);
|
||||
set_premultiplied_alpha(scaled_image, true);
|
||||
composite(pixmap, scaled_image, comp_op, opacity, x, y);
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 99da07d5e76ccf5978ef0a380bf5f631f9088584
|
||||
Subproject commit f95fe1c7b56a5eeb4fa2c2bcdc403d9254ce7448
|
|
@ -1 +1 @@
|
|||
Subproject commit fd518f1f512b8aea4ac740c2ce12c249616a291c
|
||||
Subproject commit df578e3436681bb9bc582c7ac55a4205e98334f4
|
|
@ -33,6 +33,8 @@
|
|||
#include <mapnik/util/fs.hpp>
|
||||
#include <cstdlib>
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <locale>
|
||||
#include <boost/optional/optional_io.hpp>
|
||||
|
||||
/*
|
||||
|
|
66
test/unit/map/background.cpp
Normal file
66
test/unit/map/background.cpp
Normal file
|
@ -0,0 +1,66 @@
|
|||
|
||||
#include "catch.hpp"
|
||||
|
||||
#include <mapnik/map.hpp>
|
||||
#include <mapnik/agg_renderer.hpp>
|
||||
|
||||
#if defined(HAVE_CAIRO)
|
||||
#include <mapnik/cairo/cairo_renderer.hpp>
|
||||
#include <mapnik/cairo/cairo_image_util.hpp>
|
||||
#endif
|
||||
|
||||
TEST_CASE("map") {
|
||||
|
||||
SECTION("set background - agg") {
|
||||
|
||||
mapnik::Map map(256, 256);
|
||||
mapnik::image_rgba8 image(map.width(), map.height());
|
||||
const mapnik::color c1(255, 0, 0);
|
||||
mapnik::fill(image, c1);
|
||||
|
||||
CHECK(image(0, 0) == c1.rgba());
|
||||
|
||||
// Fully transparent black should replace red color
|
||||
const mapnik::color c2(0, 0, 0, 0);
|
||||
map.set_background(c2);
|
||||
mapnik::agg_renderer<mapnik::image_rgba8> ren(map, image);
|
||||
ren.apply();
|
||||
|
||||
CHECK(image(0, 0) == c2.rgba());
|
||||
}
|
||||
|
||||
#if defined(HAVE_CAIRO)
|
||||
SECTION("set background - cairo") {
|
||||
|
||||
mapnik::Map map(256, 256);
|
||||
mapnik::cairo_surface_ptr image_surface(
|
||||
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, map.width(), map.height()),
|
||||
mapnik::cairo_surface_closer());
|
||||
mapnik::cairo_ptr image_context(mapnik::create_context(image_surface));
|
||||
|
||||
cairo_set_source_rgba(image_context.get(), 1.0, 0.0, 0.0, 1.0);
|
||||
cairo_paint(image_context.get());
|
||||
|
||||
{
|
||||
mapnik::image_rgba8 image(map.width(), map.height());
|
||||
mapnik::cairo_image_to_rgba8(image, image_surface);
|
||||
const mapnik::color c1(255, 0, 0);
|
||||
CHECK(image(0, 0) == c1.rgba());
|
||||
}
|
||||
|
||||
// Fully transparent black should replace red color
|
||||
const mapnik::color c2(0, 0, 0, 0);
|
||||
map.set_background(c2);
|
||||
mapnik::cairo_renderer<mapnik::cairo_ptr> ren(map, image_context, 1.0);
|
||||
ren.apply();
|
||||
|
||||
{
|
||||
mapnik::image_rgba8 image(map.width(), map.height());
|
||||
mapnik::cairo_image_to_rgba8(image, image_surface);
|
||||
CHECK(image(0, 0) == c2.rgba());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
@ -129,8 +129,8 @@ TEST_CASE("Well-known-geometries")
|
|||
geom_3.emplace_back(0,0);
|
||||
geom_3.emplace_back(1,1);
|
||||
geom_3.emplace_back(2,2);
|
||||
REQUIRE(mapnik::util::to_wkt(wkt0, geom_2));
|
||||
REQUIRE(mapnik::util::to_wkt(wkt1, geom_3));
|
||||
REQUIRE(mapnik::util::to_wkt(wkt0, mapnik::geometry::geometry<std::int64_t>(geom_2)));
|
||||
REQUIRE(mapnik::util::to_wkt(wkt1, mapnik::geometry::geometry<std::int64_t>(geom_3)));
|
||||
if (!mapnik::geometry::is_empty(geom_2) && !mapnik::geometry::is_empty(geom_3))
|
||||
{
|
||||
REQUIRE(wkt2 == wkt3);
|
||||
|
|
|
@ -44,11 +44,11 @@ namespace // internal
|
|||
mapnik::svg::svg_converter_type svg;
|
||||
mapnik::svg::svg_parser p;
|
||||
|
||||
test_parser()
|
||||
explicit test_parser(bool strict = false)
|
||||
: stl_storage(path.source())
|
||||
, svg_path(stl_storage)
|
||||
, svg(svg_path, path.attributes())
|
||||
, p(svg)
|
||||
, p(svg, strict)
|
||||
{}
|
||||
|
||||
mapnik::svg::svg_parser* operator->()
|
||||
|
@ -91,8 +91,14 @@ TEST_CASE("SVG parser") {
|
|||
};
|
||||
|
||||
test_parser p;
|
||||
REQUIRE(!p->parse(svg_name));
|
||||
REQUIRE(join(p->err_handler().error_messages()) == join(expected_errors));
|
||||
try
|
||||
{
|
||||
p->parse(svg_name);
|
||||
}
|
||||
catch (std::exception const& ex)
|
||||
{
|
||||
REQUIRE(ex.what() == join(expected_errors));
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("SVG::parse_from_string syntax error")
|
||||
|
@ -108,8 +114,14 @@ TEST_CASE("SVG parser") {
|
|||
std::istreambuf_iterator<char>());
|
||||
|
||||
test_parser p;
|
||||
REQUIRE(!p->parse_from_string(svg_str));
|
||||
REQUIRE(join(p->err_handler().error_messages()) == join(expected_errors));
|
||||
try
|
||||
{
|
||||
p->parse_from_string(svg_str);
|
||||
}
|
||||
catch (std::exception const& ex)
|
||||
{
|
||||
REQUIRE(ex.what() == join(expected_errors));
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("SVG::parse_from_string syntax error")
|
||||
|
@ -121,8 +133,14 @@ TEST_CASE("SVG parser") {
|
|||
};
|
||||
|
||||
test_parser p;
|
||||
REQUIRE(!p->parse(svg_name));
|
||||
REQUIRE(join(p->err_handler().error_messages()) == join(expected_errors));
|
||||
try
|
||||
{
|
||||
p->parse(svg_name);
|
||||
}
|
||||
catch (std::exception const& ex)
|
||||
{
|
||||
REQUIRE(ex.what() == join(expected_errors));
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("SVG parser color <fail>")
|
||||
|
@ -140,10 +158,23 @@ TEST_CASE("SVG parser") {
|
|||
std::string svg_str((std::istreambuf_iterator<char>(in)),
|
||||
std::istreambuf_iterator<char>());
|
||||
|
||||
{
|
||||
test_parser p;
|
||||
REQUIRE(!p->parse_from_string(svg_str));
|
||||
p->parse_from_string(svg_str);
|
||||
REQUIRE(join(p->err_handler().error_messages()) == join(expected_errors));
|
||||
}
|
||||
{
|
||||
test_parser p(true);
|
||||
try
|
||||
{
|
||||
p->parse_from_string(svg_str);
|
||||
}
|
||||
catch (std::exception const& ex)
|
||||
{
|
||||
REQUIRE(ex.what() == std::string(expected_errors[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("SVG - cope with erroneous geometries")
|
||||
{
|
||||
|
@ -170,11 +201,26 @@ TEST_CASE("SVG parser") {
|
|||
std::string svg_str((std::istreambuf_iterator<char>(in)),
|
||||
std::istreambuf_iterator<char>());
|
||||
|
||||
{
|
||||
test_parser p;
|
||||
REQUIRE(!p->parse_from_string(svg_str));
|
||||
p->parse_from_string(svg_str);
|
||||
REQUIRE(join(p->err_handler().error_messages()) == join(expected_errors));
|
||||
}
|
||||
|
||||
{
|
||||
// strict
|
||||
test_parser p(true);
|
||||
try
|
||||
{
|
||||
p->parse_from_string(svg_str);
|
||||
}
|
||||
catch (std::exception const& ex)
|
||||
{
|
||||
REQUIRE(ex.what() == std::string(expected_errors[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("SVG parser double % <fail>")
|
||||
{
|
||||
|
||||
|
@ -188,10 +234,23 @@ TEST_CASE("SVG parser") {
|
|||
std::string svg_str((std::istreambuf_iterator<char>(in)),
|
||||
std::istreambuf_iterator<char>());
|
||||
|
||||
{
|
||||
test_parser p;
|
||||
REQUIRE(!p->parse_from_string(svg_str));
|
||||
p->parse_from_string(svg_str);
|
||||
REQUIRE(join(p->err_handler().error_messages()) == join(expected_errors));
|
||||
}
|
||||
{
|
||||
test_parser p(true);
|
||||
try
|
||||
{
|
||||
p->parse_from_string(svg_str);
|
||||
}
|
||||
catch (std::exception const& ex)
|
||||
{
|
||||
REQUIRE(ex.what() == std::string(expected_errors[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("SVG parser display=none")
|
||||
{
|
||||
|
@ -327,7 +386,7 @@ TEST_CASE("SVG parser") {
|
|||
std::string svg_str((std::istreambuf_iterator<char>(in)),
|
||||
std::istreambuf_iterator<char>());
|
||||
test_parser p;
|
||||
REQUIRE(p->parse_from_string(svg_str));
|
||||
p->parse_from_string(svg_str);
|
||||
auto width = p.svg.width();
|
||||
auto height = p.svg.height();
|
||||
REQUIRE(width == 100);
|
||||
|
@ -610,11 +669,23 @@ TEST_CASE("SVG parser") {
|
|||
"Failed to find gradient fill: MyGradient",
|
||||
"Failed to find gradient stroke: MyGradient",
|
||||
};
|
||||
|
||||
{
|
||||
test_parser p;
|
||||
REQUIRE(!p->parse(svg_name));
|
||||
p->parse(svg_name);
|
||||
REQUIRE(join(p->err_handler().error_messages()) == join(expected_errors));
|
||||
}
|
||||
{
|
||||
test_parser p(true);
|
||||
try
|
||||
{
|
||||
p->parse(svg_name);
|
||||
}
|
||||
catch (std::exception const& ex)
|
||||
{
|
||||
REQUIRE(ex.what() == std::string(expected_errors[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("SVG missing <gradient> id")
|
||||
{
|
||||
|
@ -629,10 +700,23 @@ TEST_CASE("SVG parser") {
|
|||
std::string svg_str((std::istreambuf_iterator<char>(in)),
|
||||
std::istreambuf_iterator<char>());
|
||||
|
||||
{
|
||||
test_parser p;
|
||||
REQUIRE(!p->parse_from_string(svg_str));
|
||||
p->parse_from_string(svg_str);
|
||||
REQUIRE(join(p->err_handler().error_messages()) == join(expected_errors));
|
||||
}
|
||||
{
|
||||
test_parser p(true);
|
||||
try
|
||||
{
|
||||
p->parse_from_string(svg_str);
|
||||
}
|
||||
catch (std::exception const& ex)
|
||||
{
|
||||
REQUIRE(ex.what() == std::string(expected_errors[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("SVG missing <gradient> inheritance")
|
||||
{
|
||||
|
|
|
@ -38,8 +38,9 @@ namespace visual_tests {
|
|||
|
||||
namespace x3 = boost::spirit::x3;
|
||||
using x3::ulong_;
|
||||
auto const map_sizes_grammar = x3::rule<class map_sizes_grammar_type, std::vector<map_size> >{} =
|
||||
(ulong_ >> ',' >> ulong_) % ';' ;
|
||||
auto const map_size_rule = x3::rule<class map_size_rule, map_size> {} = ulong_ >> ',' >> ulong_;
|
||||
auto const map_sizes_grammar = x3::rule<class map_sizes_grammar_type, std::vector<map_size> > {} =
|
||||
map_size_rule % ';' ;
|
||||
|
||||
void parse_map_sizes(std::string const & str, std::vector<map_size> & sizes)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue