diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-13 18:02:21 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-13 20:43:16 +0100 |
commit | 4cd305a0420f1acc75a8f81ff15264a99581f9d0 (patch) | |
tree | 0bbdbc05d2497fe6be10c021019423da46328b8a /test | |
parent | 53529d2f8ada83d119ca0973607eca4e88bb0253 (diff) |
some WIP entity stuff
Diffstat (limited to 'test')
-rw-r--r-- | test/entity.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/entity.cpp b/test/entity.cpp new file mode 100644 index 00000000..9cf0e617 --- /dev/null +++ b/test/entity.cpp @@ -0,0 +1,35 @@ +#include "app.hpp" +#include "compat/assert.hpp" +#include "src/entity.hpp" + +namespace floormat { + +using namespace floormat::entities; + +static void test() +{ + struct Test { + int foo = 111; + int bar() const { return _bar; } + void set_bar(int value) { _bar = value; } + int _baz = 222; + private: + int _bar = 333; + }; + + 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{}; + fm_assert(m_foo.read(x) == 111); + fm_assert(m_bar.read(x) == 222); + fm_assert(m_baz.read(x) == 333); + + return true; +} + +} // namespace floormat |