Test (#22732)
Not a critical piece of code, it's mostly used for reporting, but it doesn't hurt to improve the coverage of our unit tests.
diff --git a/tools/wpt/tests/test_markdown.py b/tools/wpt/tests/test_markdown.py
new file mode 100644
index 0000000..dec9ad9
--- /dev/null
+++ b/tools/wpt/tests/test_markdown.py
@@ -0,0 +1,35 @@
+from tools.wpt import markdown
+
+def test_format_comment_title():
+ assert '# Browser #' == markdown.format_comment_title("browser")
+ assert '# Browser (channel) #' == markdown.format_comment_title("browser:channel")
+
+def test_markdown_adjust():
+ assert u'\\t' == markdown.markdown_adjust('\t')
+ assert u'\\r' == markdown.markdown_adjust('\r')
+ assert u'\\n' == markdown.markdown_adjust('\n')
+ assert u'' == markdown.markdown_adjust('`')
+ assert u'\\|' == markdown.markdown_adjust('|')
+ assert u'\\t\\r\\n\\|' == markdown.markdown_adjust('\t\r\n`|')
+
+result = ''
+def log(text):
+ global result
+ result += text
+
+def test_table():
+ global result
+ headings = ['h1','h2']
+ data = [['0', '1']]
+ markdown.table(headings, data, log)
+ assert ("| h1 | h2 |"
+ "|----|----|"
+ "| 0 | 1 |") == result
+
+ result = ''
+ data.append(['aaa', 'bb'])
+ markdown.table(headings, data, log)
+ assert ("| h1 | h2 |"
+ "|-----|----|"
+ "| 0 | 1 |"
+ "| aaa | bb |") == result