MCPcopy Create free account
hub / github.com/commonmark/cmark / iterator

Function iterator

api_test/main.c:293–310  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

291}
292
293static void iterator(test_batch_runner *runner) {
294 cmark_node *doc = cmark_parse_document("> a *b*\n\nc", 10, CMARK_OPT_DEFAULT);
295 int parnodes = 0;
296 cmark_event_type ev_type;
297 cmark_iter *iter = cmark_iter_new(doc);
298 cmark_node *cur;
299
300 while ((ev_type = cmark_iter_next(iter)) != CMARK_EVENT_DONE) {
301 cur = cmark_iter_get_node(iter);
302 if (cur->type == CMARK_NODE_PARAGRAPH && ev_type == CMARK_EVENT_ENTER) {
303 parnodes += 1;
304 }
305 }
306 INT_EQ(runner, parnodes, 2, "iterate correctly counts paragraphs");
307
308 cmark_iter_free(iter);
309 cmark_node_free(doc);
310}
311
312static void iterator_delete(test_batch_runner *runner) {
313 static const char md[] = "a *b* c\n"

Callers 1

mainFunction · 0.85

Calls 7

cmark_parse_documentFunction · 0.85
cmark_iter_newFunction · 0.85
cmark_iter_nextFunction · 0.85
cmark_iter_get_nodeFunction · 0.85
INT_EQFunction · 0.85
cmark_iter_freeFunction · 0.85
cmark_node_freeFunction · 0.85

Tested by

no test coverage detected