summaryrefslogtreecommitdiffhomepage
path: root/test/entity.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/entity.cpp')
-rw-r--r--test/entity.cpp34
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();