aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2015-08-13 22:05:20 -0300
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2015-08-13 22:05:20 -0300
commit07d3a1f7a2bdfa4f5918b515d617eecbd6e081db (patch)
tree7547985fcdafb0f3be7be3787ab6e179fe839509 /tests
parent3468762d7a830bd68dafdc4c8d489f965fd48b42 (diff)
downloadblogc-07d3a1f7a2bdfa4f5918b515d617eecbd6e081db.tar.gz
blogc-07d3a1f7a2bdfa4f5918b515d617eecbd6e081db.tar.bz2
blogc-07d3a1f7a2bdfa4f5918b515d617eecbd6e081db.zip
content-parser: implemented multiline support for lists
Diffstat (limited to 'tests')
-rw-r--r--tests/check_content_parser.c96
1 files changed, 89 insertions, 7 deletions
diff --git a/tests/check_content_parser.c b/tests/check_content_parser.c
index 1eb2aa5..b9f83b0 100644
--- a/tests/check_content_parser.c
+++ b/tests/check_content_parser.c
@@ -20,6 +20,24 @@
static void
+test_is_ordered_list_item(void **state)
+{
+ assert_true(blogc_is_ordered_list_item("1.bola", 2));
+ assert_true(blogc_is_ordered_list_item("1. bola", 3));
+ assert_true(blogc_is_ordered_list_item("12. bola", 4));
+ assert_true(blogc_is_ordered_list_item("123. bola", 5));
+ assert_true(blogc_is_ordered_list_item("1. bola", 6));
+ assert_true(blogc_is_ordered_list_item("1. bola", 5));
+ assert_false(blogc_is_ordered_list_item("1bola", 1));
+ assert_false(blogc_is_ordered_list_item("12bola", 2));
+ assert_false(blogc_is_ordered_list_item("1 . bola", 6));
+ assert_false(blogc_is_ordered_list_item("1. bola", 6));
+ assert_false(blogc_is_ordered_list_item("1.", 2));
+ assert_false(blogc_is_ordered_list_item(NULL, 2));
+}
+
+
+static void
test_content_parse(void **state)
{
size_t l = 0;
@@ -368,6 +386,40 @@ test_content_parse_unordered_list(void **state)
"</ul>\n"
"<p>fuuuu</p>\n");
free(html);
+ html = blogc_content_parse(
+ "lol\n"
+ "\n"
+ "* asd\n"
+ " cvb\n"
+ "* qwe\n"
+ "* zxc\n"
+ " 1234\n"
+ "\n"
+ "fuuuu\n", NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<p>lol</p>\n"
+ "<ul>\n"
+ "<li>asd\n"
+ "cvb</li>\n"
+ "<li>qwe</li>\n"
+ "<li>zxc\n"
+ "1234</li>\n"
+ "</ul>\n"
+ "<p>fuuuu</p>\n");
+ free(html);
+ html = blogc_content_parse(
+ "* asd\n"
+ "* qwe\n"
+ "* zxc", NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<ul>\n"
+ "<li>asd</li>\n"
+ "<li> qwe</li>\n"
+ "<li> zxc</li>\n"
+ "</ul>\n");
+ free(html);
}
@@ -423,21 +475,37 @@ test_content_parse_ordered_list(void **state)
"<p>fuuuu</p>\n");
free(html);
html = blogc_content_parse(
- "1.\nasd\n"
- "2. qwe\n", NULL);
+ "lol\n"
+ "\n"
+ "1. asd\n"
+ " cvb\n"
+ "2. qwe\n"
+ "3. zxc\n"
+ " 1234\n"
+ "\n"
+ "fuuuu\n", NULL);
assert_non_null(html);
assert_string_equal(html,
- "<p>1.\n"
- "asd</p>\n"
+ "<p>lol</p>\n"
"<ol>\n"
+ "<li>asd\n"
+ "cvb</li>\n"
"<li>qwe</li>\n"
- "</ol>\n");
+ "<li>zxc\n"
+ "1234</li>\n"
+ "</ol>\n"
+ "<p>fuuuu</p>\n");
free(html);
- html = blogc_content_parse("1.\n", NULL);
+ html = blogc_content_parse(
+ "1. asd\n"
+ "2. qwe\n"
+ "3. zxc", NULL);
assert_non_null(html);
assert_string_equal(html,
"<ol>\n"
- "<li></li>\n"
+ "<li>asd</li>\n"
+ "<li> qwe</li>\n"
+ "<li> zxc</li>\n"
"</ol>\n");
free(html);
}
@@ -719,6 +787,19 @@ test_content_parse_invalid_ordered_list(void **state)
"<p>a. asd\n"
"2. qwe</p>\n");
free(html);
+ html = blogc_content_parse(
+ "1.\nasd\n"
+ "2. qwe\n", NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<p>1.\n"
+ "asd\n"
+ "2. qwe</p>\n");
+ free(html);
+ html = blogc_content_parse("1.\n", NULL);
+ assert_non_null(html);
+ assert_string_equal(html, "<p>1.</p>\n");
+ free(html);
}
@@ -1038,6 +1119,7 @@ int
main(void)
{
const UnitTest tests[] = {
+ unit_test(test_is_ordered_list_item),
unit_test(test_content_parse),
unit_test(test_content_parse_with_excerpt),
unit_test(test_content_parse_header),