]> granicus.if.org Git - graphviz/commitdiff
test case for #1931
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 30 Jan 2021 02:16:35 +0000 (18:16 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 5 Feb 2021 04:17:57 +0000 (20:17 -0800)
rtest/test_regression.py

index 9b48a1b63060b1e94c3e476a41819405fba47ed4..2a9d5c79fcb7b267018f0c3bcf7f85948ef26fe7 100644 (file)
@@ -718,3 +718,33 @@ def test_1913():
       input = align.upper()
       _, stderr = run(graph.format(input))
       assert 'Warning: Illegal value {} for ALIGN - ignored'.format(input) in stderr
+
+@pytest.mark.xfail(strict=True)
+def test_1931():
+    '''
+    New lines within strings should not be discarded during parsing
+
+    '''
+
+    # a graph with \n inside of strings
+    graph = 'graph {\n'                 \
+            '  node1 [label="line 1\n'  \
+            'line 2\n'                  \
+            '"];\n'                     \
+            '  node2 [label="line 3\n'  \
+            'line 4"];\n'                \
+            '  node1 -- node2\n'        \
+            '  node2 -- "line 5\n'      \
+            'line 6"\n'                 \
+            '}'
+
+    # ask Graphviz to process this to dot output
+    p = subprocess.Popen(['dot', '-Txdot'], stdin=subprocess.PIPE,
+      stdout=subprocess.PIPE, universal_newlines=True)
+    xdot, _ = p.communicate(graph)
+    assert p.returncode == 0
+
+    # all new lines in strings should have been preserved
+    assert 'line 1\nline 2\n' in xdot
+    assert 'line 3\nline 4' in xdot
+    assert 'line 5\nline 6' in xdot