From: Matthew Fernandez Date: Mon, 14 Mar 2022 02:23:28 +0000 (-0700) Subject: add a test case for #2211 X-Git-Tag: 4.0.0~169^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=799442c8c4aa9cc6e1a0a87949de774706c43e71;p=graphviz add a test case for #2211 --- diff --git a/rtest/2211.gvpr b/rtest/2211.gvpr new file mode 100644 index 000000000..4e2abf9fe --- /dev/null +++ b/rtest/2211.gvpr @@ -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"); +} diff --git a/rtest/test_regression.py b/rtest/test_regression.py index 079fe2608..2bfca5190 100644 --- a/rtest/test_regression.py +++ b/rtest/test_regression.py @@ -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