]> granicus.if.org Git - graphviz/commitdiff
tests: SvgAnalyzer: add node and edge ID comments to the recreated SVG
authorMagnus Jacobsson <Magnus.Jacobsson@berotec.se>
Fri, 29 Jul 2022 14:07:37 +0000 (16:07 +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 97c4545ef507caf581c735b6a4a1582965d56b41..efce9e1c992264ad0fecf7f0cd04c71d8491ec85 100644 (file)
@@ -55,6 +55,11 @@ void SVG::SVGElement::to_string_impl(std::string &output,
     const auto comment = fmt::format("Title: {} Pages: 1", graphviz_id);
     output += fmt::format("<!-- {} -->\n", xml_encode(comment));
   }
+  if (type == SVG::SVGElementType::Group &&
+      (attributes.class_ == "node" || attributes.class_ == "edge")) {
+    const auto comment = graphviz_id;
+    output += fmt::format("<!-- {} -->\n", xml_encode(comment));
+  }
 
   output += "<";
   output += tag(type);
index fb97d6ae223ca68e9750dec1231d60989da69ca0..2a32ebcb583c4807ed309c02fcbd22a0a5b00ecd 100644 (file)
@@ -148,5 +148,8 @@ TEST_CASE(
     }
     CHECK(recreated_svg.find("<polygon/>") != std::string::npos);
     CHECK(recreated_svg.find("<path/>") != std::string::npos);
+    CHECK(recreated_svg.find("<!-- a -->") != std::string::npos);
+    CHECK(recreated_svg.find("<!-- b -->") != std::string::npos);
+    CHECK(recreated_svg.find("<!-- a&#45;&gt;b -->") != std::string::npos);
   }
 }