Add regression tests for issue #48.

This commit is contained in:
Rapptz 2014-09-05 16:06:48 -04:00
parent e9c3bed27e
commit e015dace71

View File

@ -855,3 +855,19 @@ TEST_CASE("userdata/nonmember functions implement functionality", "let users set
"t:gief_stuff(20)\n")); "t:gief_stuff(20)\n"));
REQUIRE((lua.get<giver>("t").a == 20)); REQUIRE((lua.get<giver>("t").a == 20));
} }
TEST_CASE("regressions/one", "issue number 48") {
struct vars {
int boop = 0;
};
sol::state lua;
lua.new_userdata<vars>("vars", "boop", &vars::boop);
REQUIRE_NOTHROW(lua.script("local beep = vars.new()\n"
"beep.boop = 1"));
// test for segfault
auto my_var = lua.get<vars>("beep");
REQUIRE(my_var.boop == 1);
auto* ptr = &my_var;
REQUIRE(ptr->boop == 1);
}