From 2a307a681f0d89dbb79e4fdeb5a37824dc0af5a0 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Wed, 12 Oct 2022 18:30:21 +0200 Subject: [PATCH] test: context aware meta prop --- test/entt/meta/meta_context.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/test/entt/meta/meta_context.cpp b/test/entt/meta/meta_context.cpp index 672df38f7..117efcf45 100644 --- a/test/entt/meta/meta_context.cpp +++ b/test/entt/meta/meta_context.cpp @@ -60,6 +60,7 @@ class MetaContext: public ::testing::Test { entt::meta() .type("foo"_hs) + .prop("prop"_hs, prop_value) .ctor() .data<&clazz::value>("value"_hs) .data<&clazz::value>("rw"_hs) @@ -80,6 +81,7 @@ class MetaContext: public ::testing::Test { entt::meta(context) .type("bar"_hs) + .prop("prop"_hs, prop_value) .base() .ctor() .dtor<&clazz::move_to_bucket>() @@ -105,6 +107,7 @@ protected: static constexpr int global_marker = 1; static constexpr int local_marker = 42; static constexpr int bucket_value = 99; + static constexpr int prop_value = 3; entt::meta_ctx context{}; }; @@ -273,7 +276,22 @@ TEST_F(MetaContext, MetaDtor) { } TEST_F(MetaContext, MetaProp) { - // TODO + using namespace entt::literals; + + const auto global = entt::resolve().prop("prop"_hs); + const auto local = entt::resolve(context).prop("prop"_hs); + + ASSERT_TRUE(global); + ASSERT_TRUE(local); + + ASSERT_EQ(global.value().type(), entt::resolve()); + ASSERT_EQ(local.value().type(), entt::resolve(context)); + + ASSERT_EQ(global.value().cast(), prop_value); + ASSERT_EQ(local.value().cast(), prop_value); + + ASSERT_EQ(global.value().type().data("marker"_hs).get({}).cast(), global_marker); + ASSERT_EQ(local.value().type().data("marker"_hs).get({}).cast(), local_marker); } TEST_F(MetaContext, MetaTemplate) {