Browse Source

test: more on meta_data

Michele Caini 5 years ago
parent
commit
6b2468f033
2 changed files with 13 additions and 16 deletions
  1. 0 15
      test/entt/meta/meta.cpp
  2. 13 1
      test/entt/meta/meta_data.cpp

+ 0 - 15
test/entt/meta/meta.cpp

@@ -9,21 +9,6 @@
 #include <entt/meta/resolve.hpp>
 #include <entt/meta/resolve.hpp>
 #include "fixture.h"
 #include "fixture.h"
 
 
-TEST_F(Meta, MetaDataFromBase) {
-    auto type = entt::resolve<concrete_type>();
-    concrete_type instance;
-
-    ASSERT_TRUE(type.data("i"_hs));
-    ASSERT_TRUE(type.data("j"_hs));
-
-    ASSERT_EQ(instance.i, 0);
-    ASSERT_EQ(instance.j, char{});
-    ASSERT_TRUE(type.data("i"_hs).set(instance, 3));
-    ASSERT_TRUE(type.data("j"_hs).set(instance, 'c'));
-    ASSERT_EQ(instance.i, 3);
-    ASSERT_EQ(instance.j, 'c');
-}
-
 TEST_F(Meta, MetaFuncFromBase) {
 TEST_F(Meta, MetaFuncFromBase) {
     auto type = entt::resolve<concrete_type>();
     auto type = entt::resolve<concrete_type>();
     auto base = entt::resolve<an_abstract_type>();
     auto base = entt::resolve<an_abstract_type>();

+ 13 - 1
test/entt/meta/meta_data.cpp

@@ -11,6 +11,7 @@ struct base_t {
     }
     }
 
 
     inline static int counter = 0;
     inline static int counter = 0;
+    int value{3};
 };
 };
 
 
 struct derived_t: base_t {};
 struct derived_t: base_t {};
@@ -64,7 +65,7 @@ enum class property_t {
 struct Meta: ::testing::Test {
 struct Meta: ::testing::Test {
     static void SetUpTestCase() {
     static void SetUpTestCase() {
         entt::meta<double>().conv<int>();
         entt::meta<double>().conv<int>();
-        entt::meta<base_t>().dtor<&base_t::destroy>();
+        entt::meta<base_t>().dtor<&base_t::destroy>().data<&base_t::value>("value"_hs);
         entt::meta<derived_t>().base<base_t>().dtor<&derived_t::destroy>();
         entt::meta<derived_t>().base<base_t>().dtor<&derived_t::destroy>();
 
 
         entt::meta<clazz_t>().type("clazz"_hs)
         entt::meta<clazz_t>().type("clazz"_hs)
@@ -424,3 +425,14 @@ TEST_F(Meta, MetaDataAsRef) {
     ASSERT_NE(instance.h, 3);
     ASSERT_NE(instance.h, 3);
     ASSERT_EQ(instance.i, 3);
     ASSERT_EQ(instance.i, 3);
 }
 }
+
+TEST_F(Meta, MetaDataFromBase) {
+    auto type = entt::resolve<derived_t>();
+    derived_t instance;
+
+    ASSERT_TRUE(type.data("value"_hs));
+
+    ASSERT_EQ(instance.value, 3);
+    ASSERT_TRUE(type.data("value"_hs).set(instance, 42));
+    ASSERT_EQ(instance.value, 42);
+}