diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2015-05-19 02:25:20 -0300 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2015-05-19 02:25:20 -0300 |
commit | 721dc436a0f88d28809918f11f1896a49cb997e4 (patch) | |
tree | ba8d70f4798512014dda0f152db841f41ab313fa /tests/check_content_parser.c | |
parent | cbefb0ffb583a877a082bc336f2d61be7e773a5d (diff) | |
download | blogc-721dc436a0f88d28809918f11f1896a49cb997e4.tar.gz blogc-721dc436a0f88d28809918f11f1896a49cb997e4.tar.bz2 blogc-721dc436a0f88d28809918f11f1896a49cb997e4.zip |
content-parser: more tests
Diffstat (limited to 'tests/check_content_parser.c')
-rw-r--r-- | tests/check_content_parser.c | 126 |
1 files changed, 126 insertions, 0 deletions
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 @@ -274,6 +274,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, + "<p>lol</p>\n" + "<ul>\n" + "<li>asd</li>\n" + "<li>qwe</li>\n" + "<li>zxc</li>\n" + "</ul>\n"); + free(html); + html = blogc_content_parse( + "lol\n" + "\n" + "* asd\n" + "* qwe\n" + "* zxc\n"); + assert_non_null(html); + assert_string_equal(html, + "<p>lol</p>\n" + "<ul>\n" + "<li>asd</li>\n" + "<li>qwe</li>\n" + "<li>zxc</li>\n" + "</ul>\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, + "<p>lol</p>\n" + "<ul>\n" + "<li>asd</li>\n" + "<li>qwe</li>\n" + "<li>zxc</li>\n" + "</ul>\n" + "<p>fuuuu</p>\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, + "<p>lol</p>\n" + "<ol>\n" + "<li>asd</li>\n" + "<li>qwe</li>\n" + "<li>zxc</li>\n" + "</ol>\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, + "<p>lol</p>\n" + "<ol>\n" + "<li>asd</li>\n" + "<li>qwe</li>\n" + "<li>zxc</li>\n" + "</ol>\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, + "<p>lol</p>\n" + "<ol>\n" + "<li>asd</li>\n" + "<li>qwe</li>\n" + "<li>zxc</li>\n" + "</ol>\n" + "<p>fuuuu</p>\n"); + free(html); +} + + +void test_content_parse_invalid_header(void **state) { char *html = blogc_content_parse( @@ -340,6 +448,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, "<p><strong> asd</p>\n"); + free(html); + html = blogc_content_parse("** asd\n"); + assert_non_null(html); + assert_string_equal(html, "<p><strong> asd</p>\n"); + free(html); +} + + +void test_content_parse_inline(void **state) { char *html = blogc_content_parse_inline( @@ -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); |