diff options
author | sanine-a <sanine.not@pm.me> | 2021-05-27 21:47:10 -0500 |
---|---|---|
committer | sanine-a <sanine.not@pm.me> | 2021-05-27 21:47:10 -0500 |
commit | 6e5972d05275076f9b7e3fbf9b5ac7bcbcef2cdc (patch) | |
tree | fc6aca30e2517d3ccea48263a4e11049e8ca4b3d | |
parent | a02326f48e1afc823b3a2fdddc50982a5ec9598d (diff) |
add common 'extra argument' overload test
-rw-r--r-- | src/test.c | 38 |
1 files changed, 37 insertions, 1 deletions
@@ -771,6 +771,40 @@ TEST(parse_nil_overloaded) return 0; } +TEST(parse_2_3_overload_0) +{ + lua_pushinteger(L, 69); + lua_pushstring(L, "foo"); + int i; char *str; void *data; + int choice = hs_parse_overloaded + (L, HS_INT, &i, HS_STR, &str, HS_END, + HS_INT, &i, HS_STR, &str, HS_USER, &data, HS_END, + HS_END); + + mu_assert("incorrectly selected option other than 0!", choice == 0); + mu_assert("failed to properly parse integer!", i == 69); + mu_assert("failed to properly parse string!", strcmp(str, "foo") == 0); + return 0; +} + +TEST(parse_2_3_overload_1) +{ + lua_pushinteger(L, 69); + lua_pushstring(L, "foo"); + void *userdata = lua_newuserdata(L, sizeof(char)); + int i; char *str; void *data; + int choice = hs_parse_overloaded + (L, HS_INT, &i, HS_STR, &str, HS_END, + HS_INT, &i, HS_STR, &str, HS_USER, &data, HS_END, + HS_END); + + mu_assert("incorrectly selected option other than 1!", choice == 1); + mu_assert("failed to properly parse integer!", i == 69); + mu_assert("failed to properly parse string!", strcmp(str, "foo") == 0); + mu_assert("failed to properly parse userdata!", userdata == data); + return 0; +} + /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @@ -871,7 +905,9 @@ int main() mu_run_test("parse userdata overloaded", parse_userdata_overloaded); mu_run_test("parse lightuserdata overloaded", parse_lightuserdata_overloaded); mu_run_test("parse nil overloaded", parse_nil_overloaded); - + mu_run_test("parse 2/3 overload 0", parse_2_3_overload_0); + mu_run_test("parse 2/3 overload 1", parse_2_3_overload_1); + printf("running hs_pushstring() tests...\n"); mu_run_test("hs_pushstring (no printf formatting)", push_noformat); mu_run_test("hs_pushstring (integer formatting)", push_formatint); |