From e015dace715d5ee38f38b6cd91b26e862e86e4f5 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Fri, 5 Sep 2014 16:06:48 -0400 Subject: [PATCH] Add regression tests for issue #48. --- tests.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests.cpp b/tests.cpp index df8284df..fc67753c 100644 --- a/tests.cpp +++ b/tests.cpp @@ -855,3 +855,19 @@ TEST_CASE("userdata/nonmember functions implement functionality", "let users set "t:gief_stuff(20)\n")); REQUIRE((lua.get("t").a == 20)); } + +TEST_CASE("regressions/one", "issue number 48") { + struct vars { + int boop = 0; + }; + + sol::state lua; + lua.new_userdata("vars", "boop", &vars::boop); + REQUIRE_NOTHROW(lua.script("local beep = vars.new()\n" + "beep.boop = 1")); + // test for segfault + auto my_var = lua.get("beep"); + REQUIRE(my_var.boop == 1); + auto* ptr = &my_var; + REQUIRE(ptr->boop == 1); +}