#include #include #include #include #include #include #include "types.h" ENTT_API void set_up(); ENTT_API void tear_down(); 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)); set_up(); entt::meta().conv(); ASSERT_TRUE(entt::resolve("position"_hs)); ASSERT_TRUE(entt::resolve("velocity"_hs)); ASSERT_EQ(entt::resolve(), entt::resolve("position"_hs)); ASSERT_EQ(entt::resolve(), entt::resolve("velocity"_hs)); auto pos = entt::resolve("position"_hs).construct(42., 3.); auto vel = entt::resolve("velocity"_hs).construct(); ASSERT_TRUE(pos && vel); ASSERT_EQ(pos.type().data("x"_hs).type(), entt::resolve()); ASSERT_NE(pos.type().data("y"_hs).get(pos).try_cast(), nullptr); ASSERT_EQ(pos.type().data("x"_hs).get(pos).cast(), 42); ASSERT_EQ(pos.type().data("y"_hs).get(pos).cast(), 3); ASSERT_EQ(vel.type().data("dx"_hs).type(), entt::resolve()); ASSERT_TRUE(vel.type().data("dy"_hs).get(vel).allow_cast()); ASSERT_EQ(vel.type().data("dx"_hs).get(vel).cast(), 0.); ASSERT_EQ(vel.type().data("dy"_hs).get(vel).cast(), 0.); ASSERT_EQ(wrap_int(42).type(), entt::resolve()); ASSERT_EQ(wrap_int(42).cast(), 42); tear_down(); ASSERT_FALSE(entt::resolve("position"_hs)); ASSERT_FALSE(entt::resolve("velocity"_hs)); }