blob: 88d1ab4327892738014550b47f463491fe725f8d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#include "test.h"
#include "template.h"
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
|