aboutsummaryrefslogtreecommitdiffstats
path: root/tests/check_content_parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/check_content_parser.c')
-rw-r--r--tests/check_content_parser.c659
1 files changed, 503 insertions, 156 deletions
diff --git a/tests/check_content_parser.c b/tests/check_content_parser.c
index 165810d..4f201d1 100644
--- a/tests/check_content_parser.c
+++ b/tests/check_content_parser.c
@@ -17,7 +17,7 @@
#include <string.h>
#include "../src/content-parser.h"
#include "../src/directives.h"
-#include "../src/utils/utils.h"
+#include "../src/utils.h"
static void
@@ -82,6 +82,7 @@ static void
test_content_parse(void **state)
{
size_t l = 0;
+ char *d = NULL;
char *html = blogc_content_parse(
"# um\n"
"## dois\n"
@@ -107,8 +108,8 @@ test_content_parse(void **state)
"1. chunda\n"
"3. fuuuu\n"
"\n"
- "+ chunda2\n"
- "+ fuuuu2\n"
+ "- chunda2\n"
+ "- fuuuu2\n"
"\n"
"<style>\n"
" chunda\n"
@@ -117,9 +118,17 @@ test_content_parse(void **state)
"guda\n"
"yay\n"
"\n"
- "**bola**\n", &l);
+ "**bola**\n"
+ "-- foo-bar\n"
+ "--- bar\n"
+ "\n"
+ "-- asd\n"
+ "\n"
+ "--- lol\n", &l, &d);
assert_non_null(html);
assert_int_equal(l, 0);
+ assert_non_null(d);
+ assert_string_equal(d, "bola");
assert_string_equal(html,
"<h1 id=\"um\">um</h1>\n"
"<h2 id=\"dois\">dois</h2>\n"
@@ -151,8 +160,13 @@ test_content_parse(void **state)
"</style>\n"
"<p>guda\n"
"yay</p>\n"
- "<p><strong>bola</strong></p>\n");
+ "<p><strong>bola</strong>\n"
+ "&ndash; foo-bar\n"
+ "&mdash; bar</p>\n"
+ "<p>&ndash; asd</p>\n"
+ "<p>&mdash; lol</p>\n");
free(html);
+ free(d);
}
@@ -160,6 +174,7 @@ static void
test_content_parse_crlf(void **state)
{
size_t l = 0;
+ char *d = NULL;
char *html = blogc_content_parse(
"# um\r\n"
"## dois\r\n"
@@ -195,9 +210,17 @@ test_content_parse_crlf(void **state)
"guda\r\n"
"yay\r\n"
"\r\n"
- "**bola**\r\n", &l);
+ "**bola**\r\n"
+ "-- foo-bar\r\n"
+ "--- bar\r\n"
+ "\r\n"
+ "-- asd\r\n"
+ "\r\n"
+ "--- lol\r\n", &l, &d);
assert_non_null(html);
assert_int_equal(l, 0);
+ assert_non_null(d);
+ assert_string_equal(d, "bola");
assert_string_equal(html,
"<h1 id=\"um\">um</h1>\r\n"
"<h2 id=\"dois\">dois</h2>\r\n"
@@ -229,8 +252,13 @@ test_content_parse_crlf(void **state)
"</style>\r\n"
"<p>guda\r\n"
"yay</p>\r\n"
- "<p><strong>bola</strong></p>\r\n");
+ "<p><strong>bola</strong>\r\n"
+ "&ndash; foo-bar\r\n"
+ "&mdash; bar</p>\r\n"
+ "<p>&ndash; asd</p>\r\n"
+ "<p>&mdash; lol</p>\r\n");
free(html);
+ free(d);
}
@@ -238,6 +266,7 @@ static void
test_content_parse_with_excerpt(void **state)
{
size_t l = 0;
+ char *d = NULL;
char *html = blogc_content_parse(
"# test\n"
"\n"
@@ -246,9 +275,11 @@ test_content_parse_with_excerpt(void **state)
"..\n"
"\n"
"guda\n"
- "lol", &l);
+ "lol", &l, &d);
assert_non_null(html);
assert_int_equal(l, 38);
+ assert_non_null(d);
+ assert_string_equal(d, "chunda");
assert_string_equal(html,
"<h1 id=\"test\">test</h1>\n"
"<p>chunda</p>\n"
@@ -256,6 +287,8 @@ test_content_parse_with_excerpt(void **state)
"lol</p>\n");
free(html);
l = 0;
+ free(d);
+ d = NULL;
html = blogc_content_parse(
"# test\n"
"\n"
@@ -264,15 +297,18 @@ test_content_parse_with_excerpt(void **state)
"...\n"
"\n"
"guda\n"
- "lol", &l);
+ "lol", &l, &d);
assert_non_null(html);
assert_int_equal(l, 38);
+ assert_non_null(d);
+ assert_string_equal(d, "chunda");
assert_string_equal(html,
"<h1 id=\"test\">test</h1>\n"
"<p>chunda</p>\n"
"<p>guda\n"
"lol</p>\n");
free(html);
+ free(d);
}
@@ -280,6 +316,7 @@ static void
test_content_parse_with_excerpt_crlf(void **state)
{
size_t l = 0;
+ char *d = NULL;
char *html = blogc_content_parse(
"# test\r\n"
"\r\n"
@@ -288,9 +325,11 @@ test_content_parse_with_excerpt_crlf(void **state)
"..\r\n"
"\r\n"
"guda\r\n"
- "lol", &l);
+ "lol", &l, &d);
assert_non_null(html);
assert_int_equal(l, 40);
+ assert_non_null(d);
+ assert_string_equal(d, "chunda");
assert_string_equal(html,
"<h1 id=\"test\">test</h1>\r\n"
"<p>chunda</p>\r\n"
@@ -298,6 +337,8 @@ test_content_parse_with_excerpt_crlf(void **state)
"lol</p>\r\n");
free(html);
l = 0;
+ free(d);
+ d = NULL;
html = blogc_content_parse(
"# test\r\n"
"\r\n"
@@ -306,26 +347,29 @@ test_content_parse_with_excerpt_crlf(void **state)
"...\r\n"
"\r\n"
"guda\r\n"
- "lol", &l);
+ "lol", &l, &d);
assert_non_null(html);
assert_int_equal(l, 40);
+ assert_non_null(d);
+ assert_string_equal(d, "chunda");
assert_string_equal(html,
"<h1 id=\"test\">test</h1>\r\n"
"<p>chunda</p>\r\n"
"<p>guda\r\n"
"lol</p>\r\n");
free(html);
+ free(d);
}
static void
test_content_parse_header(void **state)
{
- char *html = blogc_content_parse("## bola", NULL);
+ char *html = blogc_content_parse("## bola", NULL, NULL);
assert_non_null(html);
assert_string_equal(html, "<h2 id=\"bola\">bola</h2>\n");
free(html);
- html = blogc_content_parse("## bola\n", NULL);
+ html = blogc_content_parse("## bola\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html, "<h2 id=\"bola\">bola</h2>\n");
free(html);
@@ -334,7 +378,7 @@ test_content_parse_header(void **state)
"\n"
"## bola\n"
"\n"
- "guda\n", NULL);
+ "guda\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>bola</p>\n"
@@ -347,11 +391,11 @@ test_content_parse_header(void **state)
static void
test_content_parse_header_crlf(void **state)
{
- char *html = blogc_content_parse("## bola", NULL);
+ char *html = blogc_content_parse("## bola", NULL, NULL);
assert_non_null(html);
assert_string_equal(html, "<h2 id=\"bola\">bola</h2>\n");
free(html);
- html = blogc_content_parse("## bola\r\n", NULL);
+ html = blogc_content_parse("## bola\r\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html, "<h2 id=\"bola\">bola</h2>\r\n");
free(html);
@@ -360,7 +404,7 @@ test_content_parse_header_crlf(void **state)
"\r\n"
"## bola\r\n"
"\r\n"
- "guda\r\n", NULL);
+ "guda\r\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>bola</p>\r\n"
@@ -373,11 +417,11 @@ test_content_parse_header_crlf(void **state)
static void
test_content_parse_html(void **state)
{
- char *html = blogc_content_parse("<div>\n</div>", NULL);
+ char *html = blogc_content_parse("<div>\n</div>", NULL, NULL);
assert_non_null(html);
assert_string_equal(html, "<div>\n</div>\n");
free(html);
- html = blogc_content_parse("<div>\n</div>\n", NULL);
+ html = blogc_content_parse("<div>\n</div>\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html, "<div>\n</div>\n");
free(html);
@@ -387,7 +431,7 @@ test_content_parse_html(void **state)
"<div>\n"
"</div>\n"
"\n"
- "chunda\n", NULL);
+ "chunda\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>bola</p>\n"
@@ -400,11 +444,11 @@ test_content_parse_html(void **state)
static void
test_content_parse_html_crlf(void **state)
{
- char *html = blogc_content_parse("<div>\r\n</div>", NULL);
+ char *html = blogc_content_parse("<div>\r\n</div>", NULL, NULL);
assert_non_null(html);
assert_string_equal(html, "<div>\r\n</div>\r\n");
free(html);
- html = blogc_content_parse("<div>\r\n</div>\r\n", NULL);
+ html = blogc_content_parse("<div>\r\n</div>\r\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html, "<div>\r\n</div>\r\n");
free(html);
@@ -414,7 +458,7 @@ test_content_parse_html_crlf(void **state)
"<div>\r\n"
"</div>\r\n"
"\r\n"
- "chunda\r\n", NULL);
+ "chunda\r\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>bola</p>\r\n"
@@ -427,14 +471,14 @@ test_content_parse_html_crlf(void **state)
static void
test_content_parse_blockquote(void **state)
{
- char *html = blogc_content_parse("> bola\n> guda", NULL);
+ char *html = blogc_content_parse("> bola\n> guda", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<blockquote><p>bola\n"
"guda</p>\n"
"</blockquote>\n");
free(html);
- html = blogc_content_parse("> bola\n> guda\n", NULL);
+ html = blogc_content_parse("> bola\n> guda\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<blockquote><p>bola\n"
@@ -445,9 +489,22 @@ test_content_parse_blockquote(void **state)
"bola\n"
"\n"
"> bola\n"
+ "\n"
+ "chunda\n", NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<p>bola</p>\n"
+ "<blockquote><p>bola</p>\n"
+ "</blockquote>\n"
+ "<p>chunda</p>\n");
+ free(html);
+ html = blogc_content_parse(
+ "bola\n"
+ "\n"
+ "> bola\n"
"> guda\n"
"\n"
- "chunda\n", NULL);
+ "chunda\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>bola</p>\n"
@@ -462,14 +519,14 @@ test_content_parse_blockquote(void **state)
static void
test_content_parse_blockquote_crlf(void **state)
{
- char *html = blogc_content_parse("> bola\r\n> guda", NULL);
+ char *html = blogc_content_parse("> bola\r\n> guda", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<blockquote><p>bola\r\n"
"guda</p>\r\n"
"</blockquote>\r\n");
free(html);
- html = blogc_content_parse("> bola\r\n> guda\r\n", NULL);
+ html = blogc_content_parse("> bola\r\n> guda\r\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<blockquote><p>bola\r\n"
@@ -480,9 +537,22 @@ test_content_parse_blockquote_crlf(void **state)
"bola\r\n"
"\r\n"
"> bola\r\n"
+ "\r\n"
+ "chunda\r\n", NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<p>bola</p>\r\n"
+ "<blockquote><p>bola</p>\r\n"
+ "</blockquote>\r\n"
+ "<p>chunda</p>\r\n");
+ free(html);
+ html = blogc_content_parse(
+ "bola\r\n"
+ "\r\n"
+ "> bola\r\n"
"> guda\r\n"
"\r\n"
- "chunda\r\n", NULL);
+ "chunda\r\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>bola</p>\r\n"
@@ -497,13 +567,13 @@ test_content_parse_blockquote_crlf(void **state)
static void
test_content_parse_code(void **state)
{
- char *html = blogc_content_parse(" bola\n guda", NULL);
+ char *html = blogc_content_parse(" bola\n guda", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<pre><code>bola\n"
"guda</code></pre>\n");
free(html);
- html = blogc_content_parse(" bola\n guda\n", NULL);
+ html = blogc_content_parse(" bola\n guda\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<pre><code>bola\n"
@@ -515,7 +585,7 @@ test_content_parse_code(void **state)
" bola\n"
" guda\n"
"\n"
- "chunda\n", NULL);
+ "chunda\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>bola</p>\n"
@@ -529,13 +599,13 @@ test_content_parse_code(void **state)
static void
test_content_parse_code_crlf(void **state)
{
- char *html = blogc_content_parse(" bola\r\n guda", NULL);
+ char *html = blogc_content_parse(" bola\r\n guda", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<pre><code>bola\r\n"
"guda</code></pre>\r\n");
free(html);
- html = blogc_content_parse(" bola\r\n guda\r\n", NULL);
+ html = blogc_content_parse(" bola\r\n guda\r\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<pre><code>bola\r\n"
@@ -547,7 +617,7 @@ test_content_parse_code_crlf(void **state)
" bola\r\n"
" guda\r\n"
"\r\n"
- "chunda\r\n", NULL);
+ "chunda\r\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>bola</p>\r\n"
@@ -561,28 +631,28 @@ test_content_parse_code_crlf(void **state)
static void
test_content_parse_horizontal_rule(void **state)
{
- char *html = blogc_content_parse("bola\nguda\n\n**", NULL);
+ char *html = blogc_content_parse("bola\nguda\n\n**", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>bola\n"
"guda</p>\n"
"<hr />\n");
free(html);
- html = blogc_content_parse("bola\nguda\n\n++++", NULL);
+ html = blogc_content_parse("bola\nguda\n\n++++", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>bola\n"
"guda</p>\n"
"<hr />\n");
free(html);
- html = blogc_content_parse("bola\nguda\n\n--\n", NULL);
+ html = blogc_content_parse("bola\nguda\n\n--\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>bola\n"
"guda</p>\n"
"<hr />\n");
free(html);
- html = blogc_content_parse("bola\nguda\n\n****\n", NULL);
+ html = blogc_content_parse("bola\nguda\n\n****\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>bola\n"
@@ -594,7 +664,7 @@ test_content_parse_horizontal_rule(void **state)
"\n"
"**\n"
"\n"
- "chunda\n", NULL);
+ "chunda\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>bola</p>\n"
@@ -606,7 +676,7 @@ test_content_parse_horizontal_rule(void **state)
"\n"
"----\n"
"\n"
- "chunda\n", NULL);
+ "chunda\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>bola</p>\n"
@@ -619,28 +689,28 @@ test_content_parse_horizontal_rule(void **state)
static void
test_content_parse_horizontal_rule_crlf(void **state)
{
- char *html = blogc_content_parse("bola\r\nguda\r\n\r\n**", NULL);
+ char *html = blogc_content_parse("bola\r\nguda\r\n\r\n**", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>bola\r\n"
"guda</p>\r\n"
"<hr />\r\n");
free(html);
- html = blogc_content_parse("bola\r\nguda\r\n\r\n++++", NULL);
+ html = blogc_content_parse("bola\r\nguda\r\n\r\n++++", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>bola\r\n"
"guda</p>\r\n"
"<hr />\r\n");
free(html);
- html = blogc_content_parse("bola\r\nguda\r\n\r\n--\r\n", NULL);
+ html = blogc_content_parse("bola\r\nguda\r\n\r\n--\r\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>bola\r\n"
"guda</p>\r\n"
"<hr />\r\n");
free(html);
- html = blogc_content_parse("bola\r\nguda\r\n\r\n****\r\n", NULL);
+ html = blogc_content_parse("bola\r\nguda\r\n\r\n****\r\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>bola\r\n"
@@ -652,7 +722,7 @@ test_content_parse_horizontal_rule_crlf(void **state)
"\r\n"
"**\r\n"
"\r\n"
- "chunda\r\n", NULL);
+ "chunda\r\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>bola</p>\r\n"
@@ -664,7 +734,7 @@ test_content_parse_horizontal_rule_crlf(void **state)
"\r\n"
"----\r\n"
"\r\n"
- "chunda\r\n", NULL);
+ "chunda\r\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>bola</p>\r\n"
@@ -682,7 +752,7 @@ test_content_parse_unordered_list(void **state)
"\n"
"* asd\n"
"* qwe\n"
- "* zxc", NULL);
+ "* zxc", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>lol</p>\n"
@@ -697,7 +767,7 @@ test_content_parse_unordered_list(void **state)
"\n"
"* asd\n"
"* qwe\n"
- "* zxc\n", NULL);
+ "* zxc\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>lol</p>\n"
@@ -714,7 +784,7 @@ test_content_parse_unordered_list(void **state)
"* qwe\n"
"* zxc\n"
"\n"
- "fuuuu\n", NULL);
+ "fuuuu\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>lol</p>\n"
@@ -734,7 +804,7 @@ test_content_parse_unordered_list(void **state)
"* zxc\n"
" 1234\n"
"\n"
- "fuuuu\n", NULL);
+ "fuuuu\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>lol</p>\n"
@@ -750,7 +820,7 @@ test_content_parse_unordered_list(void **state)
html = blogc_content_parse(
"* asd\n"
"* qwe\n"
- "* zxc", NULL);
+ "* zxc", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<ul>\n"
@@ -770,7 +840,7 @@ test_content_parse_unordered_list_crlf(void **state)
"\r\n"
"* asd\r\n"
"* qwe\r\n"
- "* zxc", NULL);
+ "* zxc", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>lol</p>\r\n"
@@ -785,7 +855,7 @@ test_content_parse_unordered_list_crlf(void **state)
"\r\n"
"* asd\r\n"
"* qwe\r\n"
- "* zxc\r\n", NULL);
+ "* zxc\r\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>lol</p>\r\n"
@@ -802,7 +872,7 @@ test_content_parse_unordered_list_crlf(void **state)
"* qwe\r\n"
"* zxc\r\n"
"\r\n"
- "fuuuu\r\n", NULL);
+ "fuuuu\r\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>lol</p>\r\n"
@@ -822,7 +892,7 @@ test_content_parse_unordered_list_crlf(void **state)
"* zxc\r\n"
" 1234\r\n"
"\r\n"
- "fuuuu\r\n", NULL);
+ "fuuuu\r\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>lol</p>\r\n"
@@ -838,7 +908,7 @@ test_content_parse_unordered_list_crlf(void **state)
html = blogc_content_parse(
"* asd\r\n"
"* qwe\r\n"
- "* zxc", NULL);
+ "* zxc", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<ul>\r\n"
@@ -858,7 +928,7 @@ test_content_parse_ordered_list(void **state)
"\n"
"1. asd\n"
"2. qwe\n"
- "3. zxc", NULL);
+ "3. zxc", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>lol</p>\n"
@@ -873,7 +943,7 @@ test_content_parse_ordered_list(void **state)
"\n"
"1. asd\n"
"2. qwe\n"
- "3. zxc\n", NULL);
+ "3. zxc\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>lol</p>\n"
@@ -890,7 +960,7 @@ test_content_parse_ordered_list(void **state)
"2. qwe\n"
"3. zxc\n"
"\n"
- "fuuuu\n", NULL);
+ "fuuuu\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>lol</p>\n"
@@ -910,7 +980,7 @@ test_content_parse_ordered_list(void **state)
"3. zxc\n"
" 1234\n"
"\n"
- "fuuuu\n", NULL);
+ "fuuuu\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>lol</p>\n"
@@ -926,7 +996,7 @@ test_content_parse_ordered_list(void **state)
html = blogc_content_parse(
"1. asd\n"
"2. qwe\n"
- "3. zxc", NULL);
+ "3. zxc", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<ol>\n"
@@ -946,7 +1016,7 @@ test_content_parse_ordered_list_crlf(void **state)
"\r\n"
"1. asd\r\n"
"2. qwe\r\n"
- "3. zxc", NULL);
+ "3. zxc", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>lol</p>\r\n"
@@ -961,7 +1031,7 @@ test_content_parse_ordered_list_crlf(void **state)
"\r\n"
"1. asd\r\n"
"2. qwe\r\n"
- "3. zxc\r\n", NULL);
+ "3. zxc\r\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>lol</p>\r\n"
@@ -978,7 +1048,7 @@ test_content_parse_ordered_list_crlf(void **state)
"2. qwe\r\n"
"3. zxc\r\n"
"\r\n"
- "fuuuu\r\n", NULL);
+ "fuuuu\r\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>lol</p>\r\n"
@@ -998,7 +1068,7 @@ test_content_parse_ordered_list_crlf(void **state)
"3. zxc\r\n"
" 1234\r\n"
"\r\n"
- "fuuuu\r\n", NULL);
+ "fuuuu\r\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>lol</p>\r\n"
@@ -1014,7 +1084,7 @@ test_content_parse_ordered_list_crlf(void **state)
html = blogc_content_parse(
"1. asd\r\n"
"2. qwe\r\n"
- "3. zxc", NULL);
+ "3. zxc", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<ol>\r\n"
@@ -1037,15 +1107,15 @@ __wrap_blogc_directive_loader(blogc_directive_ctx_t *ctx, blogc_error_t **err)
assert_null(ctx->argument);
else
assert_string_equal(ctx->argument, arg);
- assert_int_equal(b_trie_size(ctx->params), mock_type(unsigned int));
+ assert_int_equal(sb_trie_size(ctx->params), mock_type(unsigned int));
- for (unsigned int i = 0; i < b_trie_size(ctx->params); i++) {
+ for (unsigned int i = 0; i < sb_trie_size(ctx->params); i++) {
const char *key = mock_type(const char*);
const char *value = mock_type(const char*);
- assert_string_equal(b_trie_lookup(ctx->params, key), value);
+ assert_string_equal(sb_trie_lookup(ctx->params, key), value);
}
- return b_strdup("CHUNDA\n");
+ return sb_strdup("CHUNDA\n");
}
@@ -1057,7 +1127,7 @@ test_content_parse_directive(void **state)
will_return(__wrap_blogc_directive_loader, 0);
char *html = blogc_content_parse(
".. bola::",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"CHUNDA\n");
@@ -1068,7 +1138,7 @@ test_content_parse_directive(void **state)
will_return(__wrap_blogc_directive_loader, 0);
html = blogc_content_parse(
".. bola::\n",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"CHUNDA\n");
@@ -1079,7 +1149,7 @@ test_content_parse_directive(void **state)
will_return(__wrap_blogc_directive_loader, 0);
html = blogc_content_parse(
".. bola:: ",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"CHUNDA\n");
@@ -1090,7 +1160,7 @@ test_content_parse_directive(void **state)
will_return(__wrap_blogc_directive_loader, 0);
html = blogc_content_parse(
".. bola:: \n",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"CHUNDA\n");
@@ -1101,7 +1171,7 @@ test_content_parse_directive(void **state)
will_return(__wrap_blogc_directive_loader, 0);
html = blogc_content_parse(
".. bola::\r\n",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"CHUNDA\n");
@@ -1115,7 +1185,7 @@ test_content_parse_directive(void **state)
html = blogc_content_parse(
".. bola::\n"
" :asd: qwe",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"CHUNDA\n");
@@ -1129,7 +1199,7 @@ test_content_parse_directive(void **state)
html = blogc_content_parse(
".. bola::\n"
" :asd: qwe\n",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"CHUNDA\n");
@@ -1143,7 +1213,7 @@ test_content_parse_directive(void **state)
html = blogc_content_parse(
".. bola::\r\n"
"\t:asd: qwe\r\n",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"CHUNDA\n");
@@ -1160,7 +1230,7 @@ test_content_parse_directive(void **state)
".. bola::\n"
"\t\t:asd: qwe\n"
"\t\t:zxc: vbn",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"CHUNDA\n");
@@ -1177,7 +1247,7 @@ test_content_parse_directive(void **state)
".. bola::\n"
" :asd: qwe\n"
" :zxc: vbn\n",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"CHUNDA\n");
@@ -1194,7 +1264,7 @@ test_content_parse_directive(void **state)
".. bola::\r\n"
" :asd: qwe\r\n"
" :zxc: vbn\r\n",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"CHUNDA\n");
@@ -1217,7 +1287,7 @@ test_content_parse_directive(void **state)
" :ert: zxvc\n"
" :qwe: bola\n"
"\n"
- "bola", NULL);
+ "bola", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<h1 id=\"foo\">foo</h1>\n"
@@ -1242,7 +1312,7 @@ test_content_parse_directive(void **state)
" :ert: zxvc\r\n"
" :qwe: bola\r\n"
"\r\n"
- "bola", NULL);
+ "bola", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<h1 id=\"foo\">foo</h1>\r\n"
@@ -1261,7 +1331,7 @@ test_content_parse_directive(void **state)
"\n"
".. bola::\n"
"\n"
- ".. bola::", NULL);
+ ".. bola::", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<h1 id=\"foo\">foo</h1>\n"
@@ -1280,7 +1350,7 @@ test_content_parse_directive(void **state)
"\n"
".. bola:: asd\n"
"\n"
- ".. bola:: asd\n", NULL);
+ ".. bola:: asd\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<h1 id=\"foo\">foo</h1>\n"
@@ -1299,7 +1369,7 @@ test_content_parse_directive(void **state)
"\r\n"
".. bola::\r\n"
"\r\n"
- ".. bola::\r\n", NULL);
+ ".. bola::\r\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<h1 id=\"foo\">foo</h1>\r\n"
@@ -1321,7 +1391,7 @@ test_content_parse_directive(void **state)
".. bola::\n"
" :asd: qwe\n"
"\n"
- ".. bola::", NULL);
+ ".. bola::", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<h1 id=\"foo\">foo</h1>\n"
@@ -1343,7 +1413,7 @@ test_content_parse_directive(void **state)
".. bola:: asd\n"
" :asd: qwe\n"
"\n"
- ".. bola:: asd\n", NULL);
+ ".. bola:: asd\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<h1 id=\"foo\">foo</h1>\n"
@@ -1365,7 +1435,7 @@ test_content_parse_directive(void **state)
".. bola::\n"
" :asd: qwe\n"
"\n"
- ".. bola::\n", NULL);
+ ".. bola::\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<h1 id=\"foo\">foo</h1>\n"
@@ -1387,7 +1457,7 @@ test_content_parse_directive(void **state)
".. bola::\r\n"
" :asd: qwe\r\n"
"\r\n"
- ".. bola::\r\n", NULL);
+ ".. bola::\r\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<h1 id=\"foo\">foo</h1>\r\n"
@@ -1412,7 +1482,7 @@ test_content_parse_directive(void **state)
" :asd: qwe\n"
"\n"
".. bola::\n"
- " :asd: zxc\n", NULL);
+ " :asd: zxc\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<h1 id=\"foo\">foo</h1>\n"
@@ -1437,7 +1507,7 @@ test_content_parse_directive(void **state)
" :asd: qwe\r\n"
"\r\n"
".. bola::\r\n"
- " :asd: zxc\r\n", NULL);
+ " :asd: zxc\r\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<h1 id=\"foo\">foo</h1>\r\n"
@@ -1468,7 +1538,7 @@ test_content_parse_directive(void **state)
"\n"
".. bola::\n"
" :asd: qwe\n"
- " :qwe: 456", NULL);
+ " :qwe: 456", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<h1 id=\"foo\">foo</h1>\n"
@@ -1499,7 +1569,7 @@ test_content_parse_directive(void **state)
"\n"
".. bola:: asd\n"
" :asd: qwe\n"
- " :qwe: 456\n", NULL);
+ " :qwe: 456\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<h1 id=\"foo\">foo</h1>\n"
@@ -1530,7 +1600,7 @@ test_content_parse_directive(void **state)
"\n"
".. bola::\n"
" :asd: qwe\n"
- " :qwe: 456\n", NULL);
+ " :qwe: 456\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<h1 id=\"foo\">foo</h1>\n"
@@ -1561,7 +1631,7 @@ test_content_parse_directive(void **state)
"\r\n"
".. bola::\r\n"
" :asd: qwe\r\n"
- " :qwe: 456\r\n", NULL);
+ " :qwe: 456\r\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<h1 id=\"foo\">foo</h1>\r\n"
@@ -1574,7 +1644,7 @@ test_content_parse_directive(void **state)
will_return(__wrap_blogc_directive_loader, 0);
html = blogc_content_parse(
".. bola:: chunda",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"CHUNDA\n");
@@ -1585,7 +1655,7 @@ test_content_parse_directive(void **state)
will_return(__wrap_blogc_directive_loader, 0);
html = blogc_content_parse(
".. bola:: chunda\n",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"CHUNDA\n");
@@ -1596,7 +1666,7 @@ test_content_parse_directive(void **state)
will_return(__wrap_blogc_directive_loader, 0);
html = blogc_content_parse(
".. bola:: chunda\r\n",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"CHUNDA\n");
@@ -1610,7 +1680,7 @@ test_content_parse_directive(void **state)
html = blogc_content_parse(
".. bola:: chunda\n"
" :asd: qwe",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"CHUNDA\n");
@@ -1624,7 +1694,7 @@ test_content_parse_directive(void **state)
html = blogc_content_parse(
".. bola:: chunda\n"
" :asd: qwe\n",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"CHUNDA\n");
@@ -1638,7 +1708,7 @@ test_content_parse_directive(void **state)
html = blogc_content_parse(
".. bola:: chunda\r\n"
" :asd: qwe\r\n",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"CHUNDA\n");
@@ -1655,7 +1725,7 @@ test_content_parse_directive(void **state)
".. bola:: chunda\n"
" :asd: qwe\n"
" :zxc: vbn",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"CHUNDA\n");
@@ -1672,7 +1742,7 @@ test_content_parse_directive(void **state)
".. bola:: chunda\n"
" :asd: qwe\n"
" :zxc: vbn\n",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"CHUNDA\n");
@@ -1689,7 +1759,7 @@ test_content_parse_directive(void **state)
".. bola:: chunda\r\n"
" :asd: qwe\r\n"
" :zxc: vbn\r\n",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"CHUNDA\n");
@@ -1712,7 +1782,7 @@ test_content_parse_directive(void **state)
" :ert: zxvc\n"
" :qwe: bola\n"
"\n"
- "bola", NULL);
+ "bola", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<h1 id=\"foo\">foo</h1>\n"
@@ -1737,7 +1807,7 @@ test_content_parse_directive(void **state)
" :ert: zxvc\r\n"
" :qwe: bola\r\n"
"\r\n"
- "bola", NULL);
+ "bola", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<h1 id=\"foo\">foo</h1>\r\n"
@@ -1773,7 +1843,7 @@ test_content_parse_directive(void **state)
" :asd: qwe\r\n"
" :ert: zxvc\r\n"
"\r\n"
- "bola", NULL);
+ "bola", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<h1 id=\"foo\">foo</h1>\r\n"
@@ -1785,9 +1855,176 @@ test_content_parse_directive(void **state)
static void
+test_content_parse_description(void **state)
+{
+ char *d = NULL;
+ char *html = blogc_content_parse(
+ "# foo\n"
+ "\n"
+ "bar", NULL, &d);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\n"
+ "<p>bar</p>\n");
+ assert_non_null(d);
+ assert_string_equal(d, "bar");
+ free(html);
+ free(d);
+ d = NULL;
+ html = blogc_content_parse(
+ "# foo\n"
+ "\n"
+ "bar\n", NULL, &d);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\n"
+ "<p>bar</p>\n");
+ assert_non_null(d);
+ assert_string_equal(d, "bar");
+ free(html);
+ free(d);
+ d = NULL;
+ html = blogc_content_parse(
+ "# foo\n"
+ "\n"
+ "qwe\n"
+ "bar\n", NULL, &d);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\n"
+ "<p>qwe\n"
+ "bar</p>\n");
+ assert_non_null(d);
+ assert_string_equal(d, "qwe");
+ free(html);
+ free(d);
+ d = NULL;
+ html = blogc_content_parse(
+ "# foo\n"
+ "\n"
+ "> qwe\n"
+ "\n"
+ "bar\n", NULL, &d);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\n"
+ "<blockquote><p>qwe</p>\n"
+ "</blockquote>\n"
+ "<p>bar</p>\n");
+ assert_non_null(d);
+ assert_string_equal(d, "qwe");
+ free(html);
+ free(d);
+ d = NULL;
+ html = blogc_content_parse(
+ "# foo\n"
+ "\n"
+ "> qwe\n"
+ "> zxc\n"
+ "\n"
+ "bar\n", NULL, &d);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\n"
+ "<blockquote><p>qwe\n"
+ "zxc</p>\n"
+ "</blockquote>\n"
+ "<p>bar</p>\n");
+ assert_non_null(d);
+ assert_string_equal(d, "qwe");
+ free(html);
+ free(d);
+}
+
+
+static void
+test_content_parse_description_crlf(void **state)
+{
+ char *d = NULL;
+ char *html = blogc_content_parse(
+ "# foo\r\n"
+ "\r\n"
+ "bar", NULL, &d);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\r\n"
+ "<p>bar</p>\r\n");
+ assert_non_null(d);
+ assert_string_equal(d, "bar");
+ free(html);
+ free(d);
+ d = NULL;
+ html = blogc_content_parse(
+ "# foo\r\n"
+ "\r\n"
+ "bar\r\n", NULL, &d);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\r\n"
+ "<p>bar</p>\r\n");
+ assert_non_null(d);
+ assert_string_equal(d, "bar");
+ free(html);
+ free(d);
+ d = NULL;
+ html = blogc_content_parse(
+ "# foo\r\n"
+ "\r\n"
+ "qwe\r\n"
+ "bar\r\n", NULL, &d);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\r\n"
+ "<p>qwe\r\n"
+ "bar</p>\r\n");
+ assert_non_null(d);
+ assert_string_equal(d, "qwe");
+ free(html);
+ free(d);
+ d = NULL;
+ html = blogc_content_parse(
+ "# foo\r\n"
+ "\r\n"
+ "> qwe\r\n"
+ "\r\n"
+ "bar\r\n", NULL, &d);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\r\n"
+ "<blockquote><p>qwe</p>\r\n"
+ "</blockquote>\r\n"
+ "<p>bar</p>\r\n");
+ assert_non_null(d);
+ assert_string_equal(d, "qwe");
+ free(html);
+ free(d);
+ d = NULL;
+ html = blogc_content_parse(
+ "# foo\r\n"
+ "\r\n"
+ "> qwe\r\n"
+ "> zxc\r\n"
+ "\r\n"
+ "bar\r\n", NULL, &d);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\r\n"
+ "<blockquote><p>qwe\r\n"
+ "zxc</p>\r\n"
+ "</blockquote>\r\n"
+ "<p>bar</p>\r\n");
+ assert_non_null(d);
+ assert_string_equal(d, "qwe");
+ free(html);
+ free(d);
+}
+
+
+static void
test_content_parse_invalid_excerpt(void **state)
{
size_t l = 0;
+ char *d = NULL;
char *html = blogc_content_parse(
"# test\n"
"\n"
@@ -1795,9 +2032,11 @@ test_content_parse_invalid_excerpt(void **state)
"..\n"
"\n"
"guda\n"
- "lol", &l);
+ "lol", &l, &d);
assert_non_null(html);
assert_int_equal(l, 0);
+ assert_non_null(d);
+ assert_string_equal(d, "chunda");
assert_string_equal(html,
"<h1 id=\"test\">test</h1>\n"
"<p>chunda\n"
@@ -1806,6 +2045,8 @@ test_content_parse_invalid_excerpt(void **state)
"lol</p>\n");
free(html);
l = 0;
+ free(d);
+ d = NULL;
html = blogc_content_parse(
"# test\n"
"\n"
@@ -1813,9 +2054,11 @@ test_content_parse_invalid_excerpt(void **state)
"\n"
"...\n"
"guda\n"
- "lol", &l);
+ "lol", &l, &d);
assert_non_null(html);
assert_int_equal(l, 0);
+ assert_non_null(d);
+ assert_string_equal(d, "chunda");
assert_string_equal(html,
"<h1 id=\"test\">test</h1>\n"
"<p>chunda</p>\n"
@@ -1824,15 +2067,19 @@ test_content_parse_invalid_excerpt(void **state)
"lol</p>\n");
free(html);
l = 0;
+ free(d);
+ d = NULL;
html = blogc_content_parse(
"# test\n"
"\n"
"chunda..\n"
"\n"
"guda\n"
- "lol", &l);
+ "lol", &l, &d);
assert_non_null(html);
assert_int_equal(l, 0);
+ assert_non_null(d);
+ assert_string_equal(d, "chunda..");
assert_string_equal(html,
"<h1 id=\"test\">test</h1>\n"
"<p>chunda..</p>\n"
@@ -1840,21 +2087,26 @@ test_content_parse_invalid_excerpt(void **state)
"lol</p>\n");
free(html);
l = 0;
+ free(d);
+ d = NULL;
html = blogc_content_parse(
"# test\n"
"\n"
"chunda\n"
"\n"
"...guda\n"
- "lol", &l);
+ "lol", &l, &d);
assert_non_null(html);
assert_int_equal(l, 0);
+ assert_non_null(d);
+ assert_string_equal(d, "chunda");
assert_string_equal(html,
"<h1 id=\"test\">test</h1>\n"
"<p>chunda</p>\n"
"<p>...guda\n"
"lol</p>\n");
free(html);
+ free(d);
}
@@ -1864,7 +2116,7 @@ test_content_parse_invalid_header(void **state)
char *html = blogc_content_parse(
"asd\n"
"\n"
- "##bola\n", NULL);
+ "##bola\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>asd</p>\n"
@@ -1881,7 +2133,7 @@ test_content_parse_invalid_header_empty(void **state)
"\n"
"##\n"
"\n"
- "qwe\n", NULL);
+ "qwe\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>asd</p>\n"
@@ -1898,7 +2150,7 @@ test_content_parse_invalid_blockquote(void **state)
char *html = blogc_content_parse(
"> asd\n"
"> bola\n"
- "> foo\n", NULL);
+ "> foo\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>&gt; asd\n"
@@ -1907,7 +2159,7 @@ test_content_parse_invalid_blockquote(void **state)
free(html);
html = blogc_content_parse(
"> asd\n"
- "> bola", NULL);
+ "> bola", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>&gt; asd\n"
@@ -1922,7 +2174,7 @@ test_content_parse_invalid_code(void **state)
char *html = blogc_content_parse(
" asd\n"
" bola\n"
- " foo\n", NULL);
+ " foo\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p> asd\n"
@@ -1932,7 +2184,7 @@ test_content_parse_invalid_code(void **state)
html = blogc_content_parse(
" asd\n"
" bola\n"
- " foo", NULL);
+ " foo", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p> asd\n"
@@ -1946,11 +2198,11 @@ static void
test_content_parse_invalid_horizontal_rule(void **state)
{
// this generates invalid html, but...
- char *html = blogc_content_parse("** asd", NULL);
+ char *html = blogc_content_parse("** asd", NULL, NULL);
assert_non_null(html);
assert_string_equal(html, "<p><strong> asd</p>\n");
free(html);
- html = blogc_content_parse("** asd\n", NULL);
+ html = blogc_content_parse("** asd\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html, "<p><strong> asd</p>\n");
free(html);
@@ -1963,7 +2215,7 @@ test_content_parse_invalid_unordered_list(void **state)
// more invalid html
char *html = blogc_content_parse(
"* asd\n"
- "1. qwe", NULL);
+ "1. qwe", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p><em> asd\n"
@@ -1972,7 +2224,7 @@ test_content_parse_invalid_unordered_list(void **state)
html = blogc_content_parse(
"* asd\n"
"1. qwe\n"
- "\n", NULL);
+ "\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p><em> asd\n"
@@ -1980,7 +2232,7 @@ test_content_parse_invalid_unordered_list(void **state)
free(html);
html = blogc_content_parse(
"* asd\n"
- "1. qwe\n", NULL);
+ "1. qwe\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p><em> asd\n"
@@ -1989,7 +2241,7 @@ test_content_parse_invalid_unordered_list(void **state)
free(html);
html = blogc_content_parse(
"* asd\n"
- "1. qwe\n", NULL);
+ "1. qwe\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p><em> asd\n"
@@ -2002,7 +2254,7 @@ test_content_parse_invalid_unordered_list(void **state)
"* asd\n"
"1. qwe\n"
"\n"
- "poi\n", NULL);
+ "poi\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>chunda</p>\n"
@@ -2019,7 +2271,7 @@ test_content_parse_invalid_ordered_list(void **state)
// more invalid html
char *html = blogc_content_parse(
"1. asd\n"
- "* qwe", NULL);
+ "* qwe", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>1. asd\n"
@@ -2028,7 +2280,7 @@ test_content_parse_invalid_ordered_list(void **state)
html = blogc_content_parse(
"1. asd\n"
"* qwe\n"
- "\n", NULL);
+ "\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>1. asd\n"
@@ -2036,7 +2288,7 @@ test_content_parse_invalid_ordered_list(void **state)
free(html);
html = blogc_content_parse(
"1. asd\n"
- "* qwe\n", NULL);
+ "* qwe\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>1. asd\n"
@@ -2045,7 +2297,7 @@ test_content_parse_invalid_ordered_list(void **state)
free(html);
html = blogc_content_parse(
"1. asd\n"
- "* qwe\n", NULL);
+ "* qwe\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>1. asd\n"
@@ -2058,7 +2310,7 @@ test_content_parse_invalid_ordered_list(void **state)
"1. asd\n"
"* qwe\n"
"\n"
- "poi\n", NULL);
+ "poi\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>chunda</p>\n"
@@ -2068,7 +2320,7 @@ test_content_parse_invalid_ordered_list(void **state)
free(html);
html = blogc_content_parse(
"1 asd\n"
- "* qwe\n", NULL);
+ "* qwe\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>1 asd\n"
@@ -2076,7 +2328,7 @@ test_content_parse_invalid_ordered_list(void **state)
free(html);
html = blogc_content_parse(
"a. asd\n"
- "2. qwe\n", NULL);
+ "2. qwe\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>a. asd\n"
@@ -2084,18 +2336,18 @@ test_content_parse_invalid_ordered_list(void **state)
free(html);
html = blogc_content_parse(
"1.\nasd\n"
- "2. qwe\n", NULL);
+ "2. qwe\n", NULL, 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);
+ html = blogc_content_parse("1.\n", NULL, NULL);
assert_non_null(html);
assert_string_equal(html, "<p>1.</p>\n");
free(html);
- html = blogc_content_parse("1 ", NULL);
+ html = blogc_content_parse("1 ", NULL, NULL);
assert_non_null(html);
assert_string_equal(html, "<p>1 </p>\n");
free(html);
@@ -2107,7 +2359,7 @@ test_content_parse_invalid_directive(void **state)
{
char *html = blogc_content_parse(
".. ",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>.. </p>\n");
@@ -2115,7 +2367,7 @@ test_content_parse_invalid_directive(void **state)
html = blogc_content_parse(
".. \n",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>.. </p>\n");
@@ -2123,7 +2375,7 @@ test_content_parse_invalid_directive(void **state)
html = blogc_content_parse(
".. ",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>.. <br /></p>\n");
@@ -2131,7 +2383,7 @@ test_content_parse_invalid_directive(void **state)
html = blogc_content_parse(
".. \n",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>.. <br /></p>\n");
@@ -2139,7 +2391,7 @@ test_content_parse_invalid_directive(void **state)
html = blogc_content_parse(
".. a",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>.. a</p>\n");
@@ -2147,7 +2399,7 @@ test_content_parse_invalid_directive(void **state)
html = blogc_content_parse(
".. a\n",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>.. a</p>\n");
@@ -2155,7 +2407,7 @@ test_content_parse_invalid_directive(void **state)
html = blogc_content_parse(
".. asd",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>.. asd</p>\n");
@@ -2163,7 +2415,7 @@ test_content_parse_invalid_directive(void **state)
html = blogc_content_parse(
".. asd\n",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>.. asd</p>\n");
@@ -2171,7 +2423,7 @@ test_content_parse_invalid_directive(void **state)
html = blogc_content_parse(
".. asd:",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>.. asd:</p>\n");
@@ -2179,7 +2431,7 @@ test_content_parse_invalid_directive(void **state)
html = blogc_content_parse(
".. asd:\n",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>.. asd:</p>\n");
@@ -2188,7 +2440,7 @@ test_content_parse_invalid_directive(void **state)
html = blogc_content_parse(
".. asd::\n"
" :",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>.. asd::\n"
@@ -2198,7 +2450,7 @@ test_content_parse_invalid_directive(void **state)
html = blogc_content_parse(
".. asd::\n"
" :\n",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>.. asd::\n"
@@ -2208,7 +2460,7 @@ test_content_parse_invalid_directive(void **state)
html = blogc_content_parse(
".. asd::\n"
" :a",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>.. asd::\n"
@@ -2218,7 +2470,7 @@ test_content_parse_invalid_directive(void **state)
html = blogc_content_parse(
".. asd::\n"
" :a\n",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>.. asd::\n"
@@ -2228,7 +2480,7 @@ test_content_parse_invalid_directive(void **state)
html = blogc_content_parse(
".. asd::\n"
" :as",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>.. asd::\n"
@@ -2238,7 +2490,7 @@ test_content_parse_invalid_directive(void **state)
html = blogc_content_parse(
".. asd::\n"
" :as\n",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>.. asd::\n"
@@ -2248,7 +2500,7 @@ test_content_parse_invalid_directive(void **state)
html = blogc_content_parse(
".. asd::\n"
" :as:",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>.. asd::\n"
@@ -2258,7 +2510,7 @@ test_content_parse_invalid_directive(void **state)
html = blogc_content_parse(
".. asd::\n"
" :as:\n",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>.. asd::\n"
@@ -2268,7 +2520,7 @@ test_content_parse_invalid_directive(void **state)
html = blogc_content_parse(
".. asd::\n"
" :as: ",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>.. asd::\n"
@@ -2278,7 +2530,7 @@ test_content_parse_invalid_directive(void **state)
html = blogc_content_parse(
".. asd::\n"
" :as: \n",
- NULL);
+ NULL, NULL);
assert_non_null(html);
assert_string_equal(html,
"<p>.. asd::\n"
@@ -2304,6 +2556,10 @@ test_content_parse_inline(void **state)
assert_non_null(html);
assert_string_equal(html, "<em>bola</em>");
free(html);
+ html = blogc_content_parse_inline("bola!");
+ assert_non_null(html);
+ assert_string_equal(html, "bola!");
+ free(html);
}
@@ -2419,10 +2675,22 @@ test_content_parse_inline_link(void **state)
assert_non_null(html);
assert_string_equal(html, "<a href=\"http://example.org/\">bola</a>\n");
free(html);
+ html = blogc_content_parse_inline("[bola!](http://example.org/)\n");
+ assert_non_null(html);
+ assert_string_equal(html, "<a href=\"http://example.org/\">bola!</a>\n");
+ free(html);
html = blogc_content_parse_inline("[bola]\n(http://example.org/)\n");
assert_non_null(html);
assert_string_equal(html, "<a href=\"http://example.org/\">bola</a>\n");
free(html);
+ html = blogc_content_parse_inline("[bola]\r\n(http://example.org/)\n");
+ assert_non_null(html);
+ assert_string_equal(html, "<a href=\"http://example.org/\">bola</a>\n");
+ free(html);
+ html = blogc_content_parse_inline("[bola] \r\n (http://example.org/)\n");
+ assert_non_null(html);
+ assert_string_equal(html, "<a href=\"http://example.org/\">bola</a>\n");
+ free(html);
html = blogc_content_parse_inline("[bo\nla](http://example.org/)\n");
assert_non_null(html);
assert_string_equal(html, "<a href=\"http://example.org/\">bo\nla</a>\n");
@@ -2435,6 +2703,16 @@ test_content_parse_inline_link(void **state)
assert_non_null(html);
assert_string_equal(html, "<a href=\"http://example.org/\"><code>bola(2)[3]**!\\</code></a>\n");
free(html);
+ html = blogc_content_parse_inline("test suite!)\n"
+ "depends on [cmocka](http://cmocka.org/), though.\n");
+ assert_non_null(html);
+ assert_string_equal(html, "test suite!)\n"
+ "depends on <a href=\"http://cmocka.org/\">cmocka</a>, though.\n");
+ free(html);
+ html = blogc_content_parse_inline("asd [bola]chunda(1234)");
+ assert_non_null(html);
+ assert_string_equal(html, "asd [bola]chunda(1234)");
+ free(html);
// "invalid"
html = blogc_content_parse_inline("[bola](\nhttp://example.org/)\n");
assert_non_null(html);
@@ -2516,6 +2794,42 @@ test_content_parse_inline_image(void **state)
assert_non_null(html);
assert_string_equal(html, "<img src=\"http://example.org/\" alt=\"bola\">\n");
free(html);
+ html = blogc_content_parse_inline("![bola]\r\n(http://example.org/)\n");
+ assert_non_null(html);
+ assert_string_equal(html, "<img src=\"http://example.org/\" alt=\"bola\">\n");
+ free(html);
+ html = blogc_content_parse_inline("![bola] \r\n (http://example.org/)\n");
+ assert_non_null(html);
+ assert_string_equal(html, "<img src=\"http://example.org/\" alt=\"bola\">\n");
+ free(html);
+ html = blogc_content_parse_inline(
+ "[![This is the image alt text](picture.jpg)](https://blogc.rgm.io)");
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<a href=\"https://blogc.rgm.io\"><img src=\"picture.jpg\" "
+ "alt=\"This is the image alt text\"></a>");
+ free(html);
+ html = blogc_content_parse_inline(
+ "[![This is the image alt text]\n"
+ "(picture.jpg)](https://blogc.rgm.io)");
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<a href=\"https://blogc.rgm.io\"><img src=\"picture.jpg\" "
+ "alt=\"This is the image alt text\"></a>");
+ free(html);
+ html = blogc_content_parse_inline(
+ "[![This is the image alt text]\n"
+ "(picture.jpg)]\n"
+ "(https://blogc.rgm.io)");
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<a href=\"https://blogc.rgm.io\"><img src=\"picture.jpg\" "
+ "alt=\"This is the image alt text\"></a>");
+ free(html);
+ html = blogc_content_parse_inline("asd ![bola]chunda(1234)");
+ assert_non_null(html);
+ assert_string_equal(html, "asd ![bola]chunda(1234)");
+ free(html);
// "invalid"
html = blogc_content_parse_inline("![bo\nla](http://example.org/)\n");
assert_non_null(html);
@@ -2613,6 +2927,36 @@ test_content_parse_inline_line_break_crlf(void **state)
}
+static void
+test_content_parse_inline_endash_emdash(void **state)
+{
+ char *html = blogc_content_parse_inline("foo -- bar");
+ assert_non_null(html);
+ assert_string_equal(html, "foo &ndash; bar");
+ free(html);
+ html = blogc_content_parse_inline("foo --- bar");
+ assert_non_null(html);
+ assert_string_equal(html, "foo &mdash; bar");
+ free(html);
+ html = blogc_content_parse_inline("`foo -- bar`");
+ assert_non_null(html);
+ assert_string_equal(html, "<code>foo -- bar</code>");
+ free(html);
+ html = blogc_content_parse_inline("`foo --- bar`");
+ assert_non_null(html);
+ assert_string_equal(html, "<code>foo --- bar</code>");
+ free(html);
+ html = blogc_content_parse_inline("``foo -- bar``");
+ assert_non_null(html);
+ assert_string_equal(html, "<code>foo -- bar</code>");
+ free(html);
+ html = blogc_content_parse_inline("``foo --- bar``");
+ assert_non_null(html);
+ assert_string_equal(html, "<code>foo --- bar</code>");
+ free(html);
+}
+
+
int
main(void)
{
@@ -2639,6 +2983,8 @@ main(void)
unit_test(test_content_parse_ordered_list),
unit_test(test_content_parse_ordered_list_crlf),
unit_test(test_content_parse_directive),
+ unit_test(test_content_parse_description),
+ unit_test(test_content_parse_description_crlf),
unit_test(test_content_parse_invalid_excerpt),
unit_test(test_content_parse_invalid_header),
unit_test(test_content_parse_invalid_header_empty),
@@ -2657,6 +3003,7 @@ main(void)
unit_test(test_content_parse_inline_image),
unit_test(test_content_parse_inline_line_break),
unit_test(test_content_parse_inline_line_break_crlf),
+ unit_test(test_content_parse_inline_endash_emdash),
};
return run_tests(tests);
}