Skip to content

Commit cfba1fc

Browse files
committed
expand tests
1 parent 462cab4 commit cfba1fc

File tree

1 file changed

+46
-22
lines changed

1 file changed

+46
-22
lines changed

api_test/main.c

Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -952,27 +952,51 @@ static void source_pos(test_batch_runner *runner) {
952952
cmark_node_free(doc);
953953
}
954954

955-
static void source_pos_2(test_batch_runner *runner) {
956-
static const char markdown[] =
957-
"*first*\n"
958-
"second\n";
959-
960-
cmark_node *doc = cmark_parse_document(markdown, sizeof(markdown) - 1, CMARK_OPT_DEFAULT);
961-
char *xml = cmark_render_xml(doc, CMARK_OPT_DEFAULT | CMARK_OPT_SOURCEPOS);
962-
STR_EQ(runner, xml, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
963-
"<!DOCTYPE document SYSTEM \"CommonMark.dtd\">\n"
964-
"<document sourcepos=\"1:1-2:6\" xmlns=\"http://commonmark.org/xml/1.0\">\n"
965-
" <paragraph sourcepos=\"1:1-2:6\">\n"
966-
" <emph sourcepos=\"1:1-1:7\">\n"
967-
" <text sourcepos=\"1:2-1:6\" xml:space=\"preserve\">first</text>\n"
968-
" </emph>\n"
969-
" <softbreak />\n"
970-
" <text sourcepos=\"2:1-2:6\" xml:space=\"preserve\">second</text>\n"
971-
" </paragraph>\n"
972-
"</document>\n",
973-
"sourcepos are as expected");
974-
free(xml);
975-
cmark_node_free(doc);
955+
static void source_pos_inlines(test_batch_runner *runner) {
956+
{
957+
static const char markdown[] =
958+
"*first*\n"
959+
"second\n";
960+
961+
cmark_node *doc = cmark_parse_document(markdown, sizeof(markdown) - 1, CMARK_OPT_DEFAULT);
962+
char *xml = cmark_render_xml(doc, CMARK_OPT_DEFAULT | CMARK_OPT_SOURCEPOS);
963+
STR_EQ(runner, xml, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
964+
"<!DOCTYPE document SYSTEM \"CommonMark.dtd\">\n"
965+
"<document sourcepos=\"1:1-2:6\" xmlns=\"http://commonmark.org/xml/1.0\">\n"
966+
" <paragraph sourcepos=\"1:1-2:6\">\n"
967+
" <emph sourcepos=\"1:1-1:7\">\n"
968+
" <text sourcepos=\"1:2-1:6\" xml:space=\"preserve\">first</text>\n"
969+
" </emph>\n"
970+
" <softbreak />\n"
971+
" <text sourcepos=\"2:1-2:6\" xml:space=\"preserve\">second</text>\n"
972+
" </paragraph>\n"
973+
"</document>\n",
974+
"sourcepos are as expected");
975+
free(xml);
976+
cmark_node_free(doc);
977+
}
978+
{
979+
static const char markdown[] =
980+
"*first\n"
981+
"second*\n";
982+
983+
cmark_node *doc = cmark_parse_document(markdown, sizeof(markdown) - 1, CMARK_OPT_DEFAULT);
984+
char *xml = cmark_render_xml(doc, CMARK_OPT_DEFAULT | CMARK_OPT_SOURCEPOS);
985+
STR_EQ(runner, xml, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
986+
"<!DOCTYPE document SYSTEM \"CommonMark.dtd\">\n"
987+
"<document sourcepos=\"1:1-2:7\" xmlns=\"http://commonmark.org/xml/1.0\">\n"
988+
" <paragraph sourcepos=\"1:1-2:7\">\n"
989+
" <emph sourcepos=\"1:1-2:7\">\n"
990+
" <text sourcepos=\"1:2-1:6\" xml:space=\"preserve\">first</text>\n"
991+
" <softbreak />\n"
992+
" <text sourcepos=\"2:1-2:6\" xml:space=\"preserve\">second</text>\n"
993+
" </emph>\n"
994+
" </paragraph>\n"
995+
"</document>\n",
996+
"sourcepos are as expected");
997+
free(xml);
998+
cmark_node_free(doc);
999+
}
9761000
}
9771001

9781002
static void ref_source_pos(test_batch_runner *runner) {
@@ -1025,7 +1049,7 @@ int main() {
10251049
test_safe(runner);
10261050
test_feed_across_line_ending(runner);
10271051
source_pos(runner);
1028-
source_pos_2(runner);
1052+
source_pos_inlines(runner);
10291053
ref_source_pos(runner);
10301054

10311055
test_print_summary(runner);

0 commit comments

Comments
 (0)