test: non-regression tests for meta_type::lookup constness

This commit is contained in:
skypjack
2025-10-27 00:01:13 +01:00
parent bbfd458d2d
commit d92bea4afd
2 changed files with 26 additions and 4 deletions

View File

@@ -654,6 +654,12 @@ TEST_F(MetaFunc, OverloadedConstFirst) {
ASSERT_EQ(func.invoke(std::as_const(instance), 1).cast<int>(), 2);
ASSERT_FALSE(next.invoke(std::as_const(instance), 1));
ASSERT_EQ(func.invoke(entt::meta_handle{instance}, entt::meta_any{1}).cast<int>(), 2);
ASSERT_EQ(next.invoke(entt::meta_handle{instance}, entt::meta_any{1}).cast<int>(), 1);
ASSERT_EQ(func.invoke(entt::meta_handle{std::as_const(instance)}, entt::meta_any{1}).cast<int>(), 2);
ASSERT_FALSE(next.invoke(entt::meta_handle{std::as_const(instance)}, entt::meta_any{1}));
}
TEST_F(MetaFunc, OverloadedNonConstFirst) {
@@ -680,6 +686,12 @@ TEST_F(MetaFunc, OverloadedNonConstFirst) {
ASSERT_FALSE(func.invoke(std::as_const(instance), 1));
ASSERT_EQ(next.invoke(std::as_const(instance), 1).cast<int>(), 2);
ASSERT_EQ(func.invoke(entt::meta_handle{instance}, entt::meta_any{1}).cast<int>(), 1);
ASSERT_EQ(next.invoke(entt::meta_handle{instance}, entt::meta_any{1}).cast<int>(), 2);
ASSERT_FALSE(func.invoke(entt::meta_handle{std::as_const(instance)}, entt::meta_any{1}));
ASSERT_EQ(next.invoke(entt::meta_handle{std::as_const(instance)}, entt::meta_any{1}).cast<int>(), 2);
}
TEST_F(MetaFunc, OverloadedOrder) {

View File

@@ -575,10 +575,15 @@ TEST_F(MetaType, OverloadedFuncConstFirst) {
ASSERT_TRUE(res);
ASSERT_EQ(res.cast<int>(), 2);
res = type.invoke("cf"_hs, overloaded_func{3}, 1);
res = type.invoke("cf"_hs, entt::meta_handle{instance}, entt::meta_any{1});
ASSERT_TRUE(res);
ASSERT_EQ(res.cast<int>(), 6);
ASSERT_EQ(res.cast<int>(), 4);
res = type.invoke("cf"_hs, entt::meta_handle{std::as_const(instance)}, entt::meta_any{1});
ASSERT_TRUE(res);
ASSERT_EQ(res.cast<int>(), 2);
}
TEST_F(MetaType, OverloadedFuncNonConstFirst) {
@@ -600,10 +605,15 @@ TEST_F(MetaType, OverloadedFuncNonConstFirst) {
ASSERT_TRUE(res);
ASSERT_EQ(res.cast<int>(), 2);
res = type.invoke("ncf"_hs, overloaded_func{3}, 1);
res = type.invoke("ncf"_hs, entt::meta_handle{instance}, entt::meta_any{1});
ASSERT_TRUE(res);
ASSERT_EQ(res.cast<int>(), 6);
ASSERT_EQ(res.cast<int>(), 4);
res = type.invoke("ncf"_hs, entt::meta_handle{std::as_const(instance)}, entt::meta_any{1});
ASSERT_TRUE(res);
ASSERT_EQ(res.cast<int>(), 2);
}
TEST_F(MetaType, OverloadedFuncOrder) {