From: Magnus Jacobsson Date: Wed, 27 Jul 2022 20:07:08 +0000 (+0200) Subject: tests: SvgAnalyzer: add handling of the 'rx' and 'ry' attributes X-Git-Tag: 5.0.1~7^2~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ee301c5b002c2e1fdc50c07f609b55873c06dfdd;p=graphviz tests: SvgAnalyzer: add handling of the 'rx' and 'ry' attributes --- diff --git a/tests/svg_analyzer.cpp b/tests/svg_analyzer.cpp index b7ce39aac..aa47b6764 100644 --- a/tests/svg_analyzer.cpp +++ b/tests/svg_analyzer.cpp @@ -135,6 +135,10 @@ void SVGAnalyzer::set_id(std::string_view id) { current_element().attributes.id = id; } +void SVGAnalyzer::set_rx(double rx) { current_element().attributes.rx = rx; } + +void SVGAnalyzer::set_ry(double ry) { current_element().attributes.ry = ry; } + void SVGAnalyzer::set_point(std::pair point) { current_element().attributes.points.emplace_back(point.first, point.second); } diff --git a/tests/svg_analyzer.h b/tests/svg_analyzer.h index 499dcbdad..9eff98df9 100644 --- a/tests/svg_analyzer.h +++ b/tests/svg_analyzer.h @@ -32,6 +32,8 @@ public: void set_fill(std::string_view fill) override; void set_height(double height) override; void set_id(std::string_view id) override; + void set_rx(double rx) override; + void set_ry(double ry) override; void set_class(std::string_view) override; void set_stroke(std::string_view stroke) override; void set_point(std::pair point) override; diff --git a/tests/svg_analyzer_interface.h b/tests/svg_analyzer_interface.h index 14546982b..ea5a4a28f 100644 --- a/tests/svg_analyzer_interface.h +++ b/tests/svg_analyzer_interface.h @@ -32,6 +32,8 @@ public: virtual void set_fill(std::string_view fill) = 0; virtual void set_height(double height) = 0; virtual void set_id(std::string_view id) = 0; + virtual void set_rx(double rx) = 0; + virtual void set_ry(double ry) = 0; virtual void set_point(std::pair point) = 0; virtual void set_stroke(std::string_view stroke) = 0; virtual void set_text(std::string_view text) = 0; diff --git a/tests/svg_element.cpp b/tests/svg_element.cpp index 89666c8d7..6e29f588c 100644 --- a/tests/svg_element.cpp +++ b/tests/svg_element.cpp @@ -144,7 +144,8 @@ void SVG::SVGElement::to_string_impl(std::string &output, append_attribute(attributes_str, fill_attribute_to_string()); append_attribute(attributes_str, stroke_attribute_to_string()); attributes_str += - fmt::format(R"( cx="{}" cy="{}")", attributes.cx, attributes.cy); + fmt::format(R"( cx="{}" cy="{}" rx="{}" ry="{}")", attributes.cx, + attributes.cy, attributes.rx, attributes.ry); break; case SVG::SVGElementType::Group: attributes_str += fmt::format(R"( class="{}")", attributes.class_); diff --git a/tests/svg_element.h b/tests/svg_element.h index 855627d66..7d554554d 100644 --- a/tests/svg_element.h +++ b/tests/svg_element.h @@ -53,6 +53,8 @@ struct SVGAttributes { double height; std::string id; std::vector points; + double rx; + double ry; std::string stroke; std::optional transform; SVGRect viewBox; diff --git a/tests/svgpp_context.cpp b/tests/svgpp_context.cpp index 39ec5a764..1bdd293d6 100644 --- a/tests/svgpp_context.cpp +++ b/tests/svgpp_context.cpp @@ -170,14 +170,12 @@ void SvgppContext::set(svgpp::tag::attribute::r a, const double v) { (void)v; } -void SvgppContext::set(svgpp::tag::attribute::rx a, const double v) { - (void)a; - (void)v; +void SvgppContext::set(svgpp::tag::attribute::rx, const double v) { + m_svgAnalyzer->set_rx(v); } -void SvgppContext::set(svgpp::tag::attribute::ry a, const double v) { - (void)a; - (void)v; +void SvgppContext::set(svgpp::tag::attribute::ry, const double v) { + m_svgAnalyzer->set_ry(v); } void SvgppContext::set(svgpp::tag::attribute::x1 a, const double v) { diff --git a/tests/svgpp_document_traverser.cpp b/tests/svgpp_document_traverser.cpp index 98c4d69f5..9ed7421a6 100644 --- a/tests/svgpp_document_traverser.cpp +++ b/tests/svgpp_document_traverser.cpp @@ -33,6 +33,8 @@ void traverseDocumentWithSvgpp(SvgppContext &context, char *text) { svgpp::tag::attribute::height, // svgpp::tag::attribute::id, // svgpp::tag::attribute::points, // + svgpp::tag::attribute::rx, // + svgpp::tag::attribute::ry, // svgpp::tag::attribute::stroke, // svgpp::tag::attribute::transform, // svgpp::tag::attribute::viewBox, // diff --git a/tests/test_svg_analyzer.cpp b/tests/test_svg_analyzer.cpp index fe5681fb4..34469a9e5 100644 --- a/tests/test_svg_analyzer.cpp +++ b/tests/test_svg_analyzer.cpp @@ -123,11 +123,6 @@ TEST_CASE( boost::split(recreated_svg_lines, recreated_svg, boost::is_any_of("\n")); for (std::size_t i = 0; i < original_svg_lines.size(); i++) { REQUIRE(i < recreated_svg_lines.size()); - if (recreated_svg_lines[i].starts_with("")) { // stop comparison here for the 'cylinder' node shape since we do not @@ -144,10 +139,6 @@ TEST_CASE( // do some sanity checks of the parts of the recreated SVG that we cannot // yet compare with the original SVG - if (contains_ellipse_shape(shape)) { - CHECK(recreated_svg.find(" cx=\"") != std::string::npos); - CHECK(recreated_svg.find(" cy=\"") != std::string::npos); - } CHECK(recreated_svg.find("g1") != std::string::npos); CHECK(recreated_svg.find("a") != std::string::npos); CHECK(recreated_svg.find("b") != std::string::npos);