Browse Source

test: added meta_basic

Michele Caini 5 years ago
parent
commit
320d815d60
3 changed files with 27 additions and 15 deletions
  1. 1 0
      test/CMakeLists.txt
  2. 0 15
      test/entt/meta/meta.cpp
  3. 26 0
      test/entt/meta/meta_basic.cpp

+ 1 - 0
test/CMakeLists.txt

@@ -178,6 +178,7 @@ SETUP_BASIC_TEST(locator entt/locator/locator.cpp)
 # Test meta
 
 list(APPEND TEST_META_SOURCES entt/meta/meta.cpp entt/meta/fixture.cpp)
+SETUP_BASIC_TEST(meta_basic entt/meta/meta_basic.cpp)
 SETUP_BASIC_TEST(meta "${TEST_META_SOURCES}")
 
 # Test process

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

@@ -9,21 +9,6 @@
 #include <entt/meta/resolve.hpp>
 #include "fixture.h"
 
-TEST_F(Meta, Resolve) {
-    ASSERT_EQ(entt::resolve<derived_type>(), entt::resolve_id("derived"_hs));
-    ASSERT_EQ(entt::resolve<derived_type>(), entt::resolve_type(entt::type_info<derived_type>::id()));
-    // it could be "char"_hs rather than entt::hashed_string::value("char") if it weren't for a bug in VS2017
-    ASSERT_EQ(entt::resolve_if([](auto type) { return type.id() == entt::hashed_string::value("char"); }), entt::resolve<char>());
-
-    bool found = false;
-
-    entt::resolve([&found](auto type) {
-        found = found || type == entt::resolve<derived_type>();
-    });
-
-    ASSERT_TRUE(found);
-}
-
 TEST_F(Meta, MetaAnySBO) {
     entt::meta_any any{'c'};
 

+ 26 - 0
test/entt/meta/meta_basic.cpp

@@ -0,0 +1,26 @@
+#include <gtest/gtest.h>
+#include <entt/core/hashed_string.hpp>
+#include <entt/meta/factory.hpp>
+#include <entt/meta/resolve.hpp>
+
+struct Meta: ::testing::Test {
+    static void SetUpTestCase() {
+        entt::meta<char>().type("char"_hs);
+        entt::meta<double>().type("double"_hs);
+    }
+};
+
+TEST_F(Meta, Resolve) {
+    ASSERT_EQ(entt::resolve<double>(), entt::resolve_id("double"_hs));
+    ASSERT_EQ(entt::resolve<double>(), entt::resolve_type(entt::type_info<double>::id()));
+    // it could be "char"_hs rather than entt::hashed_string::value("char") if it weren't for a bug in VS2017
+    ASSERT_EQ(entt::resolve_if([](auto type) { return type.id() == entt::hashed_string::value("char"); }), entt::resolve<char>());
+
+    bool found = false;
+
+    entt::resolve([&found](auto type) {
+        found = found || type == entt::resolve<double>();
+    });
+
+    ASSERT_TRUE(found);
+}