| 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("SvgAnalyzer fillcolor", |
| 10 |
"Test that the SvgAnalyzer can recreate the original SVG with the " |
| 11 |
"correct `fill` and `fill-opacity` attributes when the Graphviz " |
| 12 |
"`fillcolor` attribute is used for nodes and edges ") { |
| 13 |
|
| 14 |
const auto shape = GENERATE(from_range(all_node_shapes)); |
| 15 |
INFO("Shape: " << shape); |
| 16 |
|
| 17 |
const std::string_view fillcolor = |
| 18 |
GENERATE("", "\"#10204000\"", "\"#10204080\"", "\"#102040ff\""); |
| 19 |
INFO("Fillcolor: " << fillcolor); |
| 20 |
const auto fillcolor_attr = |
| 21 |
fillcolor.empty() ? "" : std::format(" fillcolor={}", fillcolor); |
| 22 |
const std::string_view node_style = fillcolor.empty() ? "" : "filled"; |
| 23 |
const auto node_style_attr = |
| 24 |
node_style.empty() ? "" : std::format(" style={}", node_style); |
| 25 |
|
| 26 |
auto dot = |
| 27 |
std::format("digraph g1 {{node [shape={}{}{}]; edge [{}]; a -> b}}", |
| 28 |
shape, node_style_attr, fillcolor_attr, fillcolor_attr); |
| 29 |
|
| 30 |
SVGAnalyzer::make_from_dot(dot).re_create_and_verify_svg(); |
| 31 |
} |