Skip to content

Commit

Permalink
Some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kunitoki committed Sep 30, 2023
1 parent b40c42b commit a7ab690
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Tests/Source/ClassTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,23 @@ struct ClassProperties : ClassTests
{
};

TEST_F(ClassProperties, FieldPointersNonRegistered)
{
using Int = Class<int, EmptyBase>;
using UnregisteredInt = Class<long, EmptyBase>;

luabridge::getGlobalNamespace(L)
.beginClass<Int>("Int")
.addProperty("staticData", [](const Int&) { return UnregisteredInt(1); })
.endClass();

#if LUABRIDGE_HAS_EXCEPTIONS
ASSERT_THROW(runLua("result = Int.staticData"), std::exception);
#else
ASSERT_FALSE(runLua("result = Int.staticData"));
#endif
}

TEST_F(ClassProperties, FieldPointers)
{
using Int = Class<int, EmptyBase>;
Expand Down Expand Up @@ -1642,6 +1659,23 @@ struct ClassStaticProperties : ClassTests
{
};

TEST_F(ClassStaticProperties, FieldPointersNonRegistered)
{
using Int = Class<int, EmptyBase>;
using UnregisteredInt = Class<long, EmptyBase>;

luabridge::getGlobalNamespace(L)
.beginClass<Int>("Int")
.addStaticProperty("staticData", [] { return UnregisteredInt(1); })
.endClass();

#if LUABRIDGE_HAS_EXCEPTIONS
ASSERT_THROW(runLua("result = Int.staticData"), std::exception);
#else
ASSERT_FALSE(runLua("result = Int.staticData"));
#endif
}

TEST_F(ClassStaticProperties, FieldPointers)
{
using Int = Class<int, EmptyBase>;
Expand Down

0 comments on commit a7ab690

Please sign in to comment.