From: Magnus Jacobsson Date: Wed, 24 Aug 2022 14:32:25 +0000 (+0200) Subject: tests: test_edge_node_overlap_utilities: check edge/node min overlap X-Git-Tag: 6.0.2~34^2~14 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=222d4184dcd0f0068f30f3ae717af5a997833c6e;p=graphviz tests: test_edge_node_overlap_utilities: check edge/node min overlap --- diff --git a/tests/test_edge_node_overlap_simple.cpp b/tests/test_edge_node_overlap_simple.cpp index e7893946d..1989d98ed 100644 --- a/tests/test_edge_node_overlap_simple.cpp +++ b/tests/test_edge_node_overlap_simple.cpp @@ -5,9 +5,9 @@ #include "test_edge_node_overlap_utilities.h" #include "test_utilities.h" -TEST_CASE( - "Overlap", - "[!shouldfail] An edge connected to a node shall not overlap that node") { +TEST_CASE("Edge node overlap", + "[!shouldfail] An edge connected to a node shall touch that node and " + "not overlap it too much") { const graph_options graph_options = { .node_shape = "polygon", diff --git a/tests/test_edge_node_overlap_utilities.cpp b/tests/test_edge_node_overlap_utilities.cpp index cb8b81035..6e218d213 100644 --- a/tests/test_edge_node_overlap_utilities.cpp +++ b/tests/test_edge_node_overlap_utilities.cpp @@ -21,7 +21,7 @@ static double overlap_in_rank_direction(SVG::SVGRect intersection, UNREACHABLE(); } -/// check that edges do not overlap nodes +/// check overlap between the edge and the nodes static bool check_analyzed_svg(SVGAnalyzer &svg_analyzer, const graph_options &graph_options, const check_options &check_options) { @@ -64,6 +64,13 @@ static bool check_analyzed_svg(SVGAnalyzer &svg_analyzer, check_options.max_node_edge_overlap + check_options.svg_rounding_error * 2); } + + // check minimum head node and edge overlap + if (check_options.check_min_edge_node_overlap) { + DO_CHECK(head_node_edge_overlap >= + check_options.min_node_edge_overlap - + check_options.svg_rounding_error * 2); + } } // check tail node and edge overlap @@ -82,6 +89,13 @@ static bool check_analyzed_svg(SVGAnalyzer &svg_analyzer, check_options.max_node_edge_overlap + check_options.svg_rounding_error * 2); } + + // check minimum overlap at edge tail + if (check_options.check_min_edge_node_overlap) { + DO_CHECK(tail_node_edge_overlap >= + check_options.min_node_edge_overlap - + check_options.svg_rounding_error * 2); + } } return success; @@ -161,7 +175,10 @@ void test_edge_node_overlap(const graph_options &graph_options, const check_options check_options = { .check_max_edge_node_overlap = tc_check_options.check_max_edge_node_overlap, + .check_min_edge_node_overlap = + tc_check_options.check_min_edge_node_overlap, .max_node_edge_overlap = graphviz_bezier_clip_margin, + .min_node_edge_overlap = 0, .svg_rounding_error = graphviz_max_svg_rounding_error, }; diff --git a/tests/test_edge_node_overlap_utilities.h b/tests/test_edge_node_overlap_utilities.h index 1b09708c4..41f828726 100644 --- a/tests/test_edge_node_overlap_utilities.h +++ b/tests/test_edge_node_overlap_utilities.h @@ -6,13 +6,19 @@ struct tc_check_options { /// whether to check that there is not too much overlap bool check_max_edge_node_overlap = true; + /// whether to check that there is enough overlap + bool check_min_edge_node_overlap = true; }; struct check_options { /// whether to check that there is not too much overlap bool check_max_edge_node_overlap = true; + /// whether to check that there is enough overlap + bool check_min_edge_node_overlap = true; /// maximum allowed overlap between edge and node double max_node_edge_overlap; + /// minimum required overlap between edge and node + double min_node_edge_overlap; /// rounding error caused by limited precision in SVG attribute values double svg_rounding_error; };