diff options
author | Nick Wellnhofer <wellnhofer@aevum.de> | 2014-11-19 16:17:11 +0100 |
---|---|---|
committer | Nick Wellnhofer <wellnhofer@aevum.de> | 2014-11-19 16:17:11 +0100 |
commit | a595a84f691009808d58226ba0ada52e995ff224 (patch) | |
tree | 3e62f384efcd6c213a4bb8c345ffc376d2b33ae9 /api_test/main.c | |
parent | 282c12c6790e49a14b0dfaa733fd44c5de79e5dc (diff) |
Add tests for insert_{before|after} functions
Diffstat (limited to 'api_test/main.c')
-rw-r--r-- | api_test/main.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/api_test/main.c b/api_test/main.c index 1ff606b..1f4e298 100644 --- a/api_test/main.c +++ b/api_test/main.c @@ -10,6 +10,7 @@ static void create_tree(test_batch_runner *runner) { + char *html; cmark_node *doc = cmark_node_new(CMARK_NODE_DOCUMENT); cmark_node *p = cmark_node_new(CMARK_NODE_PARAGRAPH); @@ -35,11 +36,36 @@ create_tree(test_batch_runner *runner) OK(runner, cmark_node_append_child(emph, str2), "append3"); INT_EQ(runner, cmark_node_check(doc), 0, "append3 consistent"); - char *html = (char *)cmark_render_html(doc); + html = (char *)cmark_render_html(doc); STR_EQ(runner, html, "<p>Hello, <em>world</em>!</p>\n", "render_html"); free(html); + OK(runner, cmark_node_insert_before(str1, str3), "ins before1"); + INT_EQ(runner, cmark_node_check(doc), 0, "ins before1 consistent"); + // 31e + OK(runner, cmark_node_first_child(p) == str3, "ins before1 works"); + + OK(runner, cmark_node_insert_before(str1, emph), "ins before2"); + INT_EQ(runner, cmark_node_check(doc), 0, "ins before2 consistent"); + // 3e1 + OK(runner, cmark_node_last_child(p) == str1, "ins before2 works"); + + OK(runner, cmark_node_insert_after(str1, str3), "ins after1"); + INT_EQ(runner, cmark_node_check(doc), 0, "ins after1 consistent"); + // e13 + OK(runner, cmark_node_last_child(p) == str3, "ins after1 works"); + + OK(runner, cmark_node_insert_after(str1, emph), "ins after2"); + INT_EQ(runner, cmark_node_check(doc), 0, "ins after2 consistent"); + // 1e3 + OK(runner, cmark_node_first_child(p) == str1, "ins after2 works"); + + html = (char *)cmark_render_html(doc); + STR_EQ(runner, html, "<p>Hello, <em>world</em>!</p>\n", + "render_html after shuffling"); + free(html); + cmark_node_destroy(doc); } |