summaryrefslogtreecommitdiff
path: root/src/tests/hs_parse_args_tests.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/hs_parse_args_tests.c')
-rw-r--r--src/tests/hs_parse_args_tests.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/tests/hs_parse_args_tests.c b/src/tests/hs_parse_args_tests.c
index 39c40fb..a6aa475 100644
--- a/src/tests/hs_parse_args_tests.c
+++ b/src/tests/hs_parse_args_tests.c
@@ -48,7 +48,7 @@ static int testfunc(lua_State *L) { return 0; }
lua_pop(L, 1);
#define CHECK_FAIL_FUNC(name) \
- lua_pushcfunction(L, name ## _testfunc); lua_getglobal(L, "test"); \
+ lua_pushcfunction(L, name ## _testfunc); lua_getglobal(L, "print"); \
mu_assert("incorrectly succeeded in parsing function!", \
lua_pcall(L, 1, 0, 0) != 0); \
lua_pop(L, 1);
@@ -191,11 +191,15 @@ PARSE_TYPECHECK_TEST(parse_func_typecheck, int, hs_func)
CHECK_FAIL_TABLE(parse_func_typecheck);
lua_pushcfunction(L, parse_func_typecheck_testfunc);
- lua_getglobal(L, "test");
+ lua_getglobal(L, "print");
mu_assert("typecheck for function failed!",
lua_pcall(L, 1, 0, 0) == 0);
- CHECK_FAIL_CFUNC(parse_func_typecheck);
+ lua_pushcfunction(L, parse_func_typecheck_testfunc);
+ lua_pushvalue(L, -1);
+ mu_assert("typecheck for C function failed!",
+ lua_pcall(L, 1, 0, 0) == 0);
+
CHECK_FAIL_USER(parse_func_typecheck);
CHECK_FAIL_LIGHT(parse_func_typecheck);
CHECK_FAIL_NIL(parse_func_typecheck);
@@ -534,7 +538,7 @@ TEST(parse_all)
return 0;
}
-/*TEST(parse_readme_example)
+TEST(parse_readme_example)
{
lua_pushboolean(L, true);
lua_pushinteger(L, 7);
@@ -546,8 +550,8 @@ TEST(parse_all)
bool b; int i; int table_index; float f; char *str; void *user;
hs_parse_args
- (L, HS_BOOL, &b, HS_INT, &i, HS_TBL, &table_index,
- HS_NUM, &f, HS_STR, &str, HS_USER, &user, HS_END);
+ (L, hs_bool(b), hs_int(i), hs_tbl(table_index),
+ hs_num(f), hs_str(str), hs_user(user));
mu_assert("failed to properly parse boolean!", b);
mu_assert("failed to properly parse integer!", i == 7);
@@ -556,7 +560,7 @@ TEST(parse_all)
mu_assert("failed to properly parse string!", strcmp(str, "c: c: c:") == 0);
mu_assert("failed to properly parse userdata!", user == userdata);
return 0;
- }*/
+}
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
@@ -594,5 +598,5 @@ void hs_parse_args_tests()
mu_run_test("parse nil", parse_nil);
mu_run_test("parse any", parse_any);
mu_run_test("parse all", parse_all);
- // mu_run_test("parse readme example", parse_readme_example);
+ mu_run_test("parse readme example", parse_readme_example);
}