diff options
author | Joseph Hunkeler <jhunkeler@users.noreply.github.com> | 2025-02-12 17:04:01 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-12 17:04:01 -0500 |
commit | 09de456a667a771348c3f1c9b0bd56afe4b8d3bd (patch) | |
tree | aedfcbb0b2876e3d7aad28a7cc09354a611c156e /tests/test_template.c | |
parent | 2bd06b22e455fa154e7db27677421c8b53cbf43c (diff) | |
parent | 4e22506e086e02ffe3056c6fd39ccb201fd358c8 (diff) | |
download | stasis-09de456a667a771348c3f1c9b0bd56afe4b8d3bd.tar.gz |
Merge pull request #89 from jhunkeler/huge-changeset
Huge changeset
Diffstat (limited to 'tests/test_template.c')
-rw-r--r-- | tests/test_template.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/tests/test_template.c b/tests/test_template.c index 79fce5e..596c2b7 100644 --- a/tests/test_template.c +++ b/tests/test_template.c @@ -47,9 +47,15 @@ void test_tpl_workflow() { tpl_reset(); tpl_register("hello_message", &data); - STASIS_ASSERT(strcmp(tpl_render("I said, \"{{ hello_message }}\""), "I said, \"Hello world!\"") == 0, "stored value in key is incorrect"); + char *result = NULL; + result = tpl_render("I said, \"{{ hello_message }}\""); + STASIS_ASSERT(strcmp(result, "I said, \"Hello world!\"") == 0, "stored value in key is incorrect"); + guard_free(result); + setenv("HELLO", "Hello environment!", 1); - STASIS_ASSERT(strcmp(tpl_render("{{ env:HELLO }}"), "Hello environment!") == 0, "environment variable content mismatch"); + result = tpl_render("{{ env:HELLO }}"); + STASIS_ASSERT(strcmp(result, "Hello environment!") == 0, "environment variable content mismatch"); + guard_free(result); unsetenv("HELLO"); guard_free(data); } @@ -87,18 +93,25 @@ void test_tpl_register_func() { char *result = NULL; result = tpl_render("{{ func:add(0,3) }}"); STASIS_ASSERT(result != NULL && strcmp(result, "3") == 0, "Answer was not 3"); + guard_free(result); result = tpl_render("{{ func:add(1,2) }}"); STASIS_ASSERT(result != NULL && strcmp(result, "3") == 0, "Answer was not 3"); + guard_free(result); result = tpl_render("{{ func:sub(6,3) }}"); STASIS_ASSERT(result != NULL && strcmp(result, "3") == 0, "Answer was not 3"); + guard_free(result); result = tpl_render("{{ func:sub(4,1) }}"); STASIS_ASSERT(result != NULL && strcmp(result, "3") == 0, "Answer was not 3"); + guard_free(result); result = tpl_render("{{ func:mul(1, 3) }}"); STASIS_ASSERT(result != NULL && strcmp(result, "3") == 0, "Answer was not 3"); + guard_free(result); result = tpl_render("{{ func:div(6,2) }}"); STASIS_ASSERT(result != NULL && strcmp(result, "3") == 0, "Answer was not 3"); + guard_free(result); result = tpl_render("{{ func:div(3,1) }}"); STASIS_ASSERT(result != NULL && strcmp(result, "3") == 0, "Answer was not 3"); + guard_free(result); } int main(int argc, char *argv[]) { |