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.c946
1 files changed, 946 insertions, 0 deletions
diff --git a/tests/check_content_parser.c b/tests/check_content_parser.c
index 2444ebb..4f201d1 100644
--- a/tests/check_content_parser.c
+++ b/tests/check_content_parser.c
@@ -16,6 +16,7 @@
#include <cmocka.h>
#include <string.h>
#include "../src/content-parser.h"
+#include "../src/directives.h"
#include "../src/utils.h"
@@ -1095,6 +1096,764 @@ test_content_parse_ordered_list_crlf(void **state)
}
+char*
+__wrap_blogc_directive_loader(blogc_directive_ctx_t *ctx, blogc_error_t **err)
+{
+ assert_non_null(err);
+ assert_null(*err);
+ assert_string_equal(ctx->name, mock_type(const char*));
+ const char *arg = mock_type(const char*);
+ if (arg == NULL)
+ assert_null(ctx->argument);
+ else
+ assert_string_equal(ctx->argument, arg);
+ assert_int_equal(sb_trie_size(ctx->params), mock_type(unsigned int));
+
+ 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(sb_trie_lookup(ctx->params, key), value);
+ }
+
+ return sb_strdup("CHUNDA\n");
+}
+
+
+static void
+test_content_parse_directive(void **state)
+{
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 0);
+ char *html = blogc_content_parse(
+ ".. bola::",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 0);
+ html = blogc_content_parse(
+ ".. bola::\n",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 0);
+ html = blogc_content_parse(
+ ".. bola:: ",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 0);
+ html = blogc_content_parse(
+ ".. bola:: \n",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 0);
+ html = blogc_content_parse(
+ ".. bola::\r\n",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 1);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ html = blogc_content_parse(
+ ".. bola::\n"
+ " :asd: qwe",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 1);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ html = blogc_content_parse(
+ ".. bola::\n"
+ " :asd: qwe\n",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 1);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ html = blogc_content_parse(
+ ".. bola::\r\n"
+ "\t:asd: qwe\r\n",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 2);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "zxc");
+ will_return(__wrap_blogc_directive_loader, "vbn");
+ html = blogc_content_parse(
+ ".. bola::\n"
+ "\t\t:asd: qwe\n"
+ "\t\t:zxc: vbn",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 2);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "zxc");
+ will_return(__wrap_blogc_directive_loader, "vbn");
+ html = blogc_content_parse(
+ ".. bola::\n"
+ " :asd: qwe\n"
+ " :zxc: vbn\n",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 2);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "zxc");
+ will_return(__wrap_blogc_directive_loader, "vbn");
+ html = blogc_content_parse(
+ ".. bola::\r\n"
+ " :asd: qwe\r\n"
+ " :zxc: vbn\r\n",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 3);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "ert");
+ will_return(__wrap_blogc_directive_loader, "zxvc");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "bola");
+ html = blogc_content_parse(
+ "# foo\n"
+ "\n"
+ ".. bola::\n"
+ " :asd: qwe\n"
+ " :ert: zxvc\n"
+ " :qwe: bola\n"
+ "\n"
+ "bola", NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\n"
+ "CHUNDA\n"
+ "<p>bola</p>\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 3);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "ert");
+ will_return(__wrap_blogc_directive_loader, "zxvc");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "bola");
+ html = blogc_content_parse(
+ "# foo\r\n"
+ "\r\n"
+ ".. bola::\r\n"
+ " :asd: qwe\r\n"
+ " :ert: zxvc\r\n"
+ " :qwe: bola\r\n"
+ "\r\n"
+ "bola", NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\r\n"
+ "CHUNDA\n"
+ "<p>bola</p>\r\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 0);
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 0);
+ html = blogc_content_parse(
+ "# foo\n"
+ "\n"
+ ".. bola::\n"
+ "\n"
+ ".. bola::", NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\n"
+ "CHUNDA\n"
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, 0);
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, 0);
+ html = blogc_content_parse(
+ "# foo\n"
+ "\n"
+ ".. bola:: asd\n"
+ "\n"
+ ".. bola:: asd\n", NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\n"
+ "CHUNDA\n"
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 0);
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 0);
+ html = blogc_content_parse(
+ "# foo\r\n"
+ "\r\n"
+ ".. bola::\r\n"
+ "\r\n"
+ ".. bola::\r\n", NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\r\n"
+ "CHUNDA\n"
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 1);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 0);
+ html = blogc_content_parse(
+ "# foo\n"
+ "\n"
+ ".. bola::\n"
+ " :asd: qwe\n"
+ "\n"
+ ".. bola::", NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\n"
+ "CHUNDA\n"
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, 1);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, 0);
+ html = blogc_content_parse(
+ "# foo\n"
+ "\n"
+ ".. bola:: asd\n"
+ " :asd: qwe\n"
+ "\n"
+ ".. bola:: asd\n", NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\n"
+ "CHUNDA\n"
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 1);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 0);
+ html = blogc_content_parse(
+ "# foo\n"
+ "\n"
+ ".. bola::\n"
+ " :asd: qwe\n"
+ "\n"
+ ".. bola::\n", NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\n"
+ "CHUNDA\n"
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 1);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 0);
+ html = blogc_content_parse(
+ "# foo\r\n"
+ "\r\n"
+ ".. bola::\r\n"
+ " :asd: qwe\r\n"
+ "\r\n"
+ ".. bola::\r\n", NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\r\n"
+ "CHUNDA\n"
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 1);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 1);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "zxc");
+ html = blogc_content_parse(
+ "# foo\n"
+ "\n"
+ ".. bola::\n"
+ " :asd: qwe\n"
+ "\n"
+ ".. bola::\n"
+ " :asd: zxc\n", NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\n"
+ "CHUNDA\n"
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 1);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 1);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "zxc");
+ html = blogc_content_parse(
+ "# foo\r\n"
+ "\r\n"
+ ".. bola::\r\n"
+ " :asd: qwe\r\n"
+ "\r\n"
+ ".. bola::\r\n"
+ " :asd: zxc\r\n", NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\r\n"
+ "CHUNDA\n"
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 2);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "123");
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 2);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "456");
+ html = blogc_content_parse(
+ "# foo\n"
+ "\n"
+ ".. bola::\n"
+ " :asd: qwe\n"
+ " :qwe: 123\n"
+ "\n"
+ ".. bola::\n"
+ " :asd: qwe\n"
+ " :qwe: 456", NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\n"
+ "CHUNDA\n"
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, 2);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "123");
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, 2);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "456");
+ html = blogc_content_parse(
+ "# foo\n"
+ "\n"
+ ".. bola:: asd\n"
+ " :asd: qwe\n"
+ " :qwe: 123\n"
+ "\n"
+ ".. bola:: asd\n"
+ " :asd: qwe\n"
+ " :qwe: 456\n", NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\n"
+ "CHUNDA\n"
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 2);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "123");
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 2);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "456");
+ html = blogc_content_parse(
+ "# foo\n"
+ "\n"
+ ".. bola::\n"
+ " :asd: qwe\n"
+ " :qwe: 123\n"
+ "\n"
+ ".. bola::\n"
+ " :asd: qwe\n"
+ " :qwe: 456\n", NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\n"
+ "CHUNDA\n"
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 2);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "123");
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 2);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "456");
+ html = blogc_content_parse(
+ "# foo\r\n"
+ "\r\n"
+ ".. bola::\r\n"
+ " :asd: qwe\r\n"
+ " :qwe: 123\r\n"
+ "\r\n"
+ ".. bola::\r\n"
+ " :asd: qwe\r\n"
+ " :qwe: 456\r\n", NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\r\n"
+ "CHUNDA\n"
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, "chunda");
+ will_return(__wrap_blogc_directive_loader, 0);
+ html = blogc_content_parse(
+ ".. bola:: chunda",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, "chunda");
+ will_return(__wrap_blogc_directive_loader, 0);
+ html = blogc_content_parse(
+ ".. bola:: chunda\n",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, "chunda");
+ will_return(__wrap_blogc_directive_loader, 0);
+ html = blogc_content_parse(
+ ".. bola:: chunda\r\n",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, "chunda");
+ will_return(__wrap_blogc_directive_loader, 1);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ html = blogc_content_parse(
+ ".. bola:: chunda\n"
+ " :asd: qwe",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, "chunda");
+ will_return(__wrap_blogc_directive_loader, 1);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ html = blogc_content_parse(
+ ".. bola:: chunda\n"
+ " :asd: qwe\n",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, "chunda");
+ will_return(__wrap_blogc_directive_loader, 1);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ html = blogc_content_parse(
+ ".. bola:: chunda\r\n"
+ " :asd: qwe\r\n",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, "chunda");
+ will_return(__wrap_blogc_directive_loader, 2);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "zxc");
+ will_return(__wrap_blogc_directive_loader, "vbn");
+ html = blogc_content_parse(
+ ".. bola:: chunda\n"
+ " :asd: qwe\n"
+ " :zxc: vbn",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, "chunda");
+ will_return(__wrap_blogc_directive_loader, 2);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "zxc");
+ will_return(__wrap_blogc_directive_loader, "vbn");
+ html = blogc_content_parse(
+ ".. bola:: chunda\n"
+ " :asd: qwe\n"
+ " :zxc: vbn\n",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, "chunda");
+ will_return(__wrap_blogc_directive_loader, 2);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "zxc");
+ will_return(__wrap_blogc_directive_loader, "vbn");
+ html = blogc_content_parse(
+ ".. bola:: chunda\r\n"
+ " :asd: qwe\r\n"
+ " :zxc: vbn\r\n",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, "chunda");
+ will_return(__wrap_blogc_directive_loader, 3);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "ert");
+ will_return(__wrap_blogc_directive_loader, "zxvc");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "bola");
+ html = blogc_content_parse(
+ "# foo\n"
+ "\n"
+ ".. bola:: chunda\n"
+ " :asd: qwe\n"
+ " :ert: zxvc\n"
+ " :qwe: bola\n"
+ "\n"
+ "bola", NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\n"
+ "CHUNDA\n"
+ "<p>bola</p>\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, "chunda");
+ will_return(__wrap_blogc_directive_loader, 3);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "ert");
+ will_return(__wrap_blogc_directive_loader, "zxvc");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "bola");
+ html = blogc_content_parse(
+ "# foo\r\n"
+ "\r\n"
+ ".. bola:: chunda\r\n"
+ " :asd: qwe\r\n"
+ " :ert: zxvc\r\n"
+ " :qwe: bola\r\n"
+ "\r\n"
+ "bola", NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\r\n"
+ "CHUNDA\n"
+ "<p>bola</p>\r\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, "chunda");
+ will_return(__wrap_blogc_directive_loader, 3);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "ert");
+ will_return(__wrap_blogc_directive_loader, "zxvc");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, "bolao");
+ will_return(__wrap_blogc_directive_loader, "chund");
+ will_return(__wrap_blogc_directive_loader, 2);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "ert");
+ will_return(__wrap_blogc_directive_loader, "zxvc");
+ html = blogc_content_parse(
+ "# foo\r\n"
+ "\r\n"
+ ".. bola:: chunda\r\n"
+ " :asd: qwe\r\n"
+ " :ert: zxvc\r\n"
+ " :qwe: bola\r\n"
+ "\r\n"
+ ".. bolao:: chund\r\n"
+ " :asd: qwe\r\n"
+ " :ert: zxvc\r\n"
+ "\r\n"
+ "bola", NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\r\n"
+ "CHUNDA\n"
+ "CHUNDA\n"
+ "<p>bola</p>\r\n");
+ free(html);
+}
+
+
static void
test_content_parse_description(void **state)
{
@@ -1596,6 +2355,191 @@ test_content_parse_invalid_ordered_list(void **state)
static void
+test_content_parse_invalid_directive(void **state)
+{
+ char *html = blogc_content_parse(
+ ".. ",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<p>.. </p>\n");
+ free(html);
+
+ html = blogc_content_parse(
+ ".. \n",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<p>.. </p>\n");
+ free(html);
+
+ html = blogc_content_parse(
+ ".. ",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<p>.. <br /></p>\n");
+ free(html);
+
+ html = blogc_content_parse(
+ ".. \n",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<p>.. <br /></p>\n");
+ free(html);
+
+ html = blogc_content_parse(
+ ".. a",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<p>.. a</p>\n");
+ free(html);
+
+ html = blogc_content_parse(
+ ".. a\n",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<p>.. a</p>\n");
+ free(html);
+
+ html = blogc_content_parse(
+ ".. asd",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<p>.. asd</p>\n");
+ free(html);
+
+ html = blogc_content_parse(
+ ".. asd\n",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<p>.. asd</p>\n");
+ free(html);
+
+ html = blogc_content_parse(
+ ".. asd:",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<p>.. asd:</p>\n");
+ free(html);
+
+ html = blogc_content_parse(
+ ".. asd:\n",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<p>.. asd:</p>\n");
+ free(html);
+
+ html = blogc_content_parse(
+ ".. asd::\n"
+ " :",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<p>.. asd::\n"
+ " :</p>\n");
+ free(html);
+
+ html = blogc_content_parse(
+ ".. asd::\n"
+ " :\n",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<p>.. asd::\n"
+ " :</p>\n");
+ free(html);
+
+ html = blogc_content_parse(
+ ".. asd::\n"
+ " :a",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<p>.. asd::\n"
+ " :a</p>\n");
+ free(html);
+
+ html = blogc_content_parse(
+ ".. asd::\n"
+ " :a\n",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<p>.. asd::\n"
+ " :a</p>\n");
+ free(html);
+
+ html = blogc_content_parse(
+ ".. asd::\n"
+ " :as",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<p>.. asd::\n"
+ " :as</p>\n");
+ free(html);
+
+ html = blogc_content_parse(
+ ".. asd::\n"
+ " :as\n",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<p>.. asd::\n"
+ " :as</p>\n");
+ free(html);
+
+ html = blogc_content_parse(
+ ".. asd::\n"
+ " :as:",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<p>.. asd::\n"
+ " :as:</p>\n");
+ free(html);
+
+ html = blogc_content_parse(
+ ".. asd::\n"
+ " :as:\n",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<p>.. asd::\n"
+ " :as:</p>\n");
+ free(html);
+
+ html = blogc_content_parse(
+ ".. asd::\n"
+ " :as: ",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<p>.. asd::\n"
+ " :as: </p>\n");
+ free(html);
+
+ html = blogc_content_parse(
+ ".. asd::\n"
+ " :as: \n",
+ NULL, NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<p>.. asd::\n"
+ " :as: </p>\n");
+ free(html);
+}
+
+
+static void
test_content_parse_inline(void **state)
{
char *html = blogc_content_parse_inline(
@@ -2038,6 +2982,7 @@ main(void)
unit_test(test_content_parse_unordered_list_crlf),
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),
@@ -2048,6 +2993,7 @@ main(void)
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_invalid_directive),
unit_test(test_content_parse_inline),
unit_test(test_content_parse_inline_em),
unit_test(test_content_parse_inline_strong),