]> granicus.if.org Git - graphviz/commitdiff
add a test case for #2211
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Mon, 14 Mar 2022 02:23:28 +0000 (19:23 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 19 Mar 2022 17:26:02 +0000 (10:26 -0700)
rtest/2211.gvpr [new file with mode: 0644]
rtest/test_regression.py

diff --git a/rtest/2211.gvpr b/rtest/2211.gvpr
new file mode 100644 (file)
index 0000000..4e2abf9
--- /dev/null
@@ -0,0 +1,14 @@
+BEGIN{
+
+  int i;
+  string s1, s2, s3;
+
+  s2="123456789012";
+
+  i=index(s2,"0");
+  print("index: ", i, "  should be 9");
+  i=index(s2,"4");
+  print("index: ", i, "  should be 3");
+  i=index(s2,"P");
+  print("index: ", i, "  should be -1");
+}
index 079fe260868e6e08bef578436eb9e0fb2cb73386..2bfca5190f6d6f418cd50db4c05ea810a98eec7b 100644 (file)
@@ -1562,6 +1562,26 @@ def test_2193():
   new = dot("canon", source=canonical)
   assert canonical == new, "canonical translation is not stable"
 
+@pytest.mark.skipif(shutil.which("gvpr") is None, reason="GVPR not available")
+@pytest.mark.xfail(strict=True)
+def test_2211():
+  """
+  GVPR’s `index` function should return correct results
+  https://gitlab.com/graphviz/graphviz/-/issues/2211
+  """
+
+  # find our collocated test case
+  program = Path(__file__).parent / "2211.gvpr"
+  assert program.exists(), "unexpectedly missing test case"
+
+  # run it through GVPR
+  output = gvpr(program)
+
+  # it should have found the right string indices for characters
+  assert output == "index: 9  should be 9\n" \
+                   "index: 3  should be 3\n" \
+                   "index: -1  should be -1\n"
+
 def test_package_version():
   """
   The graphviz_version.h header should define a non-empty PACKAGE_VERSION