aboutsummaryrefslogtreecommitdiffstats
path: root/tests/check_content_parser.c
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2015-05-27 01:19:57 -0300
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2015-05-27 01:19:57 -0300
commit3cd628f31ff383114e21349958fd19f45fe2a8c0 (patch)
treeff2ce21fb2b80931eb54cac934bd3c46ced210b0 /tests/check_content_parser.c
parentec0b4dbccf1fe41cfc14031a14d6b17e13770197 (diff)
downloadblogc-3cd628f31ff383114e21349958fd19f45fe2a8c0.tar.gz
blogc-3cd628f31ff383114e21349958fd19f45fe2a8c0.tar.bz2
blogc-3cd628f31ff383114e21349958fd19f45fe2a8c0.zip
content-parser: random fixes, more tests
Diffstat (limited to 'tests/check_content_parser.c')
-rw-r--r--tests/check_content_parser.c144
1 files changed, 144 insertions, 0 deletions
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)
"</ol>\n"
"<p>fuuuu</p>\n");
free(html);
+ html = blogc_content_parse(
+ "1.\nasd\n"
+ "2. qwe\n");
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<p>1.\n"
+ "asd</p>\n"
+ "<ol>\n"
+ "<li>qwe</li>\n"
+ "</ol>\n");
+ free(html);
+ html = blogc_content_parse("1.\n");
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<ol>\n"
+ "<li></li>\n"
+ "</ol>\n");
+ free(html);
}
@@ -463,6 +481,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,
+ "<p><em> asd\n"
+ "1. qwe</p>\n");
+ free(html);
+ html = blogc_content_parse(
+ "* asd\n"
+ "1. qwe\n"
+ "\n");
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<p><em> asd\n"
+ "1. qwe</p>\n");
+ free(html);
+ html = blogc_content_parse(
+ "* asd\n"
+ "1. qwe\n");
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<p><em> asd\n"
+ "1. qwe</p>\n");
+ free(html);
+ html = blogc_content_parse(
+ "* asd\n"
+ "1. qwe\n");
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<p><em> asd\n"
+ "1. qwe</p>\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,
+ "<p>chunda</p>\n"
+ "<p><em> asd\n"
+ "1. qwe</p>\n"
+ "<p>poi</p>\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,
+ "<p>1. asd\n"
+ "<em> qwe</p>\n");
+ free(html);
+ html = blogc_content_parse(
+ "1. asd\n"
+ "* qwe\n"
+ "\n");
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<p>1. asd\n"
+ "<em> qwe</p>\n");
+ free(html);
+ html = blogc_content_parse(
+ "1. asd\n"
+ "* qwe\n");
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<p>1. asd\n"
+ "<em> qwe</p>\n");
+ free(html);
+ html = blogc_content_parse(
+ "1. asd\n"
+ "* qwe\n");
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<p>1. asd\n"
+ "<em> qwe</p>\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,
+ "<p>chunda</p>\n"
+ "<p>1. asd\n"
+ "<em> qwe</p>\n"
+ "<p>poi</p>\n");
+ free(html);
+ html = blogc_content_parse(
+ "1 asd\n"
+ "* qwe\n");
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<p>1 asd\n"
+ "<em> qwe</p>\n");
+ free(html);
+ html = blogc_content_parse(
+ "a. asd\n"
+ "2. qwe\n");
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<p>a. asd\n"
+ "2. qwe</p>\n");
+ free(html);
+}
+
+
+void
test_content_parse_inline(void **state)
{
char *html = blogc_content_parse_inline(
@@ -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);