From fd56f2878a6360fb019b743ceb7e11b11a6e2481 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Thu, 20 Nov 2014 15:22:10 +0100 Subject: Tests for node_previous, node_parent, node_unlink --- api_test/main.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/api_test/main.c b/api_test/main.c index 6747d61..1b5725d 100644 --- a/api_test/main.c +++ b/api_test/main.c @@ -269,6 +269,7 @@ create_tree(test_batch_runner *runner) cmark_node *p = cmark_node_new(CMARK_NODE_PARAGRAPH); OK(runner, cmark_node_append_child(doc, p), "append1"); INT_EQ(runner, cmark_node_check(doc), 0, "append1 consistent"); + OK(runner, cmark_node_parent(p) == doc, "node_parent"); cmark_node *emph = cmark_node_new(CMARK_NODE_EMPH); OK(runner, cmark_node_prepend_child(p, emph), "prepend1"); @@ -307,19 +308,25 @@ create_tree(test_batch_runner *runner) 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_next(str1) == 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"); + OK(runner, cmark_node_previous(emph) == str1, "ins after2 works"); + + cmark_node_unlink(emph); html = (char *)cmark_render_html(doc); - STR_EQ(runner, html, "

Hello, world!

\n", + STR_EQ(runner, html, "

Hello, !

\n", "render_html after shuffling"); free(html); cmark_node_destroy(doc); + + // TODO: Test that the contents of an unlinked inline are valid + // after the parent block was destroyed. This doesn't work so far. + cmark_node_destroy(emph); } void -- cgit v1.2.3