From 3cd628f31ff383114e21349958fd19f45fe2a8c0 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Wed, 27 May 2015 01:19:57 -0300 Subject: content-parser: random fixes, more tests --- tests/check_content_parser.c | 144 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) (limited to 'tests/check_content_parser.c') diff --git a/tests/check_content_parser.c b/tests/check_content_parser.c index ea8de4b..4f46be8 100644 --- a/tests/check_content_parser.c +++ b/tests/check_content_parser.c @@ -378,6 +378,24 @@ test_content_parse_ordered_list(void **state) "\n" "

fuuuu

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

1.\n" + "asd

\n" + "
    \n" + "
  1. qwe
  2. \n" + "
\n"); + free(html); + html = blogc_content_parse("1.\n"); + assert_non_null(html); + assert_string_equal(html, + "
    \n" + "
  1. \n" + "
\n"); + free(html); } @@ -462,6 +480,130 @@ test_content_parse_invalid_horizontal_rule(void **state) } +void +test_content_parse_invalid_unordered_list(void **state) +{ + // more invalid html + char *html = blogc_content_parse( + "* asd\n" + "1. qwe"); + 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"); + assert_non_null(html); + assert_string_equal(html, + "

asd\n" + "1. qwe

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

asd\n" + "1. qwe

\n"); + free(html); + html = blogc_content_parse( + "* asd\n" + "1. qwe\n"); + 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"); + assert_non_null(html); + assert_string_equal(html, + "

chunda

\n" + "

asd\n" + "1. qwe

\n" + "

poi

\n"); + free(html); +} + + +void +test_content_parse_invalid_ordered_list(void **state) +{ + // more invalid html + char *html = blogc_content_parse( + "1. asd\n" + "* qwe"); + 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"); + assert_non_null(html); + assert_string_equal(html, + "

1. asd\n" + " qwe

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

1. asd\n" + " qwe

\n"); + free(html); + html = blogc_content_parse( + "1. asd\n" + "* qwe\n"); + 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"); + 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"); + 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"); + assert_non_null(html); + assert_string_equal(html, + "

a. asd\n" + "2. qwe

\n"); + free(html); +} + + void test_content_parse_inline(void **state) { @@ -497,6 +639,8 @@ main(void) 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), }; return run_tests(tests); -- cgit v1.2.3-18-g5258