summaryrefslogtreecommitdiff
path: root/api_test/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'api_test/main.c')
-rw-r--r--api_test/main.c39
1 files changed, 30 insertions, 9 deletions
diff --git a/api_test/main.c b/api_test/main.c
index 1b5725d..f484a53 100644
--- a/api_test/main.c
+++ b/api_test/main.c
@@ -261,6 +261,22 @@ accessors(test_batch_runner *runner)
}
static void
+node_check(test_batch_runner *runner) {
+ // Construct an incomplete tree.
+ cmark_node *doc = cmark_node_new(CMARK_NODE_DOCUMENT);
+ cmark_node *p1 = cmark_node_new(CMARK_NODE_PARAGRAPH);
+ cmark_node *p2 = cmark_node_new(CMARK_NODE_PARAGRAPH);
+ doc->first_child = p1;
+ p1->next = p2;
+
+ INT_EQ(runner, cmark_node_check(doc, NULL), 4, "node_check works");
+ INT_EQ(runner, cmark_node_check(doc, NULL), 0,
+ "node_check fixes tree");
+
+ cmark_node_destroy(doc);
+}
+
+static void
create_tree(test_batch_runner *runner)
{
char *html;
@@ -268,27 +284,27 @@ 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");
+ INT_EQ(runner, cmark_node_check(doc, NULL), 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");
- INT_EQ(runner, cmark_node_check(doc), 0, "prepend1 consistent");
+ INT_EQ(runner, cmark_node_check(doc, NULL), 0, "prepend1 consistent");
cmark_node *str1 = cmark_node_new(CMARK_NODE_STRING);
cmark_node_set_string_content(str1, "Hello, ");
OK(runner, cmark_node_prepend_child(p, str1), "prepend2");
- INT_EQ(runner, cmark_node_check(doc), 0, "prepend2 consistent");
+ INT_EQ(runner, cmark_node_check(doc, NULL), 0, "prepend2 consistent");
cmark_node *str3 = cmark_node_new(CMARK_NODE_STRING);
cmark_node_set_string_content(str3, "!");
OK(runner, cmark_node_append_child(p, str3), "append2");
- INT_EQ(runner, cmark_node_check(doc), 0, "append2 consistent");
+ INT_EQ(runner, cmark_node_check(doc, NULL), 0, "append2 consistent");
cmark_node *str2 = cmark_node_new(CMARK_NODE_STRING);
cmark_node_set_string_content(str2, "world");
OK(runner, cmark_node_append_child(emph, str2), "append3");
- INT_EQ(runner, cmark_node_check(doc), 0, "append3 consistent");
+ INT_EQ(runner, cmark_node_check(doc, NULL), 0, "append3 consistent");
html = (char *)cmark_render_html(doc);
STR_EQ(runner, html, "<p>Hello, <em>world</em>!</p>\n",
@@ -296,22 +312,26 @@ create_tree(test_batch_runner *runner)
free(html);
OK(runner, cmark_node_insert_before(str1, str3), "ins before1");
- INT_EQ(runner, cmark_node_check(doc), 0, "ins before1 consistent");
+ INT_EQ(runner, cmark_node_check(doc, NULL), 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");
+ INT_EQ(runner, cmark_node_check(doc, NULL), 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");
+ INT_EQ(runner, cmark_node_check(doc, NULL), 0,
+ "ins after1 consistent");
// e13
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");
+ INT_EQ(runner, cmark_node_check(doc, NULL), 0,
+ "ins after2 consistent");
// 1e3
OK(runner, cmark_node_previous(emph) == str1, "ins after2 works");
@@ -425,6 +445,7 @@ int main() {
constructor(runner);
accessors(runner);
+ node_check(runner);
create_tree(runner);
hierarchy(runner);