diff options
author | Danny van Kooten <dannyvankooten@users.noreply.github.com> | 2020-03-20 12:11:20 +0100 |
---|---|---|
committer | Danny van Kooten <dannyvankooten@users.noreply.github.com> | 2020-03-20 12:11:20 +0100 |
commit | 26a1adffd4ac7b4f1390ba0135ede850697c4dfa (patch) | |
tree | fb785b007b5e9decd9667c32782b2c17dd2f1f57 /tests | |
parent | 306f057f985260d334a5e54405273f910120523c (diff) | |
download | unja-26a1adffd4ac7b4f1390ba0135ede850697c4dfa.tar.gz unja-26a1adffd4ac7b4f1390ba0135ede850697c4dfa.zip |
add string equality operators
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_template.c | 32 |
1 files changed, 32 insertions, 0 deletions
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); |