From 1605bf39ab342ea5d904fe96df81dd0f55bd3bcf Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Mon, 23 May 2016 02:38:22 +0200 Subject: content-parser: fixed DESCRIPTION variable. it is now built as a single line variable, that contains the full unparsed content of the first paragraph found in the source file, instead of just the first line of it. this also fixes a bug that prevented creating of DESCRIPTION variable, if the source file contained only a single line paragraph. --- tests/check_content_parser.c | 55 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/check_content_parser.c b/tests/check_content_parser.c index d3ef2b8..ab6853a 100644 --- a/tests/check_content_parser.c +++ b/tests/check_content_parser.c @@ -59,6 +59,50 @@ test_htmlentities(void **state) } +static void +test_fix_description(void **state) +{ + assert_null(blogc_fix_description(NULL)); + char *s = blogc_fix_description("bola"); + assert_string_equal(s, "bola"); + free(s); + s = blogc_fix_description("bola\n"); + assert_string_equal(s, "bola"); + free(s); + s = blogc_fix_description("bola\r\n"); + assert_string_equal(s, "bola"); + free(s); + s = blogc_fix_description("bola\nguda"); + assert_string_equal(s, "bola guda"); + free(s); + s = blogc_fix_description("bola\nguda\n"); + assert_string_equal(s, "bola guda"); + free(s); + s = blogc_fix_description("bola\r\nguda\r\n"); + assert_string_equal(s, "bola guda"); + free(s); + + s = blogc_fix_description("bola\n guda lol\n asd"); + assert_string_equal(s, "bola guda lol asd"); + free(s); + s = blogc_fix_description("bola\n guda lol\n asd\n"); + assert_string_equal(s, "bola guda lol asd"); + free(s); + s = blogc_fix_description("bola\r\n guda lol\r\n asd\r\n"); + assert_string_equal(s, "bola guda lol asd"); + free(s); + s = blogc_fix_description(" bola\n guda lol\n asd"); + assert_string_equal(s, "bola guda lol asd"); + free(s); + s = blogc_fix_description(" bola\n guda lol\n asd\n"); + assert_string_equal(s, "bola guda lol asd"); + free(s); + s = blogc_fix_description(" bola\r\n guda lol\r\n asd\r\n"); + assert_string_equal(s, "bola guda lol asd"); + free(s); +} + + static void test_is_ordered_list_item(void **state) { @@ -127,7 +171,7 @@ test_content_parse(void **state) assert_non_null(html); assert_int_equal(l, 0); assert_non_null(d); - assert_string_equal(d, "bola"); + assert_string_equal(d, "bola chunda"); assert_string_equal(html, "

um

\n" "

dois

\n" @@ -219,7 +263,7 @@ test_content_parse_crlf(void **state) assert_non_null(html); assert_int_equal(l, 0); assert_non_null(d); - assert_string_equal(d, "bola"); + assert_string_equal(d, "bola chunda"); assert_string_equal(html, "

um

\r\n" "

dois

\r\n" @@ -1136,7 +1180,7 @@ test_content_parse_description(void **state) "

qwe\n" "bar

\n"); assert_non_null(d); - assert_string_equal(d, "qwe"); + assert_string_equal(d, "qwe bar"); free(html); free(d); d = NULL; @@ -1219,7 +1263,7 @@ test_content_parse_description_crlf(void **state) "

qwe\r\n" "bar

\r\n"); assert_non_null(d); - assert_string_equal(d, "qwe"); + assert_string_equal(d, "qwe bar"); free(html); free(d); d = NULL; @@ -1277,7 +1321,7 @@ test_content_parse_invalid_excerpt(void **state) assert_non_null(html); assert_int_equal(l, 0); assert_non_null(d); - assert_string_equal(d, "chunda"); + assert_string_equal(d, "chunda .."); assert_string_equal(html, "

test

\n" "

chunda\n" @@ -2019,6 +2063,7 @@ main(void) const UnitTest tests[] = { unit_test(test_slugify), unit_test(test_htmlentities), + unit_test(test_fix_description), unit_test(test_is_ordered_list_item), unit_test(test_content_parse), unit_test(test_content_parse_crlf), -- cgit v1.2.3-18-g5258