summaryrefslogtreecommitdiffhomepage
path: root/test/entity.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-11-19 07:27:49 +0100
committerStanislaw Halik <sthalik@misaki.pl>2022-11-19 07:27:49 +0100
commit0533360642ff320a1a7d25ed2911a6c44de8d6e9 (patch)
treec5a4ed240decaa495aa9f439016acf3b9d46988c /test/entity.cpp
parent167798dd34886c93657534ac8f976418b455a5d6 (diff)
entity: add field enablement predicate
Diffstat (limited to 'test/entity.cpp')
-rw-r--r--test/entity.cpp17
1 files changed, 17 insertions, 0 deletions
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<int>::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<int>::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<int>::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();