aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDanny van Kooten <dannyvankooten@users.noreply.github.com>2020-03-12 14:45:48 +0100
committerDanny van Kooten <dannyvankooten@users.noreply.github.com>2020-03-12 14:45:48 +0100
commita39e8c713e0a8ea9f2f8e455c1ce2b4d0c3f5115 (patch)
tree39f247b5a7e064d3b1490ff2da6ad1233c1d7e0c /tests
parent616ff505f666d4d162e5d2d8c0238f8af6f79c40 (diff)
downloadunja-a39e8c713e0a8ea9f2f8e455c1ce2b4d0c3f5115.tar.gz
unja-a39e8c713e0a8ea9f2f8e455c1ce2b4d0c3f5115.zip
evaluate for blocks correctly
Diffstat (limited to 'tests')
-rw-r--r--tests/test_template.c18
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