|
|
@@ -1,4 +1,6 @@
|
|
|
#include <gtest/gtest.h>
|
|
|
+#include <common/boxed_type.h>
|
|
|
+#include <common/empty.h>
|
|
|
#include <entt/core/attribute.h>
|
|
|
#include <entt/core/hashed_string.hpp>
|
|
|
#include <entt/locator/locator.hpp>
|
|
|
@@ -6,7 +8,6 @@
|
|
|
#include <entt/meta/factory.hpp>
|
|
|
#include <entt/meta/meta.hpp>
|
|
|
#include <entt/meta/resolve.hpp>
|
|
|
-#include "../common/types.h"
|
|
|
|
|
|
ENTT_API void share(const entt::locator<entt::meta_ctx>::node_type &);
|
|
|
ENTT_API void set_up();
|
|
|
@@ -16,42 +17,36 @@ ENTT_API entt::meta_any wrap_int(int);
|
|
|
TEST(Lib, Meta) {
|
|
|
using namespace entt::literals;
|
|
|
|
|
|
- ASSERT_FALSE(entt::resolve("position"_hs));
|
|
|
- ASSERT_FALSE(entt::resolve("velocity"_hs));
|
|
|
+ ASSERT_FALSE(entt::resolve("boxed_int"_hs));
|
|
|
+ ASSERT_FALSE(entt::resolve("empty"_hs));
|
|
|
|
|
|
share(entt::locator<entt::meta_ctx>::handle());
|
|
|
set_up();
|
|
|
- entt::meta<double>().conv<int>();
|
|
|
|
|
|
- ASSERT_TRUE(entt::resolve("position"_hs));
|
|
|
- ASSERT_TRUE(entt::resolve("velocity"_hs));
|
|
|
+ ASSERT_TRUE(entt::resolve("boxed_int"_hs));
|
|
|
+ ASSERT_TRUE(entt::resolve("empty"_hs));
|
|
|
|
|
|
- ASSERT_EQ(entt::resolve<position>(), entt::resolve("position"_hs));
|
|
|
- ASSERT_EQ(entt::resolve<velocity>(), entt::resolve("velocity"_hs));
|
|
|
+ ASSERT_EQ(entt::resolve<test::boxed_int>(), entt::resolve("boxed_int"_hs));
|
|
|
+ ASSERT_EQ(entt::resolve<test::empty>(), entt::resolve("empty"_hs));
|
|
|
|
|
|
- auto pos = entt::resolve("position"_hs).construct(4., 3.);
|
|
|
- auto vel = entt::resolve("velocity"_hs).construct();
|
|
|
+ auto boxed_int = entt::resolve("boxed_int"_hs).construct(4.);
|
|
|
+ auto empty = entt::resolve("empty"_hs).construct();
|
|
|
|
|
|
- ASSERT_TRUE(pos && vel);
|
|
|
+ ASSERT_TRUE(boxed_int);
|
|
|
+ ASSERT_TRUE(empty);
|
|
|
|
|
|
- ASSERT_EQ(pos.type().data("x"_hs).type(), entt::resolve<int>());
|
|
|
- ASSERT_NE(pos.type().data("y"_hs).get(pos).try_cast<int>(), nullptr);
|
|
|
- ASSERT_EQ(pos.type().data("x"_hs).get(pos).cast<int>(), 4);
|
|
|
- ASSERT_EQ(pos.type().data("y"_hs).get(pos).cast<int>(), 3);
|
|
|
+ ASSERT_EQ(boxed_int.type().data("value"_hs).type(), entt::resolve<int>());
|
|
|
+ ASSERT_NE(boxed_int.get("value"_hs).try_cast<int>(), nullptr);
|
|
|
+ ASSERT_EQ(boxed_int.get("value"_hs).cast<int>(), 4);
|
|
|
|
|
|
- ASSERT_EQ(vel.type().data("dx"_hs).type(), entt::resolve<double>());
|
|
|
- ASSERT_TRUE(vel.type().data("dy"_hs).get(vel).allow_cast<double>());
|
|
|
- ASSERT_EQ(vel.type().data("dx"_hs).get(vel).cast<double>(), 0.);
|
|
|
- ASSERT_EQ(vel.type().data("dy"_hs).get(vel).cast<double>(), 0.);
|
|
|
-
|
|
|
- pos.reset();
|
|
|
- vel.reset();
|
|
|
+ boxed_int.reset();
|
|
|
+ empty.reset();
|
|
|
|
|
|
ASSERT_EQ(wrap_int(4).type(), entt::resolve<int>());
|
|
|
ASSERT_EQ(wrap_int(4).cast<int>(), 4);
|
|
|
|
|
|
tear_down();
|
|
|
|
|
|
- ASSERT_FALSE(entt::resolve("position"_hs));
|
|
|
- ASSERT_FALSE(entt::resolve("velocity"_hs));
|
|
|
+ ASSERT_FALSE(entt::resolve("boxed_int"_hs));
|
|
|
+ ASSERT_FALSE(entt::resolve("empty"_hs));
|
|
|
}
|