/* * blogc: A blog compiler. * Copyright (C) 2015 Rafael G. Martins * * This program can be distributed under the terms of the BSD License. * See the file LICENSE. */ #ifdef HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include #include #include #include #include #include "../src/content-parser.h" #include "../src/utils/utils.h" static void test_slugify(void **state) { char *s = blogc_slugify("bola"); assert_string_equal(s, "bola"); free(s); s = blogc_slugify("bola o"); assert_string_equal(s, "bola-o"); free(s); s = blogc_slugify("Bola O"); assert_string_equal(s, "bola-o"); free(s); s = blogc_slugify("bola 0"); assert_string_equal(s, "bola-0"); free(s); s = blogc_slugify("bola () o"); assert_string_equal(s, "bola-----o"); free(s); s = blogc_slugify("Bola O"); assert_string_equal(s, "bola-o"); free(s); s = blogc_slugify("bolaço"); assert_string_equal(s, "bola--o"); free(s); } static void test_is_ordered_list_item(void **state) { assert_true(blogc_is_ordered_list_item("1.bola", 2)); assert_true(blogc_is_ordered_list_item("1. bola", 3)); assert_true(blogc_is_ordered_list_item("12. bola", 4)); assert_true(blogc_is_ordered_list_item("123. bola", 5)); assert_true(blogc_is_ordered_list_item("1. bola", 6)); assert_true(blogc_is_ordered_list_item("1. bola", 5)); assert_false(blogc_is_ordered_list_item("1bola", 1)); assert_false(blogc_is_ordered_list_item("12bola", 2)); assert_false(blogc_is_ordered_list_item("1 . bola", 6)); assert_false(blogc_is_ordered_list_item("1. bola", 6)); assert_false(blogc_is_ordered_list_item("1.", 2)); assert_false(blogc_is_ordered_list_item(NULL, 2)); } static void test_content_parse(void **state) { size_t l = 0; char *html = blogc_content_parse( "# um\n" "## dois\n" "### tres\n" "#### quatro\n" "##### cinco\n" "###### seis\n" "\n" "bola\n" "chunda\n" "\n" "> bola \n" "> guda\n" "> buga\n" "> \n" "> asd\n" "\n" " bola\n" " asd\n" " qwewer\n" "\n" "+++\n" "1. chunda\n" "3. fuuuu\n" "\n" "+ chunda2\n" "+ fuuuu2\n" "\n" "\n" "\n" "guda\n" "yay\n" "\n" "**bola**\n", &l); assert_non_null(html); assert_int_equal(l, 0); assert_string_equal(html, "

um

\n" "

dois

\n" "

tres

\n" "

quatro

\n" "
cinco
\n" "
seis
\n" "

bola\n" "chunda

\n" "

bola
\n" "guda\n" "buga

\n" "
asd
\n" "
\n" "
bola\n"
        " asd\n"
        "qwewer
\n" "
\n" "
    \n" "
  1. chunda
  2. \n" "
  3. fuuuu
  4. \n" "
\n" "
    \n" "
  • chunda2
  • \n" "
  • fuuuu2
  • \n" "
\n" "\n" "

guda\n" "yay

\n" "

bola

\n"); free(html); } static void test_content_parse_with_excerpt(void **state) { size_t l = 0; char *html = blogc_content_parse( "# test\n" "\n" "chunda\n" "\n" "..\n" "\n" "guda\n" "lol", &l); assert_non_null(html); assert_int_equal(l, 38); assert_string_equal(html, "

test

\n" "

chunda

\n" "

guda\n" "lol

\n"); free(html); l = 0; html = blogc_content_parse( "# test\n" "\n" "chunda\n" "\n" "...\n" "\n" "guda\n" "lol", &l); assert_non_null(html); assert_int_equal(l, 38); assert_string_equal(html, "

test

\n" "

chunda

\n" "

guda\n" "lol

\n"); free(html); } static void test_content_parse_header(void **state) { char *html = blogc_content_parse("## bola", NULL); assert_non_null(html); assert_string_equal(html, "

bola

\n"); free(html); html = blogc_content_parse("## bola\n", NULL); assert_non_null(html); assert_string_equal(html, "

bola

\n"); free(html); html = blogc_content_parse( "bola\n" "\n" "## bola\n" "\n" "guda\n", NULL); assert_non_null(html); assert_string_equal(html, "

bola

\n" "

bola

\n" "

guda

\n"); free(html); } static void test_content_parse_html(void **state) { char *html = blogc_content_parse("
\n
", NULL); assert_non_null(html); assert_string_equal(html, "
\n
\n"); free(html); html = blogc_content_parse("
\n
\n", NULL); assert_non_null(html); assert_string_equal(html, "
\n
\n"); free(html); html = blogc_content_parse( "bola\n" "\n" "
\n" "
\n" "\n" "chunda\n", NULL); assert_non_null(html); assert_string_equal(html, "

bola

\n" "
\n
\n" "

chunda

\n"); free(html); } static void test_content_parse_blockquote(void **state) { char *html = blogc_content_parse("> bola\n> guda", NULL); assert_non_null(html); assert_string_equal(html, "

bola\n" "guda

\n" "
\n"); free(html); html = blogc_content_parse("> bola\n> guda\n", NULL); assert_non_null(html); assert_string_equal(html, "

bola\n" "guda

\n" "
\n"); free(html); html = blogc_content_parse( "bola\n" "\n" "> bola\n" "> guda\n" "\n" "chunda\n", NULL); assert_non_null(html); assert_string_equal(html, "

bola

\n" "

bola\n" "guda

\n" "
\n" "

chunda

\n"); free(html); } static void test_content_parse_code(void **state) { char *html = blogc_content_parse(" bola\n guda", NULL); assert_non_null(html); assert_string_equal(html, "
bola\n"
        "guda
\n"); free(html); html = blogc_content_parse(" bola\n guda\n", NULL); assert_non_null(html); assert_string_equal(html, "
bola\n"
        "guda
\n"); free(html); html = blogc_content_parse( "bola\n" "\n" " bola\n" " guda\n" "\n" "chunda\n", NULL); assert_non_null(html); assert_string_equal(html, "

bola

\n" "
bola\n"
        "guda
\n" "

chunda

\n"); free(html); } static void test_content_parse_horizontal_rule(void **state) { char *html = blogc_content_parse("bola\nguda\n\n**", NULL); assert_non_null(html); assert_string_equal(html, "

bola\n" "guda

\n" "
\n"); free(html); html = blogc_content_parse("bola\nguda\n\n++++", NULL); assert_non_null(html); assert_string_equal(html, "

bola\n" "guda

\n" "
\n"); free(html); html = blogc_content_parse("bola\nguda\n\n--\n", NULL); assert_non_null(html); assert_string_equal(html, "

bola\n" "guda

\n" "
\n"); free(html); html = blogc_content_parse("bola\nguda\n\n****\n", NULL); assert_non_null(html); assert_string_equal(html, "

bola\n" "guda

\n" "
\n"); free(html); html = blogc_content_parse( "bola\n" "\n" "**\n" "\n" "chunda\n", NULL); assert_non_null(html); assert_string_equal(html, "

bola

\n" "
\n" "

chunda

\n"); free(html); html = blogc_content_parse( "bola\n" "\n" "----\n" "\n" "chunda\n", NULL); assert_non_null(html); assert_string_equal(html, "

bola

\n" "
\n" "

chunda

\n"); free(html); } static void test_content_parse_unordered_list(void **state) { char *html = blogc_content_parse( "lol\n" "\n" "* asd\n" "* qwe\n" "* zxc", NULL); assert_non_null(html); assert_string_equal(html, "

lol

\n" "
    \n" "
  • asd
  • \n" "
  • qwe
  • \n" "
  • zxc
  • \n" "
\n"); free(html); html = blogc_content_parse( "lol\n" "\n" "* asd\n" "* qwe\n" "* zxc\n", NULL); assert_non_null(html); assert_string_equal(html, "

lol

\n" "
    \n" "
  • asd
  • \n" "
  • qwe
  • \n" "
  • zxc
  • \n" "
\n"); free(html); html = blogc_content_parse( "lol\n" "\n" "* asd\n" "* qwe\n" "* zxc\n" "\n" "fuuuu\n", NULL); assert_non_null(html); assert_string_equal(html, "

lol

\n" "
    \n" "
  • asd
  • \n" "
  • qwe
  • \n" "
  • zxc
  • \n" "
\n" "

fuuuu

\n"); free(html); html = blogc_content_parse( "lol\n" "\n" "* asd\n" " cvb\n" "* qwe\n" "* zxc\n" " 1234\n" "\n" "fuuuu\n", NULL); assert_non_null(html); assert_string_equal(html, "

lol

\n" "
    \n" "
  • asd\n" "cvb
  • \n" "
  • qwe
  • \n" "
  • zxc\n" "1234
  • \n" "
\n" "

fuuuu

\n"); free(html); html = blogc_content_parse( "* asd\n" "* qwe\n" "* zxc", NULL); assert_non_null(html); assert_string_equal(html, "
    \n" "
  • asd
  • \n" "
  • qwe
  • \n" "
  • zxc
  • \n" "
\n"); free(html); } static void test_content_parse_ordered_list(void **state) { char *html = blogc_content_parse( "lol\n" "\n" "1. asd\n" "2. qwe\n" "3. zxc", NULL); assert_non_null(html); assert_string_equal(html, "

lol

\n" "
    \n" "
  1. asd
  2. \n" "
  3. qwe
  4. \n" "
  5. zxc
  6. \n" "
\n"); free(html); html = blogc_content_parse( "lol\n" "\n" "1. asd\n" "2. qwe\n" "3. zxc\n", NULL); assert_non_null(html); assert_string_equal(html, "

lol

\n" "
    \n" "
  1. asd
  2. \n" "
  3. qwe
  4. \n" "
  5. zxc
  6. \n" "
\n"); free(html); html = blogc_content_parse( "lol\n" "\n" "1. asd\n" "2. qwe\n" "3. zxc\n" "\n" "fuuuu\n", NULL); assert_non_null(html); assert_string_equal(html, "

lol

\n" "
    \n" "
  1. asd
  2. \n" "
  3. qwe
  4. \n" "
  5. zxc
  6. \n" "
\n" "

fuuuu

\n"); free(html); html = blogc_content_parse( "lol\n" "\n" "1. asd\n" " cvb\n" "2. qwe\n" "3. zxc\n" " 1234\n" "\n" "fuuuu\n", NULL); assert_non_null(html); assert_string_equal(html, "

lol

\n" "
    \n" "
  1. asd\n" "cvb
  2. \n" "
  3. qwe
  4. \n" "
  5. zxc\n" "1234
  6. \n" "
\n" "

fuuuu

\n"); free(html); html = blogc_content_parse( "1. asd\n" "2. qwe\n" "3. zxc", NULL); assert_non_null(html); assert_string_equal(html, "
    \n" "
  1. asd
  2. \n" "
  3. qwe
  4. \n" "
  5. zxc
  6. \n" "
\n"); free(html); } static void test_content_parse_invalid_excerpt(void **state) { size_t l = 0; char *html = blogc_content_parse( "# test\n" "\n" "chunda\n" "..\n" "\n" "guda\n" "lol", &l); assert_non_null(html); assert_int_equal(l, 0); assert_string_equal(html, "

test

\n" "

chunda\n" "..

\n" "

guda\n" "lol

\n"); free(html); l = 0; html = blogc_content_parse( "# test\n" "\n" "chunda\n" "\n" "...\n" "guda\n" "lol", &l); assert_non_null(html); assert_int_equal(l, 0); assert_string_equal(html, "

test

\n" "

chunda

\n" "

...\n" "guda\n" "lol

\n"); free(html); l = 0; html = blogc_content_parse( "# test\n" "\n" "chunda..\n" "\n" "guda\n" "lol", &l); assert_non_null(html); assert_int_equal(l, 0); assert_string_equal(html, "

test

\n" "

chunda..

\n" "

guda\n" "lol

\n"); free(html); l = 0; html = blogc_content_parse( "# test\n" "\n" "chunda\n" "\n" "...guda\n" "lol", &l); assert_non_null(html); assert_int_equal(l, 0); assert_string_equal(html, "

test

\n" "

chunda

\n" "

...guda\n" "lol

\n"); free(html); } static void test_content_parse_invalid_header(void **state) { char *html = blogc_content_parse( "asd\n" "\n" "##bola\n", NULL); assert_non_null(html); assert_string_equal(html, "

asd

\n" "

##bola

\n"); free(html); } static void test_content_parse_invalid_header_empty(void **state) { char *html = blogc_content_parse( "asd\n" "\n" "##\n" "\n" "qwe\n", NULL); assert_non_null(html); assert_string_equal(html, "

asd

\n" "

##\n" "\n" "qwe

\n"); free(html); } static void test_content_parse_invalid_blockquote(void **state) { char *html = blogc_content_parse( "> asd\n" "> bola\n" "> foo\n", NULL); assert_non_null(html); assert_string_equal(html, "

> asd\n" "> bola\n" "> foo

\n"); free(html); } static void test_content_parse_invalid_code(void **state) { char *html = blogc_content_parse( " asd\n" " bola\n" " foo\n", NULL); assert_non_null(html); assert_string_equal(html, "

asd\n" " bola\n" " foo

\n"); free(html); } static void test_content_parse_invalid_horizontal_rule(void **state) { // this generates invalid html, but... char *html = blogc_content_parse("** asd", NULL); assert_non_null(html); assert_string_equal(html, "

asd

\n"); free(html); html = blogc_content_parse("** asd\n", NULL); assert_non_null(html); assert_string_equal(html, "

asd

\n"); free(html); } static void test_content_parse_invalid_unordered_list(void **state) { // more invalid html char *html = blogc_content_parse( "* asd\n" "1. qwe", NULL); assert_non_null(html); assert_string_equal(html, "

asd\n" "1. qwe

\n"); free(html); html = blogc_content_parse( "* asd\n" "1. qwe\n" "\n", NULL); assert_non_null(html); assert_string_equal(html, "

asd\n" "1. qwe

\n"); free(html); html = blogc_content_parse( "* asd\n" "1. qwe\n", NULL); assert_non_null(html); assert_string_equal(html, "

asd\n" "1. qwe

\n"); free(html); html = blogc_content_parse( "* asd\n" "1. qwe\n", NULL); assert_non_null(html); assert_string_equal(html, "

asd\n" "1. qwe

\n"); free(html); html = blogc_content_parse( "chunda\n" "\n" "* asd\n" "1. qwe\n" "\n" "poi\n", NULL); assert_non_null(html); assert_string_equal(html, "

chunda

\n" "

asd\n" "1. qwe

\n" "

poi

\n"); free(html); } static void test_content_parse_invalid_ordered_list(void **state) { // more invalid html char *html = blogc_content_parse( "1. asd\n" "* qwe", NULL); assert_non_null(html); assert_string_equal(html, "

1. asd\n" " qwe

\n"); free(html); html = blogc_content_parse( "1. asd\n" "* qwe\n" "\n", NULL); assert_non_null(html); assert_string_equal(html, "

1. asd\n" " qwe

\n"); free(html); html = blogc_content_parse( "1. asd\n" "* qwe\n", NULL); assert_non_null(html); assert_string_equal(html, "

1. asd\n" " qwe

\n"); free(html); html = blogc_content_parse( "1. asd\n" "* qwe\n", NULL); assert_non_null(html); assert_string_equal(html, "

1. asd\n" " qwe

\n"); free(html); html = blogc_content_parse( "chunda\n" "\n" "1. asd\n" "* qwe\n" "\n" "poi\n", NULL); assert_non_null(html); assert_string_equal(html, "

chunda

\n" "

1. asd\n" " qwe

\n" "

poi

\n"); free(html); html = blogc_content_parse( "1 asd\n" "* qwe\n", NULL); assert_non_null(html); assert_string_equal(html, "

1 asd\n" " qwe

\n"); free(html); html = blogc_content_parse( "a. asd\n" "2. qwe\n", NULL); assert_non_null(html); assert_string_equal(html, "

a. asd\n" "2. qwe

\n"); free(html); html = blogc_content_parse( "1.\nasd\n" "2. qwe\n", NULL); assert_non_null(html); assert_string_equal(html, "

1.\n" "asd\n" "2. qwe

\n"); free(html); html = blogc_content_parse("1.\n", NULL); assert_non_null(html); assert_string_equal(html, "

1.

\n"); free(html); } static void test_content_parse_inline(void **state) { char *html = blogc_content_parse_inline( "**bola***asd* [![lol](http://google.com/lol.png) **lol** " "\\[asd\\]\\(qwe\\)](http://google.com) ``chunda`` [[bola]] chunda[9]"); assert_non_null(html); assert_string_equal(html, "bolaasd " " lol [asd](qwe) " "chunda bola chunda[9]"); free(html); html = blogc_content_parse_inline("*bola*"); assert_non_null(html); assert_string_equal(html, "bola"); free(html); } static void test_content_parse_inline_em(void **state) { char *html = blogc_content_parse_inline("*bola*"); assert_non_null(html); assert_string_equal(html, "bola"); free(html); html = blogc_content_parse_inline("*bola*\n"); assert_non_null(html); assert_string_equal(html, "bola\n"); free(html); html = blogc_content_parse_inline("_bola_"); assert_non_null(html); assert_string_equal(html, "bola"); free(html); html = blogc_content_parse_inline("_bola_\n"); assert_non_null(html); assert_string_equal(html, "bola\n"); free(html); html = blogc_content_parse_inline("_**bola**_\n"); assert_non_null(html); assert_string_equal(html, "bola\n"); free(html); // this is not really valid html = blogc_content_parse_inline("_**bola\n"); assert_non_null(html); assert_string_equal(html, "bola\n"); free(html); } static void test_content_parse_inline_strong(void **state) { char *html = blogc_content_parse_inline("**bola**"); assert_non_null(html); assert_string_equal(html, "bola"); free(html); html = blogc_content_parse_inline("**bola**\n"); assert_non_null(html); assert_string_equal(html, "bola\n"); free(html); html = blogc_content_parse_inline("__bola__"); assert_non_null(html); assert_string_equal(html, "bola"); free(html); html = blogc_content_parse_inline("__bola__\n"); assert_non_null(html); assert_string_equal(html, "bola\n"); free(html); html = blogc_content_parse_inline("__*bola*__\n"); assert_non_null(html); assert_string_equal(html, "bola\n"); free(html); // this is not really valid html = blogc_content_parse_inline("__*bola\n"); assert_non_null(html); assert_string_equal(html, "bola\n"); free(html); } static void test_content_parse_inline_code(void **state) { char *html = blogc_content_parse_inline("``bola``"); assert_non_null(html); assert_string_equal(html, "bola"); free(html); html = blogc_content_parse_inline("``bola``\n"); assert_non_null(html); assert_string_equal(html, "bola\n"); free(html); html = blogc_content_parse_inline("`bola`"); assert_non_null(html); assert_string_equal(html, "bola"); free(html); html = blogc_content_parse_inline("`bola`\n"); assert_non_null(html); assert_string_equal(html, "bola\n"); free(html); html = blogc_content_parse_inline("``bo*la``\n"); assert_non_null(html); assert_string_equal(html, "bo*la\n"); free(html); // invalid html = blogc_content_parse_inline("``bola\n"); assert_non_null(html); assert_string_equal(html, "bola\n"); free(html); html = blogc_content_parse_inline("`bola\n"); assert_non_null(html); assert_string_equal(html, "bola\n"); free(html); html = blogc_content_parse_inline("``bola`\n"); assert_non_null(html); assert_string_equal(html, "bola\n"); free(html); } static void test_content_parse_inline_link(void **state) { char *html = blogc_content_parse_inline("[bola](http://example.org/)"); assert_non_null(html); assert_string_equal(html, "bola"); free(html); html = blogc_content_parse_inline("[bola](http://example.org/)\n"); assert_non_null(html); assert_string_equal(html, "bola\n"); free(html); html = blogc_content_parse_inline("[bola]\n(http://example.org/)\n"); assert_non_null(html); assert_string_equal(html, "bola\n"); free(html); html = blogc_content_parse_inline("[bo\nla](http://example.org/)\n"); assert_non_null(html); assert_string_equal(html, "bo\nla\n"); free(html); html = blogc_content_parse_inline("[``bola``](http://example.org/)\n"); assert_non_null(html); assert_string_equal(html, "bola\n"); free(html); html = blogc_content_parse_inline("[``bola(2)[3]**!\\``](http://example.org/)\n"); assert_non_null(html); assert_string_equal(html, "bola(2)[3]**!\\\n"); free(html); // "invalid" html = blogc_content_parse_inline("[bola](\nhttp://example.org/)\n"); assert_non_null(html); assert_string_equal(html, "bola\n"); free(html); html = blogc_content_parse_inline("[bola](http://example.org/\n"); assert_non_null(html); assert_string_equal(html, "[bola](http://example.org/\n"); free(html); html = blogc_content_parse_inline("["); assert_non_null(html); assert_string_equal(html, "["); free(html); html = blogc_content_parse_inline("[\n"); assert_non_null(html); assert_string_equal(html, "[\n"); free(html); html = blogc_content_parse_inline("[a"); assert_non_null(html); assert_string_equal(html, "[a"); free(html); html = blogc_content_parse_inline("[a\n"); assert_non_null(html); assert_string_equal(html, "[a\n"); free(html); html = blogc_content_parse_inline("[a]"); assert_non_null(html); assert_string_equal(html, "[a]"); free(html); html = blogc_content_parse_inline("[a]\n"); assert_non_null(html); assert_string_equal(html, "[a]\n"); free(html); } static void test_content_parse_inline_link_auto(void **state) { char *html = blogc_content_parse_inline("[[guda]]"); assert_non_null(html); assert_string_equal(html, "guda"); free(html); html = blogc_content_parse_inline("[[guda]]\n"); assert_non_null(html); assert_string_equal(html, "guda\n"); free(html); html = blogc_content_parse_inline("[[guda]asd]"); assert_non_null(html); assert_string_equal(html, "guda"); free(html); html = blogc_content_parse_inline("[[guda]asd]\n"); assert_non_null(html); assert_string_equal(html, "guda\n"); free(html); html = blogc_content_parse_inline("[[guda]asd"); assert_non_null(html); assert_string_equal(html, "[[guda]asd"); free(html); html = blogc_content_parse_inline("[[guda]asd\n"); assert_non_null(html); assert_string_equal(html, "[[guda]asd\n"); free(html); } static void test_content_parse_inline_image(void **state) { char *html = blogc_content_parse_inline("![bola](http://example.org/)"); assert_non_null(html); assert_string_equal(html, "\"bola\""); free(html); html = blogc_content_parse_inline("![bola](http://example.org/)\n"); assert_non_null(html); assert_string_equal(html, "\"bola\"\n"); free(html); html = blogc_content_parse_inline("![bola]\n(http://example.org/)\n"); assert_non_null(html); assert_string_equal(html, "\"bola\"\n"); free(html); // "invalid" html = blogc_content_parse_inline("![bo\nla](http://example.org/)\n"); assert_non_null(html); assert_string_equal(html, "\"bo\nla\"\n"); free(html); html = blogc_content_parse_inline("![bola](\nhttp://example.org/)\n"); assert_non_null(html); assert_string_equal(html, "\"bola\"\n"); free(html); html = blogc_content_parse_inline("![bola](http://example.org/\n"); assert_non_null(html); assert_string_equal(html, "![bola](http://example.org/\n"); free(html); html = blogc_content_parse_inline("!"); assert_non_null(html); assert_string_equal(html, "!"); free(html); html = blogc_content_parse_inline("!["); assert_non_null(html); assert_string_equal(html, "!["); free(html); html = blogc_content_parse_inline("!\n"); assert_non_null(html); assert_string_equal(html, "!\n"); free(html); html = blogc_content_parse_inline("![\n"); assert_non_null(html); assert_string_equal(html, "![\n"); free(html); html = blogc_content_parse_inline("![a"); assert_non_null(html); assert_string_equal(html, "![a"); free(html); html = blogc_content_parse_inline("!a\n"); assert_non_null(html); assert_string_equal(html, "!a\n"); free(html); html = blogc_content_parse_inline("![a\n"); assert_non_null(html); assert_string_equal(html, "![a\n"); free(html); html = blogc_content_parse_inline("![a]"); assert_non_null(html); assert_string_equal(html, "![a]"); free(html); html = blogc_content_parse_inline("!a]\n"); assert_non_null(html); assert_string_equal(html, "!a]\n"); free(html); html = blogc_content_parse_inline("![a]\n"); assert_non_null(html); assert_string_equal(html, "![a]\n"); free(html); } static void test_content_parse_inline_line_break(void **state) { char *html = blogc_content_parse_inline("asd \n"); assert_non_null(html); assert_string_equal(html, "asd
\n"); free(html); html = blogc_content_parse_inline("asd "); assert_non_null(html); assert_string_equal(html, "asd
\n"); free(html); html = blogc_content_parse_inline("asd "); assert_non_null(html); assert_string_equal(html, "asd
\n"); free(html); // invalid html = blogc_content_parse_inline("asd "); assert_non_null(html); assert_string_equal(html, "asd "); free(html); html = blogc_content_parse_inline("asd \n"); assert_non_null(html); assert_string_equal(html, "asd \n"); free(html); } int main(void) { const UnitTest tests[] = { unit_test(test_slugify), unit_test(test_is_ordered_list_item), unit_test(test_content_parse), unit_test(test_content_parse_with_excerpt), unit_test(test_content_parse_header), unit_test(test_content_parse_html), unit_test(test_content_parse_blockquote), unit_test(test_content_parse_code), unit_test(test_content_parse_horizontal_rule), unit_test(test_content_parse_unordered_list), unit_test(test_content_parse_ordered_list), unit_test(test_content_parse_invalid_excerpt), unit_test(test_content_parse_invalid_header), unit_test(test_content_parse_invalid_header_empty), unit_test(test_content_parse_invalid_blockquote), unit_test(test_content_parse_invalid_code), unit_test(test_content_parse_invalid_horizontal_rule), unit_test(test_content_parse_invalid_unordered_list), unit_test(test_content_parse_invalid_ordered_list), unit_test(test_content_parse_inline), unit_test(test_content_parse_inline_em), unit_test(test_content_parse_inline_strong), unit_test(test_content_parse_inline_code), unit_test(test_content_parse_inline_link), unit_test(test_content_parse_inline_link_auto), unit_test(test_content_parse_inline_image), unit_test(test_content_parse_inline_line_break), }; return run_tests(tests); }