diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-06-26 13:49:32 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-06-26 13:49:32 -0400 |
commit | d5b5b5b09cf1ffb82d59783663c973f6987fe2d8 (patch) | |
tree | b05cc2f7ba37e67c6bd53d8e2e2b0e6f34acdff0 /tests | |
parent | 34733c7ab93ba3f610038e8ce50edad8b889135e (diff) | |
download | stasis-d5b5b5b09cf1ffb82d59783663c973f6987fe2d8.tar.gz |
Fix test_template::test_tpl_register_func
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_template.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/tests/test_template.c b/tests/test_template.c index 05d8242..d6c2c42 100644 --- a/tests/test_template.c +++ b/tests/test_template.c @@ -59,17 +59,22 @@ void test_tpl_register() { void test_tpl_register_func() { tpl_reset(); - struct tplfunc_frame tasks[] = { + struct testcase { + const char *key; + int argc; + void *func; + }; + struct testcase tc[] = { {.key = "add", .argc = 2, .func = adder}, {.key = "sub", .argc = 2, .func = subtractor}, {.key = "mul", .argc = 2, .func = multiplier}, {.key = "div", .argc = 2, .func = divider}, }; - tpl_register_func("add", &tasks[0]); - tpl_register_func("sub", &tasks[1]); - tpl_register_func("mul", &tasks[2]); - tpl_register_func("div", &tasks[3]); - STASIS_ASSERT(tpl_pool_func_used == sizeof(tasks) / sizeof(*tasks), "unexpected function pool used"); + tpl_register_func("add", &tc[0].func, tc[0].argc); + tpl_register_func("sub", &tc[1].func, tc[1].argc); + tpl_register_func("mul", &tc[2].func, tc[2].argc); + tpl_register_func("div", &tc[3].func, tc[3].argc); + STASIS_ASSERT(tpl_pool_func_used == sizeof(tc) / sizeof(*tc), "unexpected function pool used"); char *result = NULL; result = tpl_render("{{ func:add(0,3) }}"); |