summaryrefslogtreecommitdiff
path: root/test/pathological_tests.py
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-12-27 13:37:50 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2014-12-27 13:37:50 -0700
commit35997dc0b6e7f3f076f5f8811787d3b64266b626 (patch)
treef690964815d3f8bc30252d120032d76e211649ed /test/pathological_tests.py
parentc2d98840b217800c5f2dabf279ea444e65df792f (diff)
Added pathological tests for nulls in input and nested blockquotes.
Diffstat (limited to 'test/pathological_tests.py')
-rw-r--r--test/pathological_tests.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/test/pathological_tests.py b/test/pathological_tests.py
index 49ed6db..8b25137 100644
--- a/test/pathological_tests.py
+++ b/test/pathological_tests.py
@@ -17,14 +17,20 @@ if __name__ == "__main__":
cmark = CMark(prog=args.program, library_dir=args.library_dir)
+# list of pairs consisting of input and a regex that must match the output.
pathological = {
"nested strong emph":
(("*a **a " * 100000) + "b" + (" a** a*" * 100000),
- "<p>" + ("<em>a <strong>a " * 100000) + "b" +
- (" a</strong> a</em>" * 100000) + "</p>"),
+ re.compile("(<em>a <strong>a ){100000}b( a</strong> a</em>){100000}")),
"nested brackets":
(("[" * 50000) + "a" + ("]" * 50000),
- "<p>" + ("[" * 50000) + "a" + ("]" * 50000) + "</p>")
+ re.compile("\[{50000}a\]{50000}")),
+ "nested block quotes":
+ ((("> " * 50000) + "a"),
+ re.compile("(<blockquote>\n){50000}")),
+ "U+0000 in input":
+ ("abc\0de\0",
+ re.compile("abc(�)?de(�)?"))
}
whitespace_re = re.compile('/s+/')
@@ -35,14 +41,14 @@ failed = 0
print "Testing pathological cases:"
for description in pathological:
print description
- (inp, expected) = pathological[description]
+ (inp, regex) = pathological[description]
[rc, actual, err] = cmark.to_html(inp)
if rc != 0:
errored += 1
print description
print "program returned error code %d" % rc
print(err)
- elif whitespace_re.sub(' ', actual.rstrip()) == expected.rstrip():
+ elif regex.search(actual):
passed += 1
else:
print description, 'failed'