Skip to content

Commit

Permalink
add test case: get_object_created_by_lua
Browse files Browse the repository at this point in the history
  • Loading branch information
peacalm committed Jun 28, 2023
1 parent 60d37f3 commit c46575b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/unit_test/register_member.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1332,3 +1332,13 @@ TEST(register_member, luavalueref) {
l.lset("foo", "a", "x", 1);
EXPECT_EQ(l.eval<int>("return foo.a.x"), 1);
}

TEST(register_member, get_object_created_by_lua) {
luaw l;
l.register_member("i", &Obj::i);
l.register_ctor<Obj()>("NewObj");
l.dostring("a = NewObj(); a.i = 3;");
Obj a = l.get<Obj>("a");
EXPECT_EQ(a.i, 3);
EXPECT_EQ(a.ci, 1);
}

0 comments on commit c46575b

Please sign in to comment.