From 721dc436a0f88d28809918f11f1896a49cb997e4 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Tue, 19 May 2015 02:25:20 -0300 Subject: content-parser: more tests --- tests/check_content_parser.c | 126 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) diff --git a/tests/check_content_parser.c b/tests/check_content_parser.c index 390d516..e4ae9ae 100644 --- a/tests/check_content_parser.c +++ b/tests/check_content_parser.c @@ -273,6 +273,114 @@ test_content_parse_horizontal_rule(void **state) } +void +test_content_parse_unordered_list(void **state) +{ + char *html = blogc_content_parse( + "lol\n" + "\n" + "* asd\n" + "* qwe\n" + "* zxc"); + assert_non_null(html); + assert_string_equal(html, + "

lol

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

lol

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

lol

\n" + "\n" + "

fuuuu

\n"); + free(html); +} + + +void +test_content_parse_ordered_list(void **state) +{ + char *html = blogc_content_parse( + "lol\n" + "\n" + "1. asd\n" + "2. qwe\n" + "3. zxc"); + 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"); + 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"); + 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); +} + + void test_content_parse_invalid_header(void **state) { @@ -339,6 +447,21 @@ test_content_parse_invalid_code(void **state) } +void +test_content_parse_invalid_horizontal_rule(void **state) +{ + // this generates invalid html, but... + char *html = blogc_content_parse("** asd"); + assert_non_null(html); + assert_string_equal(html, "

asd

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

asd

\n"); + free(html); +} + + void test_content_parse_inline(void **state) { @@ -367,10 +490,13 @@ main(void) 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_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_inline), }; return run_tests(tests); -- cgit v1.2.3-18-g5258