From 35997dc0b6e7f3f076f5f8811787d3b64266b626 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 27 Dec 2014 13:37:50 -0700 Subject: Added pathological tests for nulls in input and nested blockquotes. --- test/pathological_tests.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'test') 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), - "

" + ("a a " * 100000) + "b" + - (" a a" * 100000) + "

"), + re.compile("(a a ){100000}b( a a){100000}")), "nested brackets": (("[" * 50000) + "a" + ("]" * 50000), - "

" + ("[" * 50000) + "a" + ("]" * 50000) + "

") + re.compile("\[{50000}a\]{50000}")), + "nested block quotes": + ((("> " * 50000) + "a"), + re.compile("(
\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' -- cgit v1.2.3