]> granicus.if.org Git - graphviz/commitdiff
tests: test_edge_node_overlap_utilities: make max node/edge overlap check optional
authorMagnus Jacobsson <Magnus.Jacobsson@berotec.se>
Tue, 13 Sep 2022 07:46:59 +0000 (09:46 +0200)
committerMagnus Jacobsson <Magnus.Jacobsson@berotec.se>
Tue, 20 Sep 2022 15:53:06 +0000 (17:53 +0200)
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.

tests/test_edge_node_overlap_simple.cpp
tests/test_edge_node_overlap_utilities.cpp
tests/test_edge_node_overlap_utilities.h

index 21a88b29986a0838a1fea8988910501f4a59a299..e7893946de5513c71c6a7aba8c88b91090152558 100644 (file)
@@ -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});
 }
index 58b2cb04156a716905ac57869cb294cf3d98003f..cb8b81035cf6648ffbd7d7d1af53c3b8b7afd870 100644 (file)
@@ -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,
   };
index 8fa656de48c18e8f301cc51cdf7761d6dda28274..1b09708c4032ba3a8fd298e1bb1a943af06705b7 100644 (file)
@@ -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 = {});