From: Magnus Jacobsson Date: Tue, 26 Jul 2022 19:40:01 +0000 (+0200) Subject: tests: SvgAnalyzer: add generation of the 'xmlns' and' xmlns:xlink' attributes X-Git-Tag: 5.0.1~7^2~14 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a10f824da40a2829c9cd41527daa610f04f47c09;p=graphviz tests: SvgAnalyzer: add generation of the 'xmlns' and' xmlns:xlink' attributes --- diff --git a/tests/svg_element.cpp b/tests/svg_element.cpp index 2e33b33a9..639fa9554 100644 --- a/tests/svg_element.cpp +++ b/tests/svg_element.cpp @@ -88,14 +88,14 @@ void SVG::SVGElement::to_string_impl(std::string &output, // ignore for now break; case SVG::SVGElementType::Svg: - attributes_str += - fmt::format(R"(width="{}pt" height="{}pt")" - "\n" - R"( viewBox="{:.2f} {:.2f} {:.2f} {:.2f}")", - std::lround(px_to_pt(attributes.width)), - std::lround(px_to_pt(attributes.height)), - attributes.viewBox.x, attributes.viewBox.y, - attributes.viewBox.width, attributes.viewBox.height); + attributes_str += fmt::format( + R"(width="{}pt" height="{}pt")" + "\n" + R"( viewBox="{:.2f} {:.2f} {:.2f} {:.2f}" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink")", + std::lround(px_to_pt(attributes.width)), + std::lround(px_to_pt(attributes.height)), attributes.viewBox.x, + attributes.viewBox.y, attributes.viewBox.width, + attributes.viewBox.height); break; case SVG::SVGElementType::Text: // ignore for now diff --git a/tests/test_svg_analyzer.cpp b/tests/test_svg_analyzer.cpp index ff49e0dca..a77530f4f 100644 --- a/tests/test_svg_analyzer.cpp +++ b/tests/test_svg_analyzer.cpp @@ -123,9 +123,9 @@ 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 since we do not yet handle all attributes on the - // 'svg' element + // 'g' element break; } REQUIRE(recreated_svg_lines[i] == original_svg_lines[i]); @@ -133,10 +133,6 @@ TEST_CASE( // do some sanity checks of the parts of the recreated SVG that we cannot // yet compare with the original SVG - CHECK(recreated_svg.find("") != std::string::npos); CHECK(recreated_svg.find("") != std::string::npos); CHECK(recreated_svg.find("") != std::string::npos); CHECK(recreated_svg.find("") != std::string::npos);