From: Magnus Jacobsson Date: Tue, 13 Sep 2022 07:46:59 +0000 (+0200) Subject: tests: test_edge_node_overlap_utilities: make max node/edge overlap check optional X-Git-Tag: 6.0.2~34^2~15 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1350a232070a06fb65cca5459fb348b6616ad47b;p=graphviz tests: test_edge_node_overlap_utilities: make max node/edge overlap check optional This is currently a no-op since the max overlap check is always enabled in the currently existing test case, but an upcoming commit will introduce a test case checking minimum overlap only. An upcoming commit series will add separate fixes for different parts of the overlap problems. Having separate test cases for checking maximum or minimum overlap will make it easier to see that the fixes have the intended effect. --- diff --git a/tests/test_edge_node_overlap_simple.cpp b/tests/test_edge_node_overlap_simple.cpp index 21a88b299..e7893946d 100644 --- a/tests/test_edge_node_overlap_simple.cpp +++ b/tests/test_edge_node_overlap_simple.cpp @@ -17,5 +17,5 @@ TEST_CASE( const auto filename_base = AUTO_NAME(); - test_edge_node_overlap(graph_options, {.filename_base = filename_base}); + test_edge_node_overlap(graph_options, {}, {.filename_base = filename_base}); } diff --git a/tests/test_edge_node_overlap_utilities.cpp b/tests/test_edge_node_overlap_utilities.cpp index 58b2cb041..cb8b81035 100644 --- a/tests/test_edge_node_overlap_utilities.cpp +++ b/tests/test_edge_node_overlap_utilities.cpp @@ -59,9 +59,11 @@ static bool check_analyzed_svg(SVGAnalyzer &svg_analyzer, overlap_in_rank_direction(overlap_bbox, rankdir); // check maximum head node and edge overlap - DO_CHECK(head_node_edge_overlap <= - check_options.max_node_edge_overlap + - check_options.svg_rounding_error * 2); + if (check_options.check_max_edge_node_overlap) { + DO_CHECK(head_node_edge_overlap <= + check_options.max_node_edge_overlap + + check_options.svg_rounding_error * 2); + } } // check tail node and edge overlap @@ -75,9 +77,11 @@ static bool check_analyzed_svg(SVGAnalyzer &svg_analyzer, overlap_in_rank_direction(overlap_bbox, rankdir); // check maximum tail node and edge overlap - DO_CHECK(tail_node_edge_overlap <= - check_options.max_node_edge_overlap + - check_options.svg_rounding_error * 2); + if (check_options.check_max_edge_node_overlap) { + DO_CHECK(tail_node_edge_overlap <= + check_options.max_node_edge_overlap + + check_options.svg_rounding_error * 2); + } } return success; @@ -136,6 +140,7 @@ static std::string generate_dot(const graph_options &graph_options) { } void test_edge_node_overlap(const graph_options &graph_options, + const tc_check_options &tc_check_options, const write_options &write_options) { const auto dot = generate_dot(graph_options); @@ -154,6 +159,8 @@ void test_edge_node_overlap(const graph_options &graph_options, std::pow(10, -graphviz_num_decimals_in_svg) / 2; const check_options check_options = { + .check_max_edge_node_overlap = + tc_check_options.check_max_edge_node_overlap, .max_node_edge_overlap = graphviz_bezier_clip_margin, .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 8fa656de4..1b09708c4 100644 --- a/tests/test_edge_node_overlap_utilities.h +++ b/tests/test_edge_node_overlap_utilities.h @@ -2,7 +2,15 @@ #include "svg_analyzer.h" +/// check options that can be controlled from the test case +struct tc_check_options { + /// whether to check that there is not too much overlap + bool check_max_edge_node_overlap = true; +}; + struct check_options { + /// whether to check that there is not too much overlap + bool check_max_edge_node_overlap = true; /// maximum allowed overlap between edge and node double max_node_edge_overlap; /// rounding error caused by limited precision in SVG attribute values @@ -27,4 +35,5 @@ struct write_options { /// generate an SVG graph from the `dot` source and check that edges don't /// overlap nodes void test_edge_node_overlap(const graph_options &graph_options = {}, + const tc_check_options &tc_check_options = {}, const write_options &write_options = {});