Debian Codegraph @

tests/test_edge_penwidth.cpp

raw
1 #include <catch2/catch_all.hpp>
2 #include <format>
3
4 #include "svg_analyzer.h"
5 #include "test_utilities.h"
6
7 TEST_CASE("Edge penwidth",
8 "Test that the Graphviz 'penwidth' attribute is used to set the "
9 "'stroke-width' attribute correctly for edges in the generated SVG") {
10
11 const auto primitive_arrow_shape =
12 GENERATE(from_range(all_primitive_arrow_shapes));
13 INFO("Primitive arrow shape: " << primitive_arrow_shape);
14
15 const auto edge_penwidth = GENERATE(0.5, 1.0, 2.0);
16 INFO("Edge penwidth: " << edge_penwidth);
17
18 auto dot =
19 std::format("digraph g1 {{edge [arrowhead={} penwidth={}]; a -> b}}",
20 primitive_arrow_shape, edge_penwidth);
21
22 const auto engine = "dot";
23 auto svg_analyzer = SVGAnalyzer::make_from_dot(dot, engine);
24
25 for (const auto &graph : svg_analyzer.graphs()) {
26 for (const auto &edge : graph.edges()) {
27 CHECK(edge.penwidth() == edge_penwidth);
28 }
29 }
30 }