| 1 |
#include <format> |
| 2 |
#include <string_view> |
| 3 |
|
| 4 |
#include <catch2/catch_all.hpp> |
| 5 |
|
| 6 |
#include "svg_analyzer.h" |
| 7 |
#include "test_utilities.h" |
| 8 |
|
| 9 |
TEST_CASE("Node penwidth", |
| 10 |
"Test that the Graphviz 'penwidth' attribute is used to set the " |
| 11 |
"'stroke-width' attribute correctly for nodes in the generated SVG") { |
| 12 |
|
| 13 |
const auto shape = GENERATE(filter( |
| 14 |
[](std::string_view s) { |
| 15 |
return !node_shapes_without_svg_shape.contains(s); |
| 16 |
}, |
| 17 |
from_range(all_node_shapes))); |
| 18 |
INFO("Shape: " << shape); |
| 19 |
|
| 20 |
const auto node_penwidth = GENERATE(0.5, 1.0, 2.0); |
| 21 |
INFO("Node penwidth: " << node_penwidth); |
| 22 |
|
| 23 |
auto dot = std::format("digraph g1 {{node [shape={} penwidth={}]; a -> b}}", |
| 24 |
shape, node_penwidth); |
| 25 |
|
| 26 |
const auto engine = "dot"; |
| 27 |
auto svg_analyzer = SVGAnalyzer::make_from_dot(dot, engine); |
| 28 |
|
| 29 |
for (const auto &graph : svg_analyzer.graphs()) { |
| 30 |
for (const auto &node : graph.nodes()) { |
| 31 |
CHECK(node.penwidth() == node_penwidth); |
| 32 |
} |
| 33 |
} |
| 34 |
} |