diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-14 13:59:57 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-14 14:05:59 +0100 |
commit | 8f0b22e3fe082c2b5c75a7fe3435f56a38cbc5a2 (patch) | |
tree | d28a02a7448e28f2f9f090a755ab5fc9faecba11 /test | |
parent | e1e68ef6f1ab1983023f6da5f92b4f1252b9c675 (diff) |
entity: more work
Diffstat (limited to 'test')
-rw-r--r-- | test/entity.cpp | 34 |
1 files changed, 12 insertions, 22 deletions
diff --git a/test/entity.cpp b/test/entity.cpp index 50d5e34b..80032b6f 100644 --- a/test/entity.cpp +++ b/test/entity.cpp @@ -2,34 +2,29 @@ #include "compat/assert.hpp" #include "src/entity.hpp" -namespace { +using namespace floormat; +using namespace floormat::entities; struct TestAccessors { - int foo = 111; int bar() const { return _bar; } void set_bar(int value) { _bar = value; } - int _baz = 333; -private: - int _bar = 222; + int foo; + int _bar; + int _baz; }; -} // namespace +using entity = Entity<TestAccessors>; +static constexpr auto m_foo = entity::type<int>::field{"foo"_s, &TestAccessors::foo, &TestAccessors::foo}; +static constexpr auto m_bar = entity::type<int>::field{"bar"_s, &TestAccessors::bar, &TestAccessors::set_bar}; +static constexpr auto r_baz = [](const TestAccessors& x) { return x._baz; }; +static constexpr auto w_baz = [](TestAccessors& x, int v) { x._baz = v; }; +static constexpr auto m_baz = entity::type<int>::field("baz"_s, r_baz, w_baz); namespace floormat { -using namespace floormat::entities; - static void test_accessors() { - using Test = ::TestAccessors; - using Entity = entity<Test>; - constexpr auto m_foo = Entity::Field<int>::make("foo"_s, &Test::foo, &Test::foo); - constexpr auto m_bar = Entity::Field<int>::make("bar"_s, &Test::bar, &Test::set_bar); - constexpr auto r_baz = [](const Test& x) { return x._baz; }; - constexpr auto w_baz = [](Test& x, int v) { x._baz = v; }; - constexpr auto m_baz = Entity::Field<int>::make("baz"_s, r_baz, w_baz); - - auto x = Test{}; + auto x = TestAccessors{111, 222, 333}; { auto a = m_foo.read(x), b = m_bar.read(x), c = m_baz.read(x); @@ -45,11 +40,6 @@ static void test_accessors() } } -static void test_() -{ - -} - void test_app::test_entity() { test_accessors(); |