diff options
Diffstat (limited to 'tests/test_template.c')
-rw-r--r-- | tests/test_template.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/tests/test_template.c b/tests/test_template.c index 88d1ab4..69f1d94 100644 --- a/tests/test_template.c +++ b/tests/test_template.c @@ -30,7 +30,21 @@ TEST(text_multiline) { free(output); } - - +TEST(for_block) { + char *input = "{% for n in numbers %}{{ n }}, {% endfor %}"; + struct hashmap *ctx = hashmap_new(); + struct list numbers; + numbers.size = 0; + numbers.cap = 64; + numbers.values = malloc(numbers.cap * sizeof *numbers.values); + numbers.values[numbers.size++] = "1"; + numbers.values[numbers.size++] = "2"; + numbers.values[numbers.size++] = "3"; + hashmap_insert(ctx, "numbers", &numbers); + char *output = template(input, ctx); + assert_str(output, "1, 2, 3, "); + hashmap_free(ctx); + free(output); +} END_TESTS
\ No newline at end of file |