]> granicus.if.org Git - graphviz/commitdiff
tests: SvgAnalyzer: add comment with graph title (ID) to the recreated SVG
authorMagnus Jacobsson <Magnus.Jacobsson@berotec.se>
Wed, 27 Jul 2022 12:28:44 +0000 (14:28 +0200)
committerMagnus Jacobsson <Magnus.Jacobsson@berotec.se>
Tue, 16 Aug 2022 10:21:45 +0000 (12:21 +0200)
tests/svg_element.cpp
tests/test_svg_analyzer.cpp

index a0d32efa5a9d1cd64e635f8ce463c97ff5e90aa3..c842a4b90106895296357862a739db4f98f58f85 100644 (file)
@@ -49,6 +49,11 @@ void SVG::SVGElement::to_string_impl(std::string &output,
   const auto indent_str = std::string(current_indent, ' ');
   output += indent_str;
 
+  if (type == SVG::SVGElementType::Svg) {
+    const auto comment = fmt::format("Title: {} Pages: 1", graphviz_id);
+    output += fmt::format("<!-- {} -->\n", xml_encode(comment));
+  }
+
   output += "<";
   output += tag(type);
 
index f052a55a809a08fae0a8b56a07753624551b664e..84a2f37ee19659acfb1fb0f73ee45bf763741add 100644 (file)
@@ -124,8 +124,8 @@ TEST_CASE(
     for (std::size_t i = 0; i < original_svg_lines.size(); i++) {
       REQUIRE(i < recreated_svg_lines.size());
       if (recreated_svg_lines[i] == "<svg>") {
-        // stop comparison here since we do not yet handle the graph title
-        // comment that comes before the 'svg' element
+        // stop comparison here since we do not yet handle attributes on the
+        // 'svg' element
         break;
       }
       REQUIRE(recreated_svg_lines[i] == original_svg_lines[i]);