diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2016-05-23 02:38:22 +0200 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2016-05-23 02:41:11 +0200 |
commit | 1605bf39ab342ea5d904fe96df81dd0f55bd3bcf (patch) | |
tree | 04a8edf1609888cedeb284efa2bc041fd2d40b60 /tests | |
parent | cc0c4d6866bb876e1ba098bc7f70fb8f312e9fc2 (diff) | |
download | blogc-1605bf39ab342ea5d904fe96df81dd0f55bd3bcf.tar.gz blogc-1605bf39ab342ea5d904fe96df81dd0f55bd3bcf.tar.bz2 blogc-1605bf39ab342ea5d904fe96df81dd0f55bd3bcf.zip |
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.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/check_content_parser.c | 55 |
1 files changed, 50 insertions, 5 deletions
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 @@ -60,6 +60,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) { assert_true(blogc_is_ordered_list_item("1.bola", 2)); @@ -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, "<h1 id=\"um\">um</h1>\n" "<h2 id=\"dois\">dois</h2>\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, "<h1 id=\"um\">um</h1>\r\n" "<h2 id=\"dois\">dois</h2>\r\n" @@ -1136,7 +1180,7 @@ test_content_parse_description(void **state) "<p>qwe\n" "bar</p>\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) "<p>qwe\r\n" "bar</p>\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, "<h1 id=\"test\">test</h1>\n" "<p>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), |