mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Add regression tests for issue #48.
This commit is contained in:
parent
e9c3bed27e
commit
e015dace71
16
tests.cpp
16
tests.cpp
|
@ -855,3 +855,19 @@ TEST_CASE("userdata/nonmember functions implement functionality", "let users set
|
|||
"t:gief_stuff(20)\n"));
|
||||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user