aboutsummaryrefslogtreecommitdiffstats
path: root/tests/check_renderer.c
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2015-04-23 19:44:39 -0300
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2015-04-23 19:44:39 -0300
commit7582a32c837c8b55613b547799d1a6405e926cba (patch)
tree91d1c6cd950b685ac29ab7b555b73ee7da2a04dd /tests/check_renderer.c
parentc7241b7dba557674ae84f53bcf55cd8597be3559 (diff)
downloadblogc-7582a32c837c8b55613b547799d1a6405e926cba.tar.gz
blogc-7582a32c837c8b55613b547799d1a6405e926cba.tar.bz2
blogc-7582a32c837c8b55613b547799d1a6405e926cba.zip
template parser: added "if not" support
Diffstat (limited to 'tests/check_renderer.c')
-rw-r--r--tests/check_renderer.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/check_renderer.c b/tests/check_renderer.c
index bbc2953..539d122 100644
--- a/tests/check_renderer.c
+++ b/tests/check_renderer.c
@@ -214,6 +214,39 @@ test_render_if3(void **state)
static void
+test_render_if_not(void **state)
+{
+ const char *str =
+ "{% block entry %}\n"
+ "{% if not CHUNDA %}chunda\n"
+ "{% if GUDA %}guda\n"
+ "{% if not BOLA %}bola\n"
+ "{% endif %}\n"
+ "{% endif %}\n"
+ "{% endif %}\n"
+ "{% endblock %}\n";
+ blogc_error_t *err = NULL;
+ b_slist_t *l = blogc_template_parse(str, strlen(str), &err);
+ assert_non_null(l);
+ assert_null(err);
+ b_slist_t *s = create_sources(1);
+ assert_non_null(s);
+ char *out = blogc_render(l, s, false);
+ assert_string_equal(out,
+ "\n"
+ "chunda\n"
+ "guda\n"
+ "\n"
+ "\n"
+ "\n"
+ "\n");
+ blogc_template_free_stmts(l);
+ b_slist_free_full(s, (b_free_func_t) b_trie_free);
+ free(out);
+}
+
+
+static void
test_render_null(void **state)
{
assert_null(blogc_render(NULL, NULL, false));
@@ -229,6 +262,7 @@ main(void)
unit_test(test_render_if),
unit_test(test_render_if2),
unit_test(test_render_if3),
+ unit_test(test_render_if_not),
unit_test(test_render_null),
};
return run_tests(tests);