aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDanny van Kooten <dannyvankooten@users.noreply.github.com>2020-03-12 15:07:09 +0100
committerDanny van Kooten <dannyvankooten@users.noreply.github.com>2020-03-12 15:07:09 +0100
commit791e03d8199fa1177f970f45a8a436912d229d1c (patch)
treebd24f5ad87bca8e932e9db8176d46a31d578c43c /tests
parenta39e8c713e0a8ea9f2f8e455c1ce2b4d0c3f5115 (diff)
downloadunja-791e03d8199fa1177f970f45a8a436912d229d1c.tar.gz
unja-791e03d8199fa1177f970f45a8a436912d229d1c.zip
add vector type
Diffstat (limited to 'tests')
-rw-r--r--tests/test_template.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/tests/test_template.c b/tests/test_template.c
index 69f1d94..55747e7 100644
--- a/tests/test_template.c
+++ b/tests/test_template.c
@@ -33,16 +33,17 @@ TEST(text_multiline) {
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);
+
+ struct vector *numbers = vector_new(3);
+ vector_push(numbers, "1");
+ vector_push(numbers, "2");
+ vector_push(numbers, "3");
+ hashmap_insert(ctx, "numbers", numbers);
+
char *output = template(input, ctx);
assert_str(output, "1, 2, 3, ");
+
+ vector_free(numbers);
hashmap_free(ctx);
free(output);
}