summaryrefslogtreecommitdiff
path: root/api_test/main.c
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-12-28 16:17:52 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2015-12-28 16:17:52 -0800
commit1d9b4cb920db48b426a4eb9482480db0f921ba43 (patch)
treea1b65bc0905e7b0e2b16c0ec11b900dd77a4870e /api_test/main.c
parent11a29f6219ab9c72c0863e47ba386d7b3e1162d5 (diff)
Added a minimal man renderer test to api tests.
Diffstat (limited to 'api_test/main.c')
-rw-r--r--api_test/main.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/api_test/main.c b/api_test/main.c
index c549ee8..abafd96 100644
--- a/api_test/main.c
+++ b/api_test/main.c
@@ -508,6 +508,49 @@ static void render_html(test_batch_runner *runner) {
cmark_node_free(doc);
}
+static void render_man(test_batch_runner *runner) {
+ char *man;
+
+ static const char markdown[] = "foo *bar*\n"
+ "\n"
+ "- Lorem ipsum dolor sit amet,\n"
+ " consectetur adipiscing elit,\n"
+ "- sed do eiusmod tempor incididunt\n"
+ " ut labore et dolore magna aliqua.\n";
+ cmark_node *doc =
+ cmark_parse_document(markdown, sizeof(markdown) - 1, CMARK_OPT_DEFAULT);
+
+ man = cmark_render_man(doc, CMARK_OPT_DEFAULT, 20);
+ STR_EQ(runner, man,
+ ".PP\n"
+ "foo \\f[I]bar\\f[]\n"
+ ".IP \\[bu] 2\n"
+ "Lorem ipsum dolor\n"
+ "sit amet,\n"
+ "consectetur\n"
+ "adipiscing elit,\n"
+ ".IP \\[bu] 2\n"
+ "sed do eiusmod\n"
+ "tempor incididunt ut\n"
+ "labore et dolore\n"
+ "magna aliqua.\n",
+ "render document with wrapping");
+ free(man);
+ man = cmark_render_man(doc, CMARK_OPT_DEFAULT, 0);
+ STR_EQ(runner, man,
+ ".PP\n"
+ "foo \\f[I]bar\\f[]\n"
+ ".IP \\[bu] 2\n"
+ "Lorem ipsum dolor sit amet,\n"
+ "consectetur adipiscing elit,\n"
+ ".IP \\[bu] 2\n"
+ "sed do eiusmod tempor incididunt\n"
+ "ut labore et dolore magna aliqua.\n",
+ "render document without wrapping");
+ free(man);
+ cmark_node_free(doc);
+}
+
static void utf8(test_batch_runner *runner) {
// Ranges
test_char(runner, 1, "\x01", "valid utf8 01");
@@ -690,6 +733,7 @@ int main() {
hierarchy(runner);
parser(runner);
render_html(runner);
+ render_man(runner);
utf8(runner);
line_endings(runner);
numeric_entities(runner);