skypjack 1 день назад
Родитель
Сommit
cda3517bad
3 измененных файлов с 38 добавлено и 1 удалено
  1. 0 1
      TODO
  2. 6 0
      test/entt/meta/meta_context.cpp
  3. 32 0
      test/entt/meta/meta_factory.cpp

+ 0 - 1
TODO

@@ -34,5 +34,4 @@ TODO:
 * try to fully support uint16_t for entity types
 * try to fully support uint16_t for entity types
 * document new meta multi support (md)
 * document new meta multi support (md)
 * use meta_any::type(value) with from_void and the like to avoid lookups in some cases
 * use meta_any::type(value) with from_void and the like to avoid lookups in some cases
-* more tests for fast lookups on resolve and meta reset
 * finish the imgui viewer/editor!
 * finish the imgui viewer/editor!

+ 6 - 0
test/entt/meta/meta_context.cpp

@@ -187,6 +187,12 @@ TEST_F(MetaContext, Resolve) {
     ASSERT_FALSE(entt::resolve("local"_hs));
     ASSERT_FALSE(entt::resolve("local"_hs));
     ASSERT_TRUE(entt::resolve(ctx(), "local"_hs));
     ASSERT_TRUE(entt::resolve(ctx(), "local"_hs));
 
 
+    ASSERT_FALSE(entt::resolve(entt::type_hash<void>::value()));
+    ASSERT_FALSE(entt::resolve(ctx(), entt::type_hash<void>::value()));
+
+    ASSERT_TRUE(entt::resolve(entt::type_hash<int>::value()));
+    ASSERT_TRUE(entt::resolve(ctx(), entt::type_hash<int>::value()));
+
     ASSERT_EQ((std::distance(entt::resolve().cbegin(), entt::resolve().cend())), 5);
     ASSERT_EQ((std::distance(entt::resolve().cbegin(), entt::resolve().cend())), 5);
     ASSERT_EQ((std::distance(entt::resolve(ctx()).cbegin(), entt::resolve(ctx()).cend())), 7);
     ASSERT_EQ((std::distance(entt::resolve(ctx()).cbegin(), entt::resolve(ctx()).cend())), 7);
 }
 }

+ 32 - 0
test/entt/meta/meta_factory.cpp

@@ -583,6 +583,22 @@ TEST_F(MetaFactory, MetaReset) {
     ASSERT_TRUE(entt::resolve(entt::type_id<int>()));
     ASSERT_TRUE(entt::resolve(entt::type_id<int>()));
     ASSERT_TRUE(entt::resolve(ctx, entt::type_id<int>()));
     ASSERT_TRUE(entt::resolve(ctx, entt::type_id<int>()));
 
 
+    entt::meta_reset(entt::type_hash<int>::value());
+
+    ASSERT_FALSE(entt::resolve(entt::type_id<int>()));
+    ASSERT_TRUE(entt::resolve(ctx, entt::type_id<int>()));
+
+    entt::meta_reset(ctx, entt::type_hash<int>::value());
+
+    ASSERT_FALSE(entt::resolve(entt::type_id<int>()));
+    ASSERT_FALSE(entt::resolve(ctx, entt::type_id<int>()));
+
+    entt::meta_factory<int>{}.type("global"_hs);
+    entt::meta_factory<int>{ctx}.type("local"_hs);
+
+    ASSERT_TRUE(entt::resolve(entt::type_id<int>()));
+    ASSERT_TRUE(entt::resolve(ctx, entt::type_id<int>()));
+
     entt::meta_reset("global"_hs);
     entt::meta_reset("global"_hs);
 
 
     ASSERT_FALSE(entt::resolve(entt::type_id<int>()));
     ASSERT_FALSE(entt::resolve(entt::type_id<int>()));
@@ -592,4 +608,20 @@ TEST_F(MetaFactory, MetaReset) {
 
 
     ASSERT_FALSE(entt::resolve(entt::type_id<int>()));
     ASSERT_FALSE(entt::resolve(entt::type_id<int>()));
     ASSERT_FALSE(entt::resolve(ctx, entt::type_id<int>()));
     ASSERT_FALSE(entt::resolve(ctx, entt::type_id<int>()));
+
+    entt::meta_factory<int>{"global"_hs};
+    entt::meta_factory<int>{ctx, "local"_hs};
+
+    ASSERT_TRUE(entt::resolve("global"_hs));
+    ASSERT_TRUE(entt::resolve(ctx, "local"_hs));
+
+    entt::meta_reset("global"_hs);
+
+    ASSERT_FALSE(entt::resolve("global"_hs));
+    ASSERT_TRUE(entt::resolve(ctx, "local"_hs));
+
+    entt::meta_reset(ctx, "local"_hs);
+
+    ASSERT_FALSE(entt::resolve("global"_hs));
+    ASSERT_FALSE(entt::resolve(ctx, "local"_hs));
 }
 }