From 35c4f119ca188fd9e90a2bbada864f9d121459ba Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Mon, 25 Jan 2016 04:46:19 +0100 Subject: renderer: fix bug when 'if' evals to false after 'if' evals to true --- tests/check_renderer.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'tests/check_renderer.c') diff --git a/tests/check_renderer.c b/tests/check_renderer.c index 360f067..d6bc947 100644 --- a/tests/check_renderer.c +++ b/tests/check_renderer.c @@ -686,6 +686,37 @@ test_render_respect_variable_scope(void **state) } +static void +test_render_ifcount_bug(void **state) +{ + const char *str = + "{% block entry %}\n" + "{% ifdef TITLE %}

{{ TITLE }}

{% endif %}\n" + "{% ifdef IS_POST %}\n" + "{% ifdef ASD %}ASD{% 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 = NULL; + s = b_slist_append(s, b_trie_new(free)); + b_trie_insert(s->data, "TITLE", b_strdup("bola")); + b_trie_t *c = b_trie_new(free); + char *out = blogc_render(l, s, c, false); + assert_string_equal(out, + "\n" + "

bola

\n" + "\n" + "\n"); + b_trie_free(c); + blogc_template_free_stmts(l); + b_slist_free_full(s, (b_free_func_t) b_trie_free); + free(out); +} + + static void test_get_variable(void **state) { @@ -897,6 +928,7 @@ main(void) unit_test(test_render_outside_block), unit_test(test_render_prefer_local_variable), unit_test(test_render_respect_variable_scope), + unit_test(test_render_ifcount_bug), unit_test(test_get_variable), unit_test(test_get_variable_only_local), unit_test(test_get_variable_only_global), -- cgit v1.2.3-18-g5258