diff options
Diffstat (limited to 'src')
-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); |