test: meta_factory::traits

This commit is contained in:
Michele Caini
2024-11-27 17:01:03 +01:00
parent 388b39dfac
commit 4bdda6c0cf
2 changed files with 31 additions and 2 deletions

2
TODO
View File

@@ -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

View File

@@ -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) {