diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-13 18:53:14 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-13 20:43:16 +0100 |
commit | f6f16968a703dda7f66212e1527ba177dde26939 (patch) | |
tree | 5c480810b6b92f4511be49ed93448f250991433f /test | |
parent | 4cd305a0420f1acc75a8f81ff15264a99581f9d0 (diff) |
test stuff
Diffstat (limited to 'test')
-rw-r--r-- | test/app.hpp | 4 | ||||
-rw-r--r-- | test/entity.cpp | 16 | ||||
-rw-r--r-- | test/main.cpp | 3 | ||||
-rw-r--r-- | test/serializer.cpp | 12 |
4 files changed, 15 insertions, 20 deletions
diff --git a/test/app.hpp b/test/app.hpp index 89753ead..76cbab18 100644 --- a/test/app.hpp +++ b/test/app.hpp @@ -22,7 +22,7 @@ struct test_app final : private FM_APPLICATION static bool test_json(); static bool test_tile_iter(); static bool test_const_math(); - static bool test_serializer(); - static bool test_entity(); + static void test_serializer(); + static void test_entity(); }; } // namespace floormat diff --git a/test/entity.cpp b/test/entity.cpp index 9cf0e617..618fb4aa 100644 --- a/test/entity.cpp +++ b/test/entity.cpp @@ -6,7 +6,7 @@ namespace floormat { using namespace floormat::entities; -static void test() +void test_app::test_entity() { struct Test { int foo = 111; @@ -18,18 +18,20 @@ static void test() }; 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 }; + constexpr const auto m_foo = Entity::Field<int>::make{ "foo"_s, &Test::foo, &Test::foo, }; + constexpr const auto m_bar = Entity::Field<int>::make{ "bar"_s, &Test::bar, &Test::set_bar, }; + constexpr const auto r_baz = [](const Test& x) { return x._baz; }; + constexpr const auto w_baz = [](Test& x, int v) { x._baz = v; }; + constexpr const 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; + m_foo.write(x, 1111); + m_bar.write(x, 2222); + m_baz.write(x, 3333); } } // namespace floormat diff --git a/test/main.cpp b/test/main.cpp index 2fcc5715..dbf4a10e 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -22,7 +22,8 @@ int test_app::exec() fm_assert(test_json()); fm_assert(test_tile_iter()); fm_assert(test_const_math()); - fm_assert(test_serializer()); + test_serializer(); + test_entity(); return 0; } diff --git a/test/serializer.cpp b/test/serializer.cpp index 2e24cd0f..568d0217 100644 --- a/test/serializer.cpp +++ b/test/serializer.cpp @@ -36,7 +36,7 @@ static bool chunks_equal(const chunk& a, const chunk& b) return true; } -static bool test_serializer1() +void test_app::test_serializer() { constexpr auto filename = "../test/test-serializer1.dat"; if (Path::exists(filename)) @@ -47,15 +47,7 @@ static bool test_serializer1() w.serialize(filename); auto w2 = world::deserialize(filename); auto &c1 = w[coord], &c2 = w2[coord]; - bool ret = chunks_equal(c1, c2); - return ret; -} - -bool test_app::test_serializer() -{ - bool ret = true; - ret &= test_serializer1(); - return ret; + fm_assert(chunks_equal(c1, c2)); } } // namespace floormat |