Sfoglia il codice sorgente

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

skypjack 4 mesi fa
parent
commit
d92bea4afd
2 ha cambiato i file con 26 aggiunte e 4 eliminazioni
  1. 12 0
      test/entt/meta/meta_func.cpp
  2. 14 4
      test/entt/meta/meta_type.cpp

+ 12 - 0
test/entt/meta/meta_func.cpp

@@ -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) {

+ 14 - 4
test/entt/meta/meta_type.cpp

@@ -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) {