]> granicus.if.org Git - graphviz/commitdiff
fix ortho: add epsilon to floating point comparison
authorCosta Shulyupin <constantine.shulyupin@gmail.com>
Mon, 16 May 2022 07:05:55 +0000 (10:05 +0300)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 11 Jun 2022 18:29:46 +0000 (11:29 -0700)
Thanks to good bug description #1408, I've compared logs of
bad and good version. I found that sometimes there is
difference ~1E-15 between t->hi.y and t->lo.y because of
precision issues. It caused false positive conditional statement.

The workaround is to tolerate insignificant deviations.

fixes #1408, fixes #1990, fixes #1658

CHANGELOG.md
lib/ortho/partition.c
tests/test_regression.py

index 19fd5c7a51cfc2629b4813272371b93074cfde3c..a6015198067af83302475995113191a7c7fe453c 100644 (file)
@@ -13,6 +13,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 - graphviz-4.0.0: build error: cmd/tools/gvcolor.c:159: undefined reference to
   `fmax` #2246
 - Failed assertion in `chkSgraph` for twopi layout and ortho splines. #14
+- Failed assertion in `chkSgraph` for dot layout and ortho splines. #1408
+- Failed assertion in `chkSgraph` for circo layout and ortho splines. #1990
+- Segmentation Fault with splines="ortho". #1658
 
 ## [4.0.0] – 2022-05-29
 
index 6a4ce218fbfc66963c60886a5752aa59bfc84e08..6dcbada7a46a84cee0a2c9aa384fb1efda7f9b12 100644 (file)
@@ -329,8 +329,8 @@ traverse_polygon (int* visited, boxf* decomp, int size, segment_t* seg, trap_t*
 
   visited[trnum] = TRUE;
   
-  if (t->hi.y > t->lo.y && seg[t->lseg].v0.x == seg[t->lseg].v1.x &&
-      seg[t->rseg].v0.x == seg[t->rseg].v1.x) {
+  if (t->hi.y > t->lo.y + C_EPS && FP_EQUAL(seg[t->lseg].v0.x, seg[t->lseg].v1.x) &&
+      FP_EQUAL(seg[t->rseg].v0.x, seg[t->rseg].v1.x)) {
       if (flip) {
           decomp[size].LL.x = t->lo.y;
           decomp[size].LL.y = -seg[t->rseg].v0.x;
index 138066febaf002b752f81249ff73e5411f855568..7de0a646b1f26c9fb3bbc21828188a5b1a0cd932 100644 (file)
@@ -21,7 +21,7 @@ import xml.etree.ElementTree as ET
 import pytest
 
 sys.path.append(os.path.dirname(__file__))
-from gvtest import dot, gvpr, is_mingw, ROOT, remove_xtype_warnings, run_c \
+from gvtest import dot, gvpr, ROOT, remove_xtype_warnings, run_c \
   #pylint: disable=wrong-import-position
 
 def is_ndebug_defined() -> bool:
@@ -396,7 +396,6 @@ def test_1314():
   # the execution did not fail as expected
   pytest.fail("dot incorrectly exited with success")
 
-@pytest.mark.xfail(strict=not is_ndebug_defined() and not is_mingw()) # FIXME
 def test_1408():
   """
   parsing particular ortho layouts should not cause an assertion failure
@@ -521,7 +520,6 @@ def test_1594():
   assert "line 3:" in stderr, \
     "GVPR did not identify correct line of syntax error"
 
-@pytest.mark.xfail() # FIXME
 def test_1658():
   """
   the graph associated with this test case should not crash Graphviz
@@ -1124,7 +1122,9 @@ def test_1971():
 
     assert p.returncode != 0, "edgepaint incorrectly accepted '-rabbit'"
 
-@pytest.mark.xfail(strict=not is_ndebug_defined()) # FIXME
+@pytest.mark.xfail(platform.system() == "Windows",
+        reason="#56",
+        strict=not is_ndebug_defined()) # FIXME
 def test_1990():
   """
   using ortho and circo in combination should not cause an assertion failure