From 0533360642ff320a1a7d25ed2911a6c44de8d6e9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 19 Nov 2022 07:27:49 +0100 Subject: entity: add field enablement predicate --- test/entity.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test') diff --git a/test/entity.cpp b/test/entity.cpp index 858c5a11..5db83974 100644 --- a/test/entity.cpp +++ b/test/entity.cpp @@ -155,6 +155,22 @@ constexpr bool test_null_writer() return true; } +void test_predicate() +{ + constexpr TestAccessors x{0, 0, 0}; + constexpr auto m_foo = entity::type::field{"foo"_s, &TestAccessors::foo, &TestAccessors::foo, + [](const TestAccessors&) { return false; }}; + static_assert(!m_foo.is_enabled(m_foo.predicate, x)); + fm_assert(!m_foo.erased().is_enabled(x)); + constexpr auto m_foo2 = entity::type::field{"foo"_s, &TestAccessors::foo, &TestAccessors::foo, + [](const TestAccessors&) { return true; }}; + static_assert(m_foo2.is_enabled(m_foo2.predicate, x)); + fm_assert(m_foo2.erased().is_enabled(x)); + constexpr auto m_foo3 = entity::type::field{"foo"_s, &TestAccessors::foo, &TestAccessors::foo}; + static_assert(m_foo3.is_enabled(m_foo3.predicate, x)); + fm_assert(m_foo3.erased().is_enabled(x)); +} + } // namespace static constexpr bool test_names() @@ -179,6 +195,7 @@ void test_app::test_entity() static_assert(test_visitor()); static_assert(test_null_writer()); static_assert(test_names()); + test_predicate(); test_fun2(); test_erasure(); test_type_name(); -- cgit v1.2.3