diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_template.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/tests/test_template.c b/tests/test_template.c index cc57ba5..d4f4e7f 100644 --- a/tests/test_template.c +++ b/tests/test_template.c @@ -5,21 +5,21 @@ START_TESTS TEST(text_only) { char *input = "Hello world."; - char *output = template(input, NULL); + char *output = template_string(input, NULL); assert_str(output, "Hello world."); free(output); } TEST(expr_number) { char *input = "Hello {{ 5 }}."; - char *output = template(input, NULL); + char *output = template_string(input, NULL); assert_str(output, "Hello 5."); free(output); } TEST(expr_string) { char *input = "Hello {{ \"world\" }}."; - char *output = template(input, NULL); + char *output = template_string(input, NULL); assert_str(output, "Hello world."); free(output); } @@ -28,7 +28,7 @@ TEST(expr_symbol) { char *input = "Hello {{name}}."; struct hashmap *ctx = hashmap_new(); hashmap_insert(ctx, "name", "world"); - char *output = template(input, ctx); + char *output = template_string(input, ctx); assert_str(output, "Hello world."); hashmap_free(ctx); free(output); @@ -50,7 +50,7 @@ TEST(expr_add) { hashmap_insert(ctx, "name", "Danny"); for (int i=0; i < ARRAY_SIZE(tests); i++) { - char *output = template(tests[i].input, ctx); + char *output = template_string(tests[i].input, ctx); assert_str(output, tests[i].expected_output); free(output); } @@ -60,45 +60,45 @@ TEST(expr_add) { TEST(expr_subtract) { char *input = "Hello {{ 5 - 5 }}."; - char *output = template(input, NULL); + char *output = template_string(input, NULL); assert_str(output, "Hello 0."); free(output); } TEST(expr_divide) { char *input = "Hello {{ 5 / 5 }}."; - char *output = template(input, NULL); + char *output = template_string(input, NULL); assert_str(output, "Hello 1."); free(output); } TEST(expr_multiply) { char *input = "Hello {{ 5 * 5 }}."; - char *output = template(input, NULL); + char *output = template_string(input, NULL); assert_str(output, "Hello 25."); free(output); } TEST(expr_gt) { char *input = "Hello {{ 5 > 4 }}."; - char *output = template(input, NULL); + char *output = template_string(input, NULL); assert_str(output, "Hello 1."); free(output); input = "Hello {{ 5 > 6 }}."; - output = template(input, NULL); + output = template_string(input, NULL); assert_str(output, "Hello 0."); free(output); } TEST(expr_lt) { char *input = "Hello {{ 5 < 4 }}."; - char *output = template(input, NULL); + char *output = template_string(input, NULL); assert_str(output, "Hello 0."); free(output); input = "Hello {{ 4 < 5 }}."; - output = template(input, NULL); + output = template_string(input, NULL); assert_str(output, "Hello 1."); free(output); } @@ -107,7 +107,7 @@ TEST(expr_whitespace) { char *input = "Hello \n{{-name -}}\n."; struct hashmap *ctx = hashmap_new(); hashmap_insert(ctx, "name", "world"); - char *output = template(input, ctx); + char *output = template_string(input, ctx); assert_str(output, "Helloworld."); hashmap_free(ctx); free(output); @@ -123,7 +123,7 @@ TEST(for_block) { vector_push(names, "Eric"); hashmap_insert(ctx, "names", names); - char *output = template(input, ctx); + char *output = template_string(input, ctx); assert_str(output, "John, Sally, Eric, "); vector_free(names); hashmap_free(ctx); @@ -138,7 +138,7 @@ TEST(var_dot_notation) { struct hashmap *ctx = hashmap_new(); hashmap_insert(ctx, "user", user); - char *output = template(input, ctx); + char *output = template_string(input, ctx); assert_str(output, "Hello Danny!"); hashmap_free(ctx); free(output); @@ -146,7 +146,7 @@ TEST(var_dot_notation) { TEST(comments) { char *input = "Hello {# comment here #}world."; - char *output = template(input, NULL); + char *output = template_string(input, NULL); assert_str(output, "Hello world."); free(output); } @@ -168,7 +168,7 @@ TEST(if_block) { hashmap_insert(ctx, "name", "Danny"); hashmap_insert(ctx, "age", "29"); for (int i=0; i < ARRAY_SIZE(tests); i++) { - char *output = template(tests[i].input, ctx); + char *output = template_string(tests[i].input, ctx); assert_str(output, tests[i].expected_output); free(output); } @@ -193,7 +193,7 @@ TEST(if_else_block) { hashmap_insert(ctx, "name", "Danny"); hashmap_insert(ctx, "age", "29"); for (int i=0; i < ARRAY_SIZE(tests); i++) { - char *output = template(tests[i].input, ctx); + char *output = template_string(tests[i].input, ctx); assert_str(output, tests[i].expected_output); free(output); } @@ -209,7 +209,7 @@ TEST(buffer_alloc) { char *text = "Lorem ipsum dolor sit amet."; hashmap_insert(ctx, "n", text); - char *output = template(input, ctx); + char *output = template_string(input, ctx); assert_str(output, text); hashmap_free(ctx); free(output); @@ -217,7 +217,7 @@ TEST(buffer_alloc) { TEST(directory) { struct env *env = env_new("./tests/data/01/"); - char *output = render(env, "child.tmpl", NULL); + char *output = template(env, "child.tmpl", NULL); assert_str(output, "Header\n\nChild content\n\nFooter"); free(output); env_free(env); |