From: Magnus Jacobsson Date: Wed, 27 Jul 2022 19:42:19 +0000 (+0200) Subject: tests: SvgAnalyzer: add handling of the 'cx' and 'cy' attributes X-Git-Tag: 5.0.1~7^2~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=61377f837336d5c05721b64a9d584f5e1c24c818;p=graphviz tests: SvgAnalyzer: add handling of the 'cx' and 'cy' attributes --- diff --git a/tests/svg_analyzer.cpp b/tests/svg_analyzer.cpp index 3c004959b..b7ce39aac 100644 --- a/tests/svg_analyzer.cpp +++ b/tests/svg_analyzer.cpp @@ -115,6 +115,10 @@ void SVGAnalyzer::set_class(std::string_view class_) { current_element().attributes.class_ = class_; } +void SVGAnalyzer::set_cx(double cx) { current_element().attributes.cx = cx; } + +void SVGAnalyzer::set_cy(double cy) { current_element().attributes.cy = cy; } + void SVGAnalyzer::set_fill(std::string_view fill) { current_element().attributes.fill = fill; } diff --git a/tests/svg_analyzer.h b/tests/svg_analyzer.h index a21fec1af..499dcbdad 100644 --- a/tests/svg_analyzer.h +++ b/tests/svg_analyzer.h @@ -27,6 +27,8 @@ public: void on_enter_element_text() override; void on_enter_element_title() override; void on_exit_element() override; + void set_cx(double cx) override; + void set_cy(double cy) override; void set_fill(std::string_view fill) override; void set_height(double height) override; void set_id(std::string_view id) override; diff --git a/tests/svg_analyzer_interface.h b/tests/svg_analyzer_interface.h index 907c2112a..14546982b 100644 --- a/tests/svg_analyzer_interface.h +++ b/tests/svg_analyzer_interface.h @@ -27,6 +27,8 @@ public: virtual void on_enter_element_title() = 0; virtual void on_exit_element() = 0; virtual void set_class(std::string_view) = 0; + virtual void set_cx(double cx) = 0; + virtual void set_cy(double cy) = 0; 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; diff --git a/tests/svg_element.cpp b/tests/svg_element.cpp index 3a8084abc..89666c8d7 100644 --- a/tests/svg_element.cpp +++ b/tests/svg_element.cpp @@ -143,6 +143,8 @@ void SVG::SVGElement::to_string_impl(std::string &output, case SVG::SVGElementType::Ellipse: 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); 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 a23014212..855627d66 100644 --- a/tests/svg_element.h +++ b/tests/svg_element.h @@ -47,6 +47,8 @@ std::string_view tag(SVG::SVGElementType type); struct SVGAttributes { std::string class_; + double cx; + double cy; std::string fill; double height; std::string id; diff --git a/tests/svgpp_context.cpp b/tests/svgpp_context.cpp index 6b17f1d09..39ec5a764 100644 --- a/tests/svgpp_context.cpp +++ b/tests/svgpp_context.cpp @@ -116,14 +116,12 @@ void SvgppContext::path_close_subpath() {} void SvgppContext::path_exit() {} -void SvgppContext::set(svgpp::tag::attribute::cy a, const double v) { - (void)a; - (void)v; +void SvgppContext::set(svgpp::tag::attribute::cy, const double v) { + m_svgAnalyzer->set_cy(v); } -void SvgppContext::set(svgpp::tag::attribute::cx a, const double v) { - (void)a; - (void)v; +void SvgppContext::set(svgpp::tag::attribute::cx, const double v) { + m_svgAnalyzer->set_cx(v); } void SvgppContext::set(svgpp::tag::attribute::fill, svgpp::tag::value::none) { diff --git a/tests/svgpp_document_traverser.cpp b/tests/svgpp_document_traverser.cpp index 9dfed9dfb..98c4d69f5 100644 --- a/tests/svgpp_document_traverser.cpp +++ b/tests/svgpp_document_traverser.cpp @@ -27,6 +27,8 @@ void traverseDocumentWithSvgpp(SvgppContext &context, char *text) { using processed_attributes_t = boost::mpl::setg1") != std::string::npos); CHECK(recreated_svg.find("a") != std::string::npos); CHECK(recreated_svg.find("b") != std::string::npos);