From f63fb03b25b33d5c2ef5ef0eaad016b4ee4aee65 Mon Sep 17 00:00:00 2001
From: "Rafael G. Martins" guda\n"
"yay bola bola\n"
+ "— foo\n"
+ "– bar — asd – lol guda\r\n"
"yay bola bola\r\n"
+ "— foo\r\n"
+ "– bar — asd – lol guda\n"
"yay bola\n"
- "— foo\n"
+ "— foo-bar\n"
"– bar — asd – lol guda\r\n"
"yay bola\r\n"
- "— foo\r\n"
+ "— foo-bar\r\n"
"– bar — asd – lol guda\n"
"yay bola\n"
- "— foo-bar\n"
- "– bar — asd – lolbola(2)[3]**!\\
\n");
free(html);
+ html = blogc_content_parse_inline("test suite!)\n"
+ "depends on [cmocka](http://cmocka.org/), though.\n");
+ assert_non_null(html);
+ assert_string_equal(html, "test suite!)\n"
+ "depends on cmocka, though.\n");
+ free(html);
// "invalid"
html = blogc_content_parse_inline("[bola](\nhttp://example.org/)\n");
assert_non_null(html);
--
cgit v1.2.3-18-g5258
From 31d376735ab2aaaed0934edcce676113f83a7de7 Mon Sep 17 00:00:00 2001
From: "Rafael G. Martins" \n");
free(html);
+ html = blogc_content_parse_inline("![bola]\r\n(http://example.org/)\n");
+ assert_non_null(html);
+ assert_string_equal(html, "
\n");
+ free(html);
+ html = blogc_content_parse_inline("![bola] \r\n (http://example.org/)\n");
+ assert_non_null(html);
+ assert_string_equal(html, "
\n");
+ free(html);
+ html = blogc_content_parse_inline("asd ![bola]chunda(1234)");
+ assert_non_null(html);
+ assert_string_equal(html, "asd ![bola]chunda(1234)");
+ free(html);
// "invalid"
html = blogc_content_parse_inline("\n");
assert_non_null(html);
--
cgit v1.2.3-18-g5258
From b73afb052337d3c11d90efb5e90c2818063dda4d Mon Sep 17 00:00:00 2001
From: "Rafael G. Martins"
\n");
free(html);
+ html = blogc_content_parse_inline(
+ "[](https://blogc.rgm.io)");
+ assert_non_null(html);
+ assert_string_equal(html,
+ "
");
+ free(html);
+ html = blogc_content_parse_inline(
+ "[![This is the image alt text]\n"
+ "(picture.jpg)](https://blogc.rgm.io)");
+ assert_non_null(html);
+ assert_string_equal(html,
+ "
");
+ free(html);
html = blogc_content_parse_inline("asd ![bola]chunda(1234)");
assert_non_null(html);
assert_string_equal(html, "asd ![bola]chunda(1234)");
--
cgit v1.2.3-18-g5258
From 437ea5b71f7a1f6cd5d09b28259a8e49acab7fbc Mon Sep 17 00:00:00 2001
From: "Rafael G. Martins"
");
free(html);
+ html = blogc_content_parse_inline(
+ "[![This is the image alt text]\n"
+ "(picture.jpg)]\n"
+ "(https://blogc.rgm.io)");
+ assert_non_null(html);
+ assert_string_equal(html,
+ "
");
+ free(html);
html = blogc_content_parse_inline("asd ![bola]chunda(1234)");
assert_non_null(html);
assert_string_equal(html, "asd ![bola]chunda(1234)");
--
cgit v1.2.3-18-g5258
From 3b0f9293a3432023cdca91df01418347d9781ffa Mon Sep 17 00:00:00 2001
From: "Rafael G. Martins"
– asd
\n" + "— lol
\n"); free(html); } @@ -245,10 +245,10 @@ test_content_parse_crlf(void **state) "guda\r\n" "yay
\r\n" "bola\r\n" - "— foo-bar\r\n" - "– bar
\r\n" - "— asd
\r\n" - "– lol
\r\n"); + "– foo-bar\r\n" + "— bar\r\n" + "– asd
\r\n" + "— lol
\r\n"); free(html); } -- cgit v1.2.3-18-g5258 From 001c16ac605ee65f5688534e42c10395db3f0d5a Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins"foo -- bar
");
+ free(html);
+ html = blogc_content_parse_inline("`foo --- bar`");
+ assert_non_null(html);
+ assert_string_equal(html, "foo --- bar
");
+ free(html);
+ html = blogc_content_parse_inline("``foo -- bar``");
+ assert_non_null(html);
+ assert_string_equal(html, "foo -- bar
");
+ free(html);
+ html = blogc_content_parse_inline("``foo --- bar``");
+ assert_non_null(html);
+ assert_string_equal(html, "foo --- bar
");
+ free(html);
+}
+
+
int
main(void)
{
@@ -1793,6 +1823,7 @@ main(void)
unit_test(test_content_parse_inline_image),
unit_test(test_content_parse_inline_line_break),
unit_test(test_content_parse_inline_line_break_crlf),
+ unit_test(test_content_parse_inline_endash_emdash),
};
return run_tests(tests);
}
--
cgit v1.2.3-18-g5258
From 9b2a563b4931ca39cd6dd14bf85cda627714a4b2 Mon Sep 17 00:00:00 2001
From: "Rafael G. Martins" – asd
\n" "— lol
\n"); free(html); + free(d); } @@ -169,6 +173,7 @@ static void test_content_parse_crlf(void **state) { size_t l = 0; + char *d = NULL; char *html = blogc_content_parse( "# um\r\n" "## dois\r\n" @@ -210,9 +215,11 @@ test_content_parse_crlf(void **state) "\r\n" "-- asd\r\n" "\r\n" - "--- lol\r\n", &l); + "--- lol\r\n", &l, &d); assert_non_null(html); assert_int_equal(l, 0); + assert_non_null(d); + assert_string_equal(d, "bola"); assert_string_equal(html, "– asd
\r\n" "— lol
\r\n"); free(html); + free(d); } @@ -257,6 +265,7 @@ static void test_content_parse_with_excerpt(void **state) { size_t l = 0; + char *d = NULL; char *html = blogc_content_parse( "# test\n" "\n" @@ -265,9 +274,11 @@ test_content_parse_with_excerpt(void **state) "..\n" "\n" "guda\n" - "lol", &l); + "lol", &l, &d); assert_non_null(html); assert_int_equal(l, 38); + assert_non_null(d); + assert_string_equal(d, "chunda"); assert_string_equal(html, "chunda
\n" @@ -275,6 +286,8 @@ test_content_parse_with_excerpt(void **state) "lol\n"); free(html); l = 0; + free(d); + d = NULL; html = blogc_content_parse( "# test\n" "\n" @@ -283,15 +296,18 @@ test_content_parse_with_excerpt(void **state) "...\n" "\n" "guda\n" - "lol", &l); + "lol", &l, &d); assert_non_null(html); assert_int_equal(l, 38); + assert_non_null(d); + assert_string_equal(d, "chunda"); assert_string_equal(html, "chunda
\n" "guda\n" "lol
\n"); free(html); + free(d); } @@ -299,6 +315,7 @@ static void test_content_parse_with_excerpt_crlf(void **state) { size_t l = 0; + char *d = NULL; char *html = blogc_content_parse( "# test\r\n" "\r\n" @@ -307,9 +324,11 @@ test_content_parse_with_excerpt_crlf(void **state) "..\r\n" "\r\n" "guda\r\n" - "lol", &l); + "lol", &l, &d); assert_non_null(html); assert_int_equal(l, 40); + assert_non_null(d); + assert_string_equal(d, "chunda"); assert_string_equal(html, "chunda
\r\n" @@ -317,6 +336,8 @@ test_content_parse_with_excerpt_crlf(void **state) "lol\r\n"); free(html); l = 0; + free(d); + d = NULL; html = blogc_content_parse( "# test\r\n" "\r\n" @@ -325,26 +346,29 @@ test_content_parse_with_excerpt_crlf(void **state) "...\r\n" "\r\n" "guda\r\n" - "lol", &l); + "lol", &l, &d); assert_non_null(html); assert_int_equal(l, 40); + assert_non_null(d); + assert_string_equal(d, "chunda"); assert_string_equal(html, "chunda
\r\n" "guda\r\n" "lol
\r\n"); free(html); + free(d); } static void test_content_parse_header(void **state) { - char *html = blogc_content_parse("## bola", NULL); + char *html = blogc_content_parse("## bola", NULL, NULL); assert_non_null(html); assert_string_equal(html, "bola
\n" @@ -366,11 +390,11 @@ test_content_parse_header(void **state) static void test_content_parse_header_crlf(void **state) { - char *html = blogc_content_parse("## bola", NULL); + char *html = blogc_content_parse("## bola", NULL, NULL); assert_non_null(html); assert_string_equal(html, "bola
\r\n" @@ -392,11 +416,11 @@ test_content_parse_header_crlf(void **state) static void test_content_parse_html(void **state) { - char *html = blogc_content_parse("bola
\n" @@ -419,11 +443,11 @@ test_content_parse_html(void **state) static void test_content_parse_html_crlf(void **state) { - char *html = blogc_content_parse("bola
\r\n" @@ -446,27 +470,40 @@ test_content_parse_html_crlf(void **state) static void test_content_parse_blockquote(void **state) { - char *html = blogc_content_parse("> bola\n> guda", NULL); + char *html = blogc_content_parse("> bola\n> guda", NULL, NULL); assert_non_null(html); assert_string_equal(html, "\n"); free(html); - html = blogc_content_parse("> bola\n> guda\n", NULL); + html = blogc_content_parse("> bola\n> guda\n", NULL, 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" + "\n" + "chunda\n", NULL, NULL); + assert_non_null(html); + assert_string_equal(html, + "bola\n" "guda
\n" "
bola
\n" + "\n" + "bola
\n" + "
chunda
\n"); + free(html); html = blogc_content_parse( "bola\n" "\n" "> bola\n" "> guda\n" "\n" - "chunda\n", NULL); + "chunda\n", NULL, NULL); assert_non_null(html); assert_string_equal(html, "bola
\n" @@ -481,27 +518,40 @@ test_content_parse_blockquote(void **state) static void test_content_parse_blockquote_crlf(void **state) { - char *html = blogc_content_parse("> bola\r\n> guda", NULL); + char *html = blogc_content_parse("> bola\r\n> guda", NULL, NULL); assert_non_null(html); assert_string_equal(html, "\r\n"); free(html); - html = blogc_content_parse("> bola\r\n> guda\r\n", NULL); + html = blogc_content_parse("> bola\r\n> guda\r\n", NULL, NULL); assert_non_null(html); assert_string_equal(html, "bola\r\n" "guda
\r\n" "
\r\n"); free(html); + html = blogc_content_parse( + "bola\r\n" + "\r\n" + "> bola\r\n" + "\r\n" + "chunda\r\n", NULL, NULL); + assert_non_null(html); + assert_string_equal(html, + "bola\r\n" "guda
\r\n" "
bola
\r\n" + "\r\n" + "bola
\r\n" + "
chunda
\r\n"); + free(html); html = blogc_content_parse( "bola\r\n" "\r\n" "> bola\r\n" "> guda\r\n" "\r\n" - "chunda\r\n", NULL); + "chunda\r\n", NULL, NULL); assert_non_null(html); assert_string_equal(html, "bola
\r\n" @@ -516,13 +566,13 @@ test_content_parse_blockquote_crlf(void **state) static void test_content_parse_code(void **state) { - char *html = blogc_content_parse(" bola\n guda", NULL); + char *html = blogc_content_parse(" bola\n guda", NULL, NULL); assert_non_null(html); assert_string_equal(html, "bola\n"
"guda
\n");
free(html);
- html = blogc_content_parse(" bola\n guda\n", NULL);
+ html = blogc_content_parse(" bola\n guda\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"bola\n"
@@ -534,7 +584,7 @@ test_content_parse_code(void **state)
" bola\n"
" guda\n"
"\n"
- "chunda\n", NULL);
+ "chunda\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"bola
\n"
@@ -548,13 +598,13 @@ test_content_parse_code(void **state)
static void
test_content_parse_code_crlf(void **state)
{
- char *html = blogc_content_parse(" bola\r\n guda", NULL);
+ char *html = blogc_content_parse(" bola\r\n guda", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"bola\r\n"
"guda
\r\n");
free(html);
- html = blogc_content_parse(" bola\r\n guda\r\n", NULL);
+ html = blogc_content_parse(" bola\r\n guda\r\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"bola\r\n"
@@ -566,7 +616,7 @@ test_content_parse_code_crlf(void **state)
" bola\r\n"
" guda\r\n"
"\r\n"
- "chunda\r\n", NULL);
+ "chunda\r\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"bola
\r\n"
@@ -580,28 +630,28 @@ test_content_parse_code_crlf(void **state)
static void
test_content_parse_horizontal_rule(void **state)
{
- char *html = blogc_content_parse("bola\nguda\n\n**", NULL);
+ char *html = blogc_content_parse("bola\nguda\n\n**", NULL, 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);
+ html = blogc_content_parse("bola\nguda\n\n++++", NULL, 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);
+ html = blogc_content_parse("bola\nguda\n\n--\n", NULL, 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);
+ html = blogc_content_parse("bola\nguda\n\n****\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"bola\n"
@@ -613,7 +663,7 @@ test_content_parse_horizontal_rule(void **state)
"\n"
"**\n"
"\n"
- "chunda\n", NULL);
+ "chunda\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"
bola
\n"
@@ -625,7 +675,7 @@ test_content_parse_horizontal_rule(void **state)
"\n"
"----\n"
"\n"
- "chunda\n", NULL);
+ "chunda\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"bola
\n"
@@ -638,28 +688,28 @@ test_content_parse_horizontal_rule(void **state)
static void
test_content_parse_horizontal_rule_crlf(void **state)
{
- char *html = blogc_content_parse("bola\r\nguda\r\n\r\n**", NULL);
+ char *html = blogc_content_parse("bola\r\nguda\r\n\r\n**", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"bola\r\n"
"guda
\r\n"
"
\r\n");
free(html);
- html = blogc_content_parse("bola\r\nguda\r\n\r\n++++", NULL);
+ html = blogc_content_parse("bola\r\nguda\r\n\r\n++++", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"bola\r\n"
"guda
\r\n"
"
\r\n");
free(html);
- html = blogc_content_parse("bola\r\nguda\r\n\r\n--\r\n", NULL);
+ html = blogc_content_parse("bola\r\nguda\r\n\r\n--\r\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"bola\r\n"
"guda
\r\n"
"
\r\n");
free(html);
- html = blogc_content_parse("bola\r\nguda\r\n\r\n****\r\n", NULL);
+ html = blogc_content_parse("bola\r\nguda\r\n\r\n****\r\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"bola\r\n"
@@ -671,7 +721,7 @@ test_content_parse_horizontal_rule_crlf(void **state)
"\r\n"
"**\r\n"
"\r\n"
- "chunda\r\n", NULL);
+ "chunda\r\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"
bola
\r\n"
@@ -683,7 +733,7 @@ test_content_parse_horizontal_rule_crlf(void **state)
"\r\n"
"----\r\n"
"\r\n"
- "chunda\r\n", NULL);
+ "chunda\r\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"bola
\r\n"
@@ -701,7 +751,7 @@ test_content_parse_unordered_list(void **state)
"\n"
"* asd\n"
"* qwe\n"
- "* zxc", NULL);
+ "* zxc", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"lol
\n"
@@ -716,7 +766,7 @@ test_content_parse_unordered_list(void **state)
"\n"
"* asd\n"
"* qwe\n"
- "* zxc\n", NULL);
+ "* zxc\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"lol
\n"
@@ -733,7 +783,7 @@ test_content_parse_unordered_list(void **state)
"* qwe\n"
"* zxc\n"
"\n"
- "fuuuu\n", NULL);
+ "fuuuu\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"lol
\n"
@@ -753,7 +803,7 @@ test_content_parse_unordered_list(void **state)
"* zxc\n"
" 1234\n"
"\n"
- "fuuuu\n", NULL);
+ "fuuuu\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"lol
\n"
@@ -769,7 +819,7 @@ test_content_parse_unordered_list(void **state)
html = blogc_content_parse(
"* asd\n"
"* qwe\n"
- "* zxc", NULL);
+ "* zxc", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"\n"
@@ -789,7 +839,7 @@ test_content_parse_unordered_list_crlf(void **state)
"\r\n"
"* asd\r\n"
"* qwe\r\n"
- "* zxc", NULL);
+ "* zxc", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"lol
\r\n"
@@ -804,7 +854,7 @@ test_content_parse_unordered_list_crlf(void **state)
"\r\n"
"* asd\r\n"
"* qwe\r\n"
- "* zxc\r\n", NULL);
+ "* zxc\r\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"lol
\r\n"
@@ -821,7 +871,7 @@ test_content_parse_unordered_list_crlf(void **state)
"* qwe\r\n"
"* zxc\r\n"
"\r\n"
- "fuuuu\r\n", NULL);
+ "fuuuu\r\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"lol
\r\n"
@@ -841,7 +891,7 @@ test_content_parse_unordered_list_crlf(void **state)
"* zxc\r\n"
" 1234\r\n"
"\r\n"
- "fuuuu\r\n", NULL);
+ "fuuuu\r\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"lol
\r\n"
@@ -857,7 +907,7 @@ test_content_parse_unordered_list_crlf(void **state)
html = blogc_content_parse(
"* asd\r\n"
"* qwe\r\n"
- "* zxc", NULL);
+ "* zxc", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"\r\n"
@@ -877,7 +927,7 @@ test_content_parse_ordered_list(void **state)
"\n"
"1. asd\n"
"2. qwe\n"
- "3. zxc", NULL);
+ "3. zxc", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"lol
\n"
@@ -892,7 +942,7 @@ test_content_parse_ordered_list(void **state)
"\n"
"1. asd\n"
"2. qwe\n"
- "3. zxc\n", NULL);
+ "3. zxc\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"lol
\n"
@@ -909,7 +959,7 @@ test_content_parse_ordered_list(void **state)
"2. qwe\n"
"3. zxc\n"
"\n"
- "fuuuu\n", NULL);
+ "fuuuu\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"lol
\n"
@@ -929,7 +979,7 @@ test_content_parse_ordered_list(void **state)
"3. zxc\n"
" 1234\n"
"\n"
- "fuuuu\n", NULL);
+ "fuuuu\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"lol
\n"
@@ -945,7 +995,7 @@ test_content_parse_ordered_list(void **state)
html = blogc_content_parse(
"1. asd\n"
"2. qwe\n"
- "3. zxc", NULL);
+ "3. zxc", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"\n"
@@ -965,7 +1015,7 @@ test_content_parse_ordered_list_crlf(void **state)
"\r\n"
"1. asd\r\n"
"2. qwe\r\n"
- "3. zxc", NULL);
+ "3. zxc", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"lol
\r\n"
@@ -980,7 +1030,7 @@ test_content_parse_ordered_list_crlf(void **state)
"\r\n"
"1. asd\r\n"
"2. qwe\r\n"
- "3. zxc\r\n", NULL);
+ "3. zxc\r\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"lol
\r\n"
@@ -997,7 +1047,7 @@ test_content_parse_ordered_list_crlf(void **state)
"2. qwe\r\n"
"3. zxc\r\n"
"\r\n"
- "fuuuu\r\n", NULL);
+ "fuuuu\r\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"lol
\r\n"
@@ -1017,7 +1067,7 @@ test_content_parse_ordered_list_crlf(void **state)
"3. zxc\r\n"
" 1234\r\n"
"\r\n"
- "fuuuu\r\n", NULL);
+ "fuuuu\r\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"lol
\r\n"
@@ -1033,7 +1083,7 @@ test_content_parse_ordered_list_crlf(void **state)
html = blogc_content_parse(
"1. asd\r\n"
"2. qwe\r\n"
- "3. zxc", NULL);
+ "3. zxc", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"\r\n"
@@ -1045,10 +1095,177 @@ test_content_parse_ordered_list_crlf(void **state)
}
+static void
+test_content_parse_description(void **state)
+{
+ char *d = NULL;
+ char *html = blogc_content_parse(
+ "# foo\n"
+ "\n"
+ "bar", NULL, &d);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "foo
\n"
+ "bar
\n");
+ assert_non_null(d);
+ assert_string_equal(d, "bar");
+ free(html);
+ free(d);
+ d = NULL;
+ html = blogc_content_parse(
+ "# foo\n"
+ "\n"
+ "bar\n", NULL, &d);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "foo
\n"
+ "bar
\n");
+ assert_non_null(d);
+ assert_string_equal(d, "bar");
+ free(html);
+ free(d);
+ d = NULL;
+ html = blogc_content_parse(
+ "# foo\n"
+ "\n"
+ "qwe\n"
+ "bar\n", NULL, &d);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "foo
\n"
+ "qwe\n"
+ "bar
\n");
+ assert_non_null(d);
+ assert_string_equal(d, "qwe");
+ free(html);
+ free(d);
+ d = NULL;
+ html = blogc_content_parse(
+ "# foo\n"
+ "\n"
+ "> qwe\n"
+ "\n"
+ "bar\n", NULL, &d);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "foo
\n"
+ "qwe
\n"
+ "
\n"
+ "bar
\n");
+ assert_non_null(d);
+ assert_string_equal(d, "qwe");
+ free(html);
+ free(d);
+ d = NULL;
+ html = blogc_content_parse(
+ "# foo\n"
+ "\n"
+ "> qwe\n"
+ "> zxc\n"
+ "\n"
+ "bar\n", NULL, &d);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "foo
\n"
+ "qwe\n"
+ "zxc
\n"
+ "
\n"
+ "bar
\n");
+ assert_non_null(d);
+ assert_string_equal(d, "qwe");
+ free(html);
+ free(d);
+}
+
+
+static void
+test_content_parse_description_crlf(void **state)
+{
+ char *d = NULL;
+ char *html = blogc_content_parse(
+ "# foo\r\n"
+ "\r\n"
+ "bar", NULL, &d);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "foo
\r\n"
+ "bar
\r\n");
+ assert_non_null(d);
+ assert_string_equal(d, "bar");
+ free(html);
+ free(d);
+ d = NULL;
+ html = blogc_content_parse(
+ "# foo\r\n"
+ "\r\n"
+ "bar\r\n", NULL, &d);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "foo
\r\n"
+ "bar
\r\n");
+ assert_non_null(d);
+ assert_string_equal(d, "bar");
+ free(html);
+ free(d);
+ d = NULL;
+ html = blogc_content_parse(
+ "# foo\r\n"
+ "\r\n"
+ "qwe\r\n"
+ "bar\r\n", NULL, &d);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "foo
\r\n"
+ "qwe\r\n"
+ "bar
\r\n");
+ assert_non_null(d);
+ assert_string_equal(d, "qwe");
+ free(html);
+ free(d);
+ d = NULL;
+ html = blogc_content_parse(
+ "# foo\r\n"
+ "\r\n"
+ "> qwe\r\n"
+ "\r\n"
+ "bar\r\n", NULL, &d);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "foo
\r\n"
+ "qwe
\r\n"
+ "
\r\n"
+ "bar
\r\n");
+ assert_non_null(d);
+ assert_string_equal(d, "qwe");
+ free(html);
+ free(d);
+ d = NULL;
+ html = blogc_content_parse(
+ "# foo\r\n"
+ "\r\n"
+ "> qwe\r\n"
+ "> zxc\r\n"
+ "\r\n"
+ "bar\r\n", NULL, &d);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "foo
\r\n"
+ "qwe\r\n"
+ "zxc
\r\n"
+ "
\r\n"
+ "bar
\r\n");
+ assert_non_null(d);
+ assert_string_equal(d, "qwe");
+ free(html);
+ free(d);
+}
+
+
static void
test_content_parse_invalid_excerpt(void **state)
{
size_t l = 0;
+ char *d = NULL;
char *html = blogc_content_parse(
"# test\n"
"\n"
@@ -1056,9 +1273,11 @@ test_content_parse_invalid_excerpt(void **state)
"..\n"
"\n"
"guda\n"
- "lol", &l);
+ "lol", &l, &d);
assert_non_null(html);
assert_int_equal(l, 0);
+ assert_non_null(d);
+ assert_string_equal(d, "chunda");
assert_string_equal(html,
"test
\n"
"chunda\n"
@@ -1067,6 +1286,8 @@ test_content_parse_invalid_excerpt(void **state)
"lol
\n");
free(html);
l = 0;
+ free(d);
+ d = NULL;
html = blogc_content_parse(
"# test\n"
"\n"
@@ -1074,9 +1295,11 @@ test_content_parse_invalid_excerpt(void **state)
"\n"
"...\n"
"guda\n"
- "lol", &l);
+ "lol", &l, &d);
assert_non_null(html);
assert_int_equal(l, 0);
+ assert_non_null(d);
+ assert_string_equal(d, "chunda");
assert_string_equal(html,
"test
\n"
"chunda
\n"
@@ -1085,15 +1308,19 @@ test_content_parse_invalid_excerpt(void **state)
"lol\n");
free(html);
l = 0;
+ free(d);
+ d = NULL;
html = blogc_content_parse(
"# test\n"
"\n"
"chunda..\n"
"\n"
"guda\n"
- "lol", &l);
+ "lol", &l, &d);
assert_non_null(html);
assert_int_equal(l, 0);
+ assert_non_null(d);
+ assert_string_equal(d, "chunda..");
assert_string_equal(html,
"test
\n"
"chunda..
\n"
@@ -1101,21 +1328,26 @@ test_content_parse_invalid_excerpt(void **state)
"lol\n");
free(html);
l = 0;
+ free(d);
+ d = NULL;
html = blogc_content_parse(
"# test\n"
"\n"
"chunda\n"
"\n"
"...guda\n"
- "lol", &l);
+ "lol", &l, &d);
assert_non_null(html);
assert_int_equal(l, 0);
+ assert_non_null(d);
+ assert_string_equal(d, "chunda");
assert_string_equal(html,
"test
\n"
"chunda
\n"
"...guda\n"
"lol
\n");
free(html);
+ free(d);
}
@@ -1125,7 +1357,7 @@ test_content_parse_invalid_header(void **state)
char *html = blogc_content_parse(
"asd\n"
"\n"
- "##bola\n", NULL);
+ "##bola\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"asd
\n"
@@ -1142,7 +1374,7 @@ test_content_parse_invalid_header_empty(void **state)
"\n"
"##\n"
"\n"
- "qwe\n", NULL);
+ "qwe\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"asd
\n"
@@ -1159,7 +1391,7 @@ test_content_parse_invalid_blockquote(void **state)
char *html = blogc_content_parse(
"> asd\n"
"> bola\n"
- "> foo\n", NULL);
+ "> foo\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"> asd\n"
@@ -1168,7 +1400,7 @@ test_content_parse_invalid_blockquote(void **state)
free(html);
html = blogc_content_parse(
"> asd\n"
- "> bola", NULL);
+ "> bola", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"
> asd\n"
@@ -1183,7 +1415,7 @@ test_content_parse_invalid_code(void **state)
char *html = blogc_content_parse(
" asd\n"
" bola\n"
- " foo\n", NULL);
+ " foo\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"
asd\n"
@@ -1193,7 +1425,7 @@ test_content_parse_invalid_code(void **state)
html = blogc_content_parse(
" asd\n"
" bola\n"
- " foo", NULL);
+ " foo", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"
asd\n"
@@ -1207,11 +1439,11 @@ static void
test_content_parse_invalid_horizontal_rule(void **state)
{
// this generates invalid html, but...
- char *html = blogc_content_parse("** asd", NULL);
+ char *html = blogc_content_parse("** asd", NULL, NULL);
assert_non_null(html);
assert_string_equal(html, "
asd
\n");
free(html);
- html = blogc_content_parse("** asd\n", NULL);
+ html = blogc_content_parse("** asd\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html, " asd
\n");
free(html);
@@ -1224,7 +1456,7 @@ test_content_parse_invalid_unordered_list(void **state)
// more invalid html
char *html = blogc_content_parse(
"* asd\n"
- "1. qwe", NULL);
+ "1. qwe", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
" asd\n"
@@ -1233,7 +1465,7 @@ test_content_parse_invalid_unordered_list(void **state)
html = blogc_content_parse(
"* asd\n"
"1. qwe\n"
- "\n", NULL);
+ "\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
" asd\n"
@@ -1241,7 +1473,7 @@ test_content_parse_invalid_unordered_list(void **state)
free(html);
html = blogc_content_parse(
"* asd\n"
- "1. qwe\n", NULL);
+ "1. qwe\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
" asd\n"
@@ -1250,7 +1482,7 @@ test_content_parse_invalid_unordered_list(void **state)
free(html);
html = blogc_content_parse(
"* asd\n"
- "1. qwe\n", NULL);
+ "1. qwe\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
" asd\n"
@@ -1263,7 +1495,7 @@ test_content_parse_invalid_unordered_list(void **state)
"* asd\n"
"1. qwe\n"
"\n"
- "poi\n", NULL);
+ "poi\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"chunda
\n"
@@ -1280,7 +1512,7 @@ test_content_parse_invalid_ordered_list(void **state)
// more invalid html
char *html = blogc_content_parse(
"1. asd\n"
- "* qwe", NULL);
+ "* qwe", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"1. asd\n"
@@ -1289,7 +1521,7 @@ test_content_parse_invalid_ordered_list(void **state)
html = blogc_content_parse(
"1. asd\n"
"* qwe\n"
- "\n", NULL);
+ "\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"
1. asd\n"
@@ -1297,7 +1529,7 @@ test_content_parse_invalid_ordered_list(void **state)
free(html);
html = blogc_content_parse(
"1. asd\n"
- "* qwe\n", NULL);
+ "* qwe\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"
1. asd\n"
@@ -1306,7 +1538,7 @@ test_content_parse_invalid_ordered_list(void **state)
free(html);
html = blogc_content_parse(
"1. asd\n"
- "* qwe\n", NULL);
+ "* qwe\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"
1. asd\n"
@@ -1319,7 +1551,7 @@ test_content_parse_invalid_ordered_list(void **state)
"1. asd\n"
"* qwe\n"
"\n"
- "poi\n", NULL);
+ "poi\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"
chunda
\n"
@@ -1329,7 +1561,7 @@ test_content_parse_invalid_ordered_list(void **state)
free(html);
html = blogc_content_parse(
"1 asd\n"
- "* qwe\n", NULL);
+ "* qwe\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"1 asd\n"
@@ -1337,7 +1569,7 @@ test_content_parse_invalid_ordered_list(void **state)
free(html);
html = blogc_content_parse(
"a. asd\n"
- "2. qwe\n", NULL);
+ "2. qwe\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"
a. asd\n"
@@ -1345,18 +1577,18 @@ test_content_parse_invalid_ordered_list(void **state)
free(html);
html = blogc_content_parse(
"1.\nasd\n"
- "2. qwe\n", NULL);
+ "2. qwe\n", NULL, 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);
+ html = blogc_content_parse("1.\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html, "1.
\n");
free(html);
- html = blogc_content_parse("1 ", NULL);
+ html = blogc_content_parse("1 ", NULL, NULL);
assert_non_null(html);
assert_string_equal(html, "1
\n");
free(html);
@@ -1806,6 +2038,8 @@ main(void)
unit_test(test_content_parse_unordered_list_crlf),
unit_test(test_content_parse_ordered_list),
unit_test(test_content_parse_ordered_list_crlf),
+ unit_test(test_content_parse_description),
+ unit_test(test_content_parse_description_crlf),
unit_test(test_content_parse_invalid_excerpt),
unit_test(test_content_parse_invalid_header),
unit_test(test_content_parse_invalid_header_empty),
--
cgit v1.2.3-18-g5258
From 9699bf0ce6b34c0d05c509925f3367f2200caad5 Mon Sep 17 00:00:00 2001
From: "Rafael G. Martins"
Date: Wed, 27 Apr 2016 02:34:19 +0200
Subject: remove squareball for good
---
tests/check_content_parser.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'tests/check_content_parser.c')
diff --git a/tests/check_content_parser.c b/tests/check_content_parser.c
index 0eaab70..2444ebb 100644
--- a/tests/check_content_parser.c
+++ b/tests/check_content_parser.c
@@ -16,7 +16,7 @@
#include
#include
#include "../src/content-parser.h"
-#include
+#include "../src/utils.h"
static void
--
cgit v1.2.3-18-g5258