diff options
-rw-r--r-- | src/test.c | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -634,6 +634,30 @@ TEST(parse_all) return 0; } +TEST(parse_readme_example) +{ + lua_pushboolean(L, true); + lua_pushinteger(L, 7); + lua_getglobal(L, "debug"); + int expected = lua_gettop(L); + lua_pushnumber(L, 3.1415f); + lua_pushstring(L, "c: c: c:"); + void *userdata = lua_newuserdata(L, sizeof(char)); + + 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); + + mu_assert("failed to properly parse boolean!", b); + mu_assert("failed to properly parse integer!", i == 7); + mu_assert("failed to properly parse table!", table_index == expected); + mu_assert("failed to properly parse number!", f == 3.1415f); + mu_assert("failed to properly parse string!", strcmp(str, "c: c: c:") == 0); + mu_assert("failed to properly parse userdata!", user == userdata); + return 0; +} + /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @@ -834,6 +858,7 @@ int main() 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); printf("running hs_parse_overloaded() parsing tests...\n"); mu_run_test("parse bool overloaded", parse_bool_overloaded); |