From 26a1adffd4ac7b4f1390ba0135ede850697c4dfa Mon Sep 17 00:00:00 2001 From: Danny van Kooten Date: Fri, 20 Mar 2020 12:11:20 +0100 Subject: add string equality operators --- tests/test_template.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'tests') diff --git a/tests/test_template.c b/tests/test_template.c index 039e993..d94ddd6 100644 --- a/tests/test_template.c +++ b/tests/test_template.c @@ -309,6 +309,22 @@ TEST(expr_eq) { } } +TEST(expr_string_eq) { + struct { + char *input; + char *expected_output; + } tests[] = { + {"{% if \"foo\" == \"bar\" %}1{% endif %}", ""}, + {"{% if \"foo\" == \"foo\" %}1{% endif %}", "1"}, + }; + + for (int i=0; i < ARRAY_SIZE(tests); i++) { + char *output = template_string(tests[i].input, NULL); + assert_str(output, tests[i].expected_output); + free(output); + } +} + TEST(expr_not_eq) { struct { char *input; @@ -325,6 +341,22 @@ TEST(expr_not_eq) { } } +TEST(expr_string_not_eq) { + struct { + char *input; + char *expected_output; + } tests[] = { + {"{% if \"foo\" != \"bar\" %}1{% endif %}", "1"}, + {"{% if \"foo\" != \"foo\" %}1{% endif %}", ""}, + }; + + for (int i=0; i < ARRAY_SIZE(tests); i++) { + char *output = template_string(tests[i].input, NULL); + assert_str(output, tests[i].expected_output); + free(output); + } +} + TEST(if_block_whitespace) { char *input = "\n{%- if 10 > 5 -%}\nOK\n{%- endif -%}\n"; char *output = template_string(input, NULL); -- cgit v1.2.3