| 1 |
#include <string> |
| 2 |
#include <string_view> |
| 3 |
#include <unordered_map> |
| 4 |
|
| 5 |
#include "svg_analyzer.h" |
| 6 |
|
| 7 |
/// check options that can be controlled from the test case |
| 8 |
struct tc_check_options { |
| 9 |
/// whether to check that there is not too much overlap |
| 10 |
bool check_max_edge_node_overlap = true; |
| 11 |
/// whether to check that there is enough overlap |
| 12 |
bool check_min_edge_node_overlap = true; |
| 13 |
/// whether to check that there is not too much overlap between edge stem and |
| 14 |
/// arrow |
| 15 |
bool check_max_edge_stem_arrow_overlap = true; |
| 16 |
/// whether to check that there is enough overlap between edge stem and arrow |
| 17 |
bool check_min_edge_stem_arrow_overlap = true; |
| 18 |
}; |
| 19 |
|
| 20 |
struct check_options { |
| 21 |
/// whether to check that there is not too much overlap |
| 22 |
bool check_max_edge_node_overlap = true; |
| 23 |
/// whether to check that there is enough overlap |
| 24 |
bool check_min_edge_node_overlap = true; |
| 25 |
/// whether to check that there is not too much overlap between edge stem and |
| 26 |
/// arrow |
| 27 |
bool check_max_edge_stem_arrow_overlap = true; |
| 28 |
/// whether to check that there is enough overlap between edge stem and arrow |
| 29 |
bool check_min_edge_stem_arrow_overlap = true; |
| 30 |
/// maximum allowed overlap between edge and node |
| 31 |
double max_node_edge_overlap; |
| 32 |
/// minimum required overlap between edge and node |
| 33 |
double min_node_edge_overlap; |
| 34 |
/// map between primitive arrow shape and maximum allowed overlap between edge |
| 35 |
/// stem and arrow |
| 36 |
std::unordered_map<std::string_view, double> max_edge_stem_arrow_overlap; |
| 37 |
/// minimum required overlap between edge stem and arrow |
| 38 |
double min_edge_stem_arrow_overlap; |
| 39 |
/// rounding error caused by limited precision in SVG attribute values |
| 40 |
double svg_rounding_error; |
| 41 |
}; |
| 42 |
|
| 43 |
struct graph_options { |
| 44 |
std::string_view rankdir = "TB"; |
| 45 |
std::string_view node_shape = "polygon"; |
| 46 |
double node_fontsize = 14; |
| 47 |
double node_penwidth = 1; |
| 48 |
std::string_view dir = "forward"; |
| 49 |
double edge_penwidth = 1; |
| 50 |
double edge_arrowsize = 1; |
| 51 |
std::string_view primitive_arrowhead_shape = "normal"; |
| 52 |
std::string_view primitive_arrowtail_shape = "normal"; |
| 53 |
std::string_view arrowhead_modifier = ""; |
| 54 |
std::string_view arrowtail_modifier = ""; |
| 55 |
}; |
| 56 |
|
| 57 |
struct write_options { |
| 58 |
std::string filename_base = "test_edge_node_overlap"; |
| 59 |
bool write_svg_on_success = false; |
| 60 |
bool write_original_svg = false; |
| 61 |
bool write_recreated_svg = false; |
| 62 |
bool write_annotated_svg = true; |
| 63 |
}; |
| 64 |
|
| 65 |
/// generate an SVG graph from the `dot` source and check that edges don't |
| 66 |
/// overlap nodes |
| 67 |
void test_edge_node_overlap(const graph_options &graph_options = {}, |
| 68 |
const tc_check_options &tc_check_options = {}, |
| 69 |
const write_options &write_options = {}); |