Fix error message + update SVG parser unit test

This commit is contained in:
Artem Pavlenko 2021-04-15 16:29:05 +01:00
parent fd204874ec
commit 7c5f4539e1
2 changed files with 4 additions and 2 deletions

View file

@ -966,10 +966,10 @@ void parse_dimensions(svg_parser & parser, rapidxml::xml_node<char> const* node)
else if (width == 0 || height == 0 || has_percent_width || has_percent_height) else if (width == 0 || height == 0 || has_percent_width || has_percent_height)
{ {
std::stringstream ss; std::stringstream ss;
ss << "SVG parse error: can't infer valid image dimensions from \" width:"; ss << "SVG parse error: can't infer valid image dimensions from width:\"";
if (has_percent_width) ss << width * 100 << "%"; if (has_percent_width) ss << width * 100 << "%";
else ss << width; else ss << width;
ss << " height:"; ss << "\" height:\"";
if (has_percent_height) ss << height * 100 << "%"; if (has_percent_height) ss << height * 100 << "%";
else ss << height; else ss << height;
ss << "\""; ss << "\"";

View file

@ -149,6 +149,7 @@ TEST_CASE("SVG parser") {
std::string svg_name("./test/data/svg/color_fail.svg"); std::string svg_name("./test/data/svg/color_fail.svg");
char const* expected_errors[] = char const* expected_errors[] =
{ {
"SVG parse error: can't infer valid image dimensions from width:\"100%\" height:\"100%\"",
"SVG parse error: failed to parse <color> with value \"fail\"", "SVG parse error: failed to parse <color> with value \"fail\"",
"SVG parse error: failed to parse <number> with value \"fail\"" "SVG parse error: failed to parse <number> with value \"fail\""
}; };
@ -180,6 +181,7 @@ TEST_CASE("SVG parser") {
std::string svg_name("./test/data/svg/errors.svg"); std::string svg_name("./test/data/svg/errors.svg");
char const* expected_errors[] = char const* expected_errors[] =
{ {
"SVG parse error: can't infer valid image dimensions from width:\"100%\" height:\"100%\"",
"SVG validation error: invalid <rect> width \"-100\"", "SVG validation error: invalid <rect> width \"-100\"",
"SVG parse error: failed to parse <number> with value \"FAIL\"", "SVG parse error: failed to parse <number> with value \"FAIL\"",
"SVG validation error: invalid <rect> height \"-100\"", "SVG validation error: invalid <rect> height \"-100\"",