aboutsummaryrefslogtreecommitdiff
path: root/tests/test_template.c
diff options
context:
space:
mode:
authorDanny van Kooten <dannyvankooten@users.noreply.github.com>2020-03-12 14:19:24 +0100
committerDanny van Kooten <dannyvankooten@users.noreply.github.com>2020-03-12 14:19:24 +0100
commit616ff505f666d4d162e5d2d8c0238f8af6f79c40 (patch)
treebd475af1d3c7b200d38e6769d33c1bed77384d15 /tests/test_template.c
parent83eee4d23f9da9e72238dd01d43b350ed5bc04f1 (diff)
downloadunja-616ff505f666d4d162e5d2d8c0238f8af6f79c40.tar.gz
unja-616ff505f666d4d162e5d2d8c0238f8af6f79c40.zip
add first template tests
Diffstat (limited to 'tests/test_template.c')
-rw-r--r--tests/test_template.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/tests/test_template.c b/tests/test_template.c
index 62ac77c..88d1ab4 100644
--- a/tests/test_template.c
+++ b/tests/test_template.c
@@ -4,7 +4,33 @@
START_TESTS
TEST(text_only) {
-
+ char *input = "Hello world.";
+ char *output = template(input, NULL);
+ assert_str(output, "Hello world.");
+ free(output);
}
+TEST(text_with_var) {
+ char *input = "Hello {{name}}.";
+ struct hashmap *ctx = hashmap_new();
+ hashmap_insert(ctx, "name", "world");
+ char *output = template(input, ctx);
+ assert_str(output, "Hello world.");
+ hashmap_free(ctx);
+ free(output);
+}
+
+TEST(text_multiline) {
+ char *input = "Hello {{name}}.\nL2";
+ struct hashmap *ctx = hashmap_new();
+ hashmap_insert(ctx, "name", "world");
+ char *output = template(input, ctx);
+ assert_str(output, "Hello world.\nL2");
+ hashmap_free(ctx);
+ free(output);
+}
+
+
+
+
END_TESTS \ No newline at end of file