Skip to content

Commit

Permalink
test: meta_factory::traits
Browse files Browse the repository at this point in the history
  • Loading branch information
skypjack committed Nov 27, 2024
1 parent 388b39d commit 4bdda6c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion TODO
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ TODO:
* refine the storage fallback mechanism for views (ie alloc?)
* don't pass reactive storage by default to callback
* runtime types support for meta for types that aren't backed by C++ types
* dtor, traits and custom should be part of meta descriptor maybe (?)
* dtor, traits and custom should be part of meta descriptor (update meta_factory tests then)
* allow attaching const values of non-Type type to meta types
* built-in no-pagination storage - no_pagination page size as limits::max
* meta_any ownership construction and from_void
Expand Down
31 changes: 30 additions & 1 deletion test/entt/meta/meta_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,36 @@ TEST_F(MetaFactory, FuncOverload) {
}

TEST_F(MetaFactory, Traits) {
// TODO
using namespace entt::literals;

entt::meta<clazz>()
.data<&base::member>("member"_hs)
.func<&clazz::set_int>("func"_hs)
.func<&clazz::set_boxed_int>("func"_hs);

entt::meta_type type = entt::resolve<clazz>();

ASSERT_EQ(type.traits<test::meta_traits>(), test::meta_traits::none);
ASSERT_EQ(type.data("member"_hs).traits<test::meta_traits>(), test::meta_traits::none);
ASSERT_EQ(type.func("func"_hs).traits<test::meta_traits>(), test::meta_traits::none);
ASSERT_EQ(type.func("func"_hs).next().traits<test::meta_traits>(), test::meta_traits::none);

entt::meta<clazz>()
.traits(test::meta_traits::one | test::meta_traits::three)
.data<&base::member>("member"_hs)
.traits(test::meta_traits::one)
.func<&clazz::set_int>("func"_hs)
.traits(test::meta_traits::two)
.func<&clazz::set_boxed_int>("func"_hs)
.traits(test::meta_traits::three);

// traits are copied and never refreshed (yet)
type = entt::resolve<clazz>();

ASSERT_EQ(type.traits<test::meta_traits>(), test::meta_traits::one | test::meta_traits::three);
ASSERT_EQ(type.data("member"_hs).traits<test::meta_traits>(), test::meta_traits::one);
ASSERT_EQ(type.func("func"_hs).traits<test::meta_traits>(), test::meta_traits::two);
ASSERT_EQ(type.func("func"_hs).next().traits<test::meta_traits>(), test::meta_traits::three);
}

TEST_F(MetaFactory, Custom) {
Expand Down

0 comments on commit 4bdda6c

Please sign in to comment.