aboutsummaryrefslogtreecommitdiffstats
path: root/tests/check_renderer.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/check_renderer.c')
-rw-r--r--tests/check_renderer.c224
1 files changed, 112 insertions, 112 deletions
diff --git a/tests/check_renderer.c b/tests/check_renderer.c
index cb8f8f1..802b159 100644
--- a/tests/check_renderer.c
+++ b/tests/check_renderer.c
@@ -19,10 +19,10 @@
#include "../src/renderer.h"
#include "../src/source-parser.h"
#include "../src/template-parser.h"
-#include "../src/utils/utils.h"
+#include <squareball.h>
-static b_slist_t*
+static sb_slist_t*
create_sources(unsigned int count)
{
const char *s[] = {
@@ -46,12 +46,12 @@ create_sources(unsigned int count)
};
assert_false(count > 3);
blogc_error_t *err = NULL;
- b_slist_t *l = NULL;
+ sb_slist_t *l = NULL;
for (unsigned int i = 0; i < count; i++) {
- l = b_slist_append(l, blogc_source_parse(s[i], strlen(s[i]), &err));
+ l = sb_slist_append(l, blogc_source_parse(s[i], strlen(s[i]), &err));
assert_null(err);
}
- assert_int_equal(b_slist_length(l), count);
+ assert_int_equal(sb_slist_length(l), count);
return l;
}
@@ -76,10 +76,10 @@ test_render_entry(void **state)
"{% if GUDA > \"zxd\" %}LOL3{% endif %}\n"
"{% if GUDA <= \"zxc\" %}LOL4{% endif %}\n";
blogc_error_t *err = NULL;
- b_slist_t *l = blogc_template_parse(str, strlen(str), &err);
+ sb_slist_t *l = blogc_template_parse(str, strlen(str), &err);
assert_non_null(l);
assert_null(err);
- b_slist_t *s = create_sources(1);
+ sb_slist_t *s = create_sources(1);
assert_non_null(s);
char *out = blogc_render(l, s, NULL, false);
assert_string_equal(out,
@@ -99,7 +99,7 @@ test_render_entry(void **state)
"\n"
"LOL4\n");
blogc_template_free_stmts(l);
- b_slist_free_full(s, (b_free_func_t) b_trie_free);
+ sb_slist_free_full(s, (sb_free_func_t) sb_trie_free);
free(out);
}
@@ -119,10 +119,10 @@ test_render_listing(void **state)
"bola: {% ifdef BOLA %}{{ BOLA }}{% endif %}\n"
"{% endblock %}\n";
blogc_error_t *err = NULL;
- b_slist_t *l = blogc_template_parse(str, strlen(str), &err);
+ sb_slist_t *l = blogc_template_parse(str, strlen(str), &err);
assert_non_null(l);
assert_null(err);
- b_slist_t *s = create_sources(3);
+ sb_slist_t *s = create_sources(3);
assert_non_null(s);
char *out = blogc_render(l, s, NULL, true);
assert_string_equal(out,
@@ -140,7 +140,7 @@ test_render_listing(void **state)
"bola: asd3\n"
"\n");
blogc_template_free_stmts(l);
- b_slist_free_full(s, (b_free_func_t) b_trie_free);
+ sb_slist_free_full(s, (sb_free_func_t) sb_trie_free);
free(out);
}
@@ -160,7 +160,7 @@ test_render_listing_empty(void **state)
"bola: {% ifdef BOLA %}{{ BOLA }}{% endif %}\n"
"{% endblock %}\n";
blogc_error_t *err = NULL;
- b_slist_t *l = blogc_template_parse(str, strlen(str), &err);
+ sb_slist_t *l = blogc_template_parse(str, strlen(str), &err);
assert_non_null(l);
assert_null(err);
char *out = blogc_render(l, NULL, NULL, true);
@@ -187,10 +187,10 @@ test_render_ifdef(void **state)
"{% endif %}\n"
"{% endblock %}\n";
blogc_error_t *err = NULL;
- b_slist_t *l = blogc_template_parse(str, strlen(str), &err);
+ sb_slist_t *l = blogc_template_parse(str, strlen(str), &err);
assert_non_null(l);
assert_null(err);
- b_slist_t *s = create_sources(1);
+ sb_slist_t *s = create_sources(1);
assert_non_null(s);
char *out = blogc_render(l, s, NULL, false);
assert_string_equal(out,
@@ -198,7 +198,7 @@ test_render_ifdef(void **state)
"\n"
"\n");
blogc_template_free_stmts(l);
- b_slist_free_full(s, (b_free_func_t) b_trie_free);
+ sb_slist_free_full(s, (sb_free_func_t) sb_trie_free);
free(out);
}
@@ -216,10 +216,10 @@ test_render_ifdef2(void **state)
"{% endif %}\n"
"{% endblock %}\n";
blogc_error_t *err = NULL;
- b_slist_t *l = blogc_template_parse(str, strlen(str), &err);
+ sb_slist_t *l = blogc_template_parse(str, strlen(str), &err);
assert_non_null(l);
assert_null(err);
- b_slist_t *s = create_sources(1);
+ sb_slist_t *s = create_sources(1);
assert_non_null(s);
char *out = blogc_render(l, s, NULL, false);
assert_string_equal(out,
@@ -229,7 +229,7 @@ test_render_ifdef2(void **state)
"\n"
"\n");
blogc_template_free_stmts(l);
- b_slist_free_full(s, (b_free_func_t) b_trie_free);
+ sb_slist_free_full(s, (sb_free_func_t) sb_trie_free);
free(out);
}
@@ -247,10 +247,10 @@ test_render_ifdef3(void **state)
"{% endif %}\n"
"{% endblock %}\n";
blogc_error_t *err = NULL;
- b_slist_t *l = blogc_template_parse(str, strlen(str), &err);
+ sb_slist_t *l = blogc_template_parse(str, strlen(str), &err);
assert_non_null(l);
assert_null(err);
- b_slist_t *s = create_sources(1);
+ sb_slist_t *s = create_sources(1);
assert_non_null(s);
char *out = blogc_render(l, s, NULL, false);
assert_string_equal(out,
@@ -262,7 +262,7 @@ test_render_ifdef3(void **state)
"\n"
"\n");
blogc_template_free_stmts(l);
- b_slist_free_full(s, (b_free_func_t) b_trie_free);
+ sb_slist_free_full(s, (sb_free_func_t) sb_trie_free);
free(out);
}
@@ -280,10 +280,10 @@ test_render_ifndef(void **state)
"{% endif %}\n"
"{% endblock %}\n";
blogc_error_t *err = NULL;
- b_slist_t *l = blogc_template_parse(str, strlen(str), &err);
+ sb_slist_t *l = blogc_template_parse(str, strlen(str), &err);
assert_non_null(l);
assert_null(err);
- b_slist_t *s = create_sources(1);
+ sb_slist_t *s = create_sources(1);
assert_non_null(s);
char *out = blogc_render(l, s, NULL, false);
assert_string_equal(out,
@@ -295,7 +295,7 @@ test_render_ifndef(void **state)
"\n"
"\n");
blogc_template_free_stmts(l);
- b_slist_free_full(s, (b_free_func_t) b_trie_free);
+ sb_slist_free_full(s, (sb_free_func_t) sb_trie_free);
free(out);
}
@@ -314,10 +314,10 @@ test_render_if_eq(void **state)
"{% endif %}\n"
"{% endblock %}\n";
blogc_error_t *err = NULL;
- b_slist_t *l = blogc_template_parse(str, strlen(str), &err);
+ sb_slist_t *l = blogc_template_parse(str, strlen(str), &err);
assert_non_null(l);
assert_null(err);
- b_slist_t *s = create_sources(1);
+ sb_slist_t *s = create_sources(1);
assert_non_null(s);
char *out = blogc_render(l, s, NULL, false);
assert_string_equal(out,
@@ -330,7 +330,7 @@ test_render_if_eq(void **state)
"\n"
"\n");
blogc_template_free_stmts(l);
- b_slist_free_full(s, (b_free_func_t) b_trie_free);
+ sb_slist_free_full(s, (sb_free_func_t) sb_trie_free);
free(out);
}
@@ -349,10 +349,10 @@ test_render_if_neq(void **state)
"{% endif %}\n"
"{% endblock %}\n";
blogc_error_t *err = NULL;
- b_slist_t *l = blogc_template_parse(str, strlen(str), &err);
+ sb_slist_t *l = blogc_template_parse(str, strlen(str), &err);
assert_non_null(l);
assert_null(err);
- b_slist_t *s = create_sources(1);
+ sb_slist_t *s = create_sources(1);
assert_non_null(s);
char *out = blogc_render(l, s, NULL, false);
assert_string_equal(out,
@@ -365,7 +365,7 @@ test_render_if_neq(void **state)
"\n"
"\n");
blogc_template_free_stmts(l);
- b_slist_free_full(s, (b_free_func_t) b_trie_free);
+ sb_slist_free_full(s, (sb_free_func_t) sb_trie_free);
free(out);
}
@@ -384,10 +384,10 @@ test_render_if_lt(void **state)
"{% endif %}\n"
"{% endblock %}\n";
blogc_error_t *err = NULL;
- b_slist_t *l = blogc_template_parse(str, strlen(str), &err);
+ sb_slist_t *l = blogc_template_parse(str, strlen(str), &err);
assert_non_null(l);
assert_null(err);
- b_slist_t *s = create_sources(1);
+ sb_slist_t *s = create_sources(1);
assert_non_null(s);
char *out = blogc_render(l, s, NULL, false);
assert_string_equal(out,
@@ -400,7 +400,7 @@ test_render_if_lt(void **state)
"\n"
"\n");
blogc_template_free_stmts(l);
- b_slist_free_full(s, (b_free_func_t) b_trie_free);
+ sb_slist_free_full(s, (sb_free_func_t) sb_trie_free);
free(out);
}
@@ -419,10 +419,10 @@ test_render_if_gt(void **state)
"{% endif %}\n"
"{% endblock %}\n";
blogc_error_t *err = NULL;
- b_slist_t *l = blogc_template_parse(str, strlen(str), &err);
+ sb_slist_t *l = blogc_template_parse(str, strlen(str), &err);
assert_non_null(l);
assert_null(err);
- b_slist_t *s = create_sources(1);
+ sb_slist_t *s = create_sources(1);
assert_non_null(s);
char *out = blogc_render(l, s, NULL, false);
assert_string_equal(out,
@@ -435,7 +435,7 @@ test_render_if_gt(void **state)
"\n"
"\n");
blogc_template_free_stmts(l);
- b_slist_free_full(s, (b_free_func_t) b_trie_free);
+ sb_slist_free_full(s, (sb_free_func_t) sb_trie_free);
free(out);
}
@@ -456,10 +456,10 @@ test_render_if_lt_eq(void **state)
"{% endif %}\n"
"{% endblock %}\n";
blogc_error_t *err = NULL;
- b_slist_t *l = blogc_template_parse(str, strlen(str), &err);
+ sb_slist_t *l = blogc_template_parse(str, strlen(str), &err);
assert_non_null(l);
assert_null(err);
- b_slist_t *s = create_sources(1);
+ sb_slist_t *s = create_sources(1);
assert_non_null(s);
char *out = blogc_render(l, s, NULL, false);
assert_string_equal(out,
@@ -474,7 +474,7 @@ test_render_if_lt_eq(void **state)
"\n"
"\n");
blogc_template_free_stmts(l);
- b_slist_free_full(s, (b_free_func_t) b_trie_free);
+ sb_slist_free_full(s, (sb_free_func_t) sb_trie_free);
free(out);
}
@@ -495,10 +495,10 @@ test_render_if_gt_eq(void **state)
"{% endif %}\n"
"{% endblock %}\n";
blogc_error_t *err = NULL;
- b_slist_t *l = blogc_template_parse(str, strlen(str), &err);
+ sb_slist_t *l = blogc_template_parse(str, strlen(str), &err);
assert_non_null(l);
assert_null(err);
- b_slist_t *s = create_sources(1);
+ sb_slist_t *s = create_sources(1);
assert_non_null(s);
char *out = blogc_render(l, s, NULL, false);
assert_string_equal(out,
@@ -513,7 +513,7 @@ test_render_if_gt_eq(void **state)
"\n"
"\n");
blogc_template_free_stmts(l);
- b_slist_free_full(s, (b_free_func_t) b_trie_free);
+ sb_slist_free_full(s, (sb_free_func_t) sb_trie_free);
free(out);
}
@@ -533,21 +533,21 @@ test_render_outside_block(void **state)
"{{ BOLA }}\n"
"{% ifndef CHUNDA %}lol{% endif %}\n";
blogc_error_t *err = NULL;
- b_slist_t *l = blogc_template_parse(str, strlen(str), &err);
+ sb_slist_t *l = blogc_template_parse(str, strlen(str), &err);
assert_non_null(l);
assert_null(err);
- b_slist_t *s = create_sources(1);
+ sb_slist_t *s = create_sources(1);
assert_non_null(s);
- b_trie_t *c = b_trie_new(free);
- b_trie_insert(c, "GUDA", b_strdup("asd"));
+ sb_trie_t *c = sb_trie_new(free);
+ sb_trie_insert(c, "GUDA", sb_strdup("asd"));
char *out = blogc_render(l, s, c, false);
assert_string_equal(out,
"bola\n"
"\n"
"lol\n");
- b_trie_free(c);
+ sb_trie_free(c);
blogc_template_free_stmts(l);
- b_slist_free_full(s, (b_free_func_t) b_trie_free);
+ sb_slist_free_full(s, (sb_free_func_t) sb_trie_free);
free(out);
}
@@ -566,14 +566,14 @@ test_render_prefer_local_variable(void **state)
"{% endif %}\n"
"{% endblock %}\n";
blogc_error_t *err = NULL;
- b_slist_t *l = blogc_template_parse(str, strlen(str), &err);
+ sb_slist_t *l = blogc_template_parse(str, strlen(str), &err);
assert_non_null(l);
assert_null(err);
- b_slist_t *s = create_sources(1);
+ sb_slist_t *s = create_sources(1);
assert_non_null(s);
- b_trie_t *c = b_trie_new(free);
- b_trie_insert(c, "GUDA", b_strdup("hehe"));
- b_trie_insert(c, "LOL", b_strdup("hmm"));
+ sb_trie_t *c = sb_trie_new(free);
+ sb_trie_insert(c, "GUDA", sb_strdup("hehe"));
+ sb_trie_insert(c, "LOL", sb_strdup("hmm"));
char *out = blogc_render(l, s, c, false);
assert_string_equal(out,
"\n"
@@ -584,9 +584,9 @@ test_render_prefer_local_variable(void **state)
"\n"
"\n"
"\n");
- b_trie_free(c);
+ sb_trie_free(c);
blogc_template_free_stmts(l);
- b_slist_free_full(s, (b_free_func_t) b_trie_free);
+ sb_slist_free_full(s, (sb_free_func_t) sb_trie_free);
free(out);
}
@@ -602,12 +602,12 @@ test_render_respect_variable_scope(void **state)
"{% ifdef BOLA %}{{ BOLA }}{% endif %}\n"
"{% endblock %}\n";
blogc_error_t *err = NULL;
- b_slist_t *l = blogc_template_parse(str, strlen(str), &err);
+ sb_slist_t *l = blogc_template_parse(str, strlen(str), &err);
assert_non_null(l);
assert_null(err);
- b_slist_t *s = create_sources(1);
+ sb_slist_t *s = create_sources(1);
assert_non_null(s);
- b_trie_t *c = b_trie_new(free);
+ sb_trie_t *c = sb_trie_new(free);
char *out = blogc_render(l, s, c, false);
assert_string_equal(out,
"\n"
@@ -616,9 +616,9 @@ test_render_respect_variable_scope(void **state)
"\n"
"asd\n"
"\n");
- b_trie_free(c);
+ sb_trie_free(c);
blogc_template_free_stmts(l);
- b_slist_free_full(s, (b_free_func_t) b_trie_free);
+ sb_slist_free_full(s, (sb_free_func_t) sb_trie_free);
free(out);
}
@@ -626,112 +626,112 @@ test_render_respect_variable_scope(void **state)
static void
test_get_variable(void **state)
{
- b_trie_t *g = b_trie_new(free);
- b_trie_insert(g, "NAME", b_strdup("bola"));
- b_trie_insert(g, "TITLE", b_strdup("bola2"));
- b_trie_t *l = b_trie_new(free);
- b_trie_insert(l, "NAME", b_strdup("chunda"));
- b_trie_insert(l, "TITLE", b_strdup("chunda2"));
+ sb_trie_t *g = sb_trie_new(free);
+ sb_trie_insert(g, "NAME", sb_strdup("bola"));
+ sb_trie_insert(g, "TITLE", sb_strdup("bola2"));
+ sb_trie_t *l = sb_trie_new(free);
+ sb_trie_insert(l, "NAME", sb_strdup("chunda"));
+ sb_trie_insert(l, "TITLE", sb_strdup("chunda2"));
assert_string_equal(blogc_get_variable("NAME", g, l), "chunda");
assert_string_equal(blogc_get_variable("TITLE", g, l), "chunda2");
assert_null(blogc_get_variable("BOLA", g, l));
- b_trie_free(g);
- b_trie_free(l);
+ sb_trie_free(g);
+ sb_trie_free(l);
}
static void
test_get_variable_only_local(void **state)
{
- b_trie_t *g = NULL;
- b_trie_t *l = b_trie_new(free);
- b_trie_insert(l, "NAME", b_strdup("chunda"));
- b_trie_insert(l, "TITLE", b_strdup("chunda2"));
+ sb_trie_t *g = NULL;
+ sb_trie_t *l = sb_trie_new(free);
+ sb_trie_insert(l, "NAME", sb_strdup("chunda"));
+ sb_trie_insert(l, "TITLE", sb_strdup("chunda2"));
assert_string_equal(blogc_get_variable("NAME", g, l), "chunda");
assert_string_equal(blogc_get_variable("TITLE", g, l), "chunda2");
assert_null(blogc_get_variable("BOLA", g, l));
- b_trie_free(l);
+ sb_trie_free(l);
}
static void
test_get_variable_only_global(void **state)
{
- b_trie_t *g = b_trie_new(free);
- b_trie_insert(g, "NAME", b_strdup("bola"));
- b_trie_insert(g, "TITLE", b_strdup("bola2"));
- b_trie_t *l = NULL;
+ sb_trie_t *g = sb_trie_new(free);
+ sb_trie_insert(g, "NAME", sb_strdup("bola"));
+ sb_trie_insert(g, "TITLE", sb_strdup("bola2"));
+ sb_trie_t *l = NULL;
assert_string_equal(blogc_get_variable("NAME", g, l), "bola");
assert_string_equal(blogc_get_variable("TITLE", g, l), "bola2");
assert_null(blogc_get_variable("BOLA", g, l));
- b_trie_free(g);
+ sb_trie_free(g);
}
static void
test_format_date(void **state)
{
- b_trie_t *g = b_trie_new(free);
- b_trie_insert(g, "DATE_FORMAT", b_strdup("%H -- %M"));
- b_trie_t *l = b_trie_new(free);
- b_trie_insert(l, "DATE_FORMAT", b_strdup("%R"));
+ sb_trie_t *g = sb_trie_new(free);
+ sb_trie_insert(g, "DATE_FORMAT", sb_strdup("%H -- %M"));
+ sb_trie_t *l = sb_trie_new(free);
+ sb_trie_insert(l, "DATE_FORMAT", sb_strdup("%R"));
char *date = blogc_format_date("2015-01-02 03:04:05", g, l);
assert_string_equal(date, "03:04");
free(date);
- b_trie_free(g);
- b_trie_free(l);
+ sb_trie_free(g);
+ sb_trie_free(l);
}
static void
test_format_date_with_global_format(void **state)
{
- b_trie_t *g = b_trie_new(free);
- b_trie_insert(g, "DATE_FORMAT", b_strdup("%H -- %M"));
- b_trie_t *l = b_trie_new(free);
+ sb_trie_t *g = sb_trie_new(free);
+ sb_trie_insert(g, "DATE_FORMAT", sb_strdup("%H -- %M"));
+ sb_trie_t *l = sb_trie_new(free);
char *date = blogc_format_date("2015-01-02 03:04:05", g, l);
assert_string_equal(date, "03 -- 04");
free(date);
- b_trie_free(g);
- b_trie_free(l);
+ sb_trie_free(g);
+ sb_trie_free(l);
}
static void
test_format_date_without_format(void **state)
{
- b_trie_t *g = b_trie_new(free);
- b_trie_t *l = b_trie_new(free);
+ sb_trie_t *g = sb_trie_new(free);
+ sb_trie_t *l = sb_trie_new(free);
char *date = blogc_format_date("2015-01-02 03:04:05", g, l);
assert_string_equal(date, "2015-01-02 03:04:05");
free(date);
- b_trie_free(g);
- b_trie_free(l);
+ sb_trie_free(g);
+ sb_trie_free(l);
}
static void
test_format_date_without_date(void **state)
{
- b_trie_t *g = b_trie_new(free);
- b_trie_t *l = b_trie_new(free);
+ sb_trie_t *g = sb_trie_new(free);
+ sb_trie_t *l = sb_trie_new(free);
char *date = blogc_format_date(NULL, g, l);
assert_null(date);
free(date);
- b_trie_free(g);
- b_trie_free(l);
+ sb_trie_free(g);
+ sb_trie_free(l);
}
static void
test_format_variable(void **state)
{
- b_trie_t *g = b_trie_new(free);
- b_trie_insert(g, "NAME", b_strdup("bola"));
- b_trie_insert(g, "TITLE", b_strdup("bola2"));
- b_trie_t *l = b_trie_new(free);
- b_trie_insert(l, "NAME", b_strdup("chunda"));
- b_trie_insert(l, "TITLE", b_strdup("chunda2"));
+ sb_trie_t *g = sb_trie_new(free);
+ sb_trie_insert(g, "NAME", sb_strdup("bola"));
+ sb_trie_insert(g, "TITLE", sb_strdup("bola2"));
+ sb_trie_t *l = sb_trie_new(free);
+ sb_trie_insert(l, "NAME", sb_strdup("chunda"));
+ sb_trie_insert(l, "TITLE", sb_strdup("chunda2"));
char *tmp = blogc_format_variable("NAME", g, l);
assert_string_equal(tmp, "chunda");
free(tmp);
@@ -739,24 +739,24 @@ test_format_variable(void **state)
assert_string_equal(tmp, "chunda2");
free(tmp);
assert_null(blogc_format_variable("BOLA", g, l));
- b_trie_free(g);
- b_trie_free(l);
+ sb_trie_free(g);
+ sb_trie_free(l);
}
static void
test_format_variable_with_date(void **state)
{
- b_trie_t *g = b_trie_new(free);
- b_trie_insert(g, "DATE", b_strdup("2010-11-12 13:14:15"));
- b_trie_insert(g, "DATE_FORMAT", b_strdup("%R"));
- b_trie_t *l = b_trie_new(free);
- b_trie_insert(l, "DATE", b_strdup("2011-12-13 14:15:16"));
+ sb_trie_t *g = sb_trie_new(free);
+ sb_trie_insert(g, "DATE", sb_strdup("2010-11-12 13:14:15"));
+ sb_trie_insert(g, "DATE_FORMAT", sb_strdup("%R"));
+ sb_trie_t *l = sb_trie_new(free);
+ sb_trie_insert(l, "DATE", sb_strdup("2011-12-13 14:15:16"));
char *tmp = blogc_format_variable("DATE_FORMATTED", g, l);
assert_string_equal(tmp, "14:15");
free(tmp);
- b_trie_free(g);
- b_trie_free(l);
+ sb_trie_free(g);
+ sb_trie_free(l);
}