diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-10-09 08:51:34 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-10-09 08:55:43 +0200 |
commit | 4b6e676db5b6e034900adb39510e7b36560e96ad (patch) | |
tree | dc67361736880353995645f72b145b05b9ed6d21 /test/coords.cpp | |
parent | e5876e1627597076a26b0c3b49b132705fc4b760 (diff) |
a
Diffstat (limited to 'test/coords.cpp')
-rw-r--r-- | test/coords.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/test/coords.cpp b/test/coords.cpp index 62f86fc5..363d6f8a 100644 --- a/test/coords.cpp +++ b/test/coords.cpp @@ -5,20 +5,23 @@ namespace floormat { namespace { -constexpr auto norm = [](const point& pt, Vector2i delta) { return object::normalize_coords(pt, delta); }; - void test_normalize_point() { - auto a = point{{{ 0, 0, 0}, { 0, 0}}, { 0, 0} }, - b = point{{{ -1, 1, 0}, { 0, 15}}, { 0, 0} }, - c = point{{{ -1, 1, 1}, { 0, 0}}, { 1, 31} }, - d = point{{{ 1, 0, 1}, {15, 15}}, {-31, 31} }, - e = point{{{ 1, 0, 1}, {15, 15}}, {-31, 31} }, - f = point{{{16384, -16384, 2}, {15, 0}}, {1, 2} }; - - fm_assert_equal(norm(a, {}), point{{{ 0, 0, 0}, { 0, 0}}, { 0, 0} }); - fm_assert_equal(norm(b, { 1, -1}), point{{{ -1, 1 , 0}, { 0, 15}}, { 1, -1} }); - fm_assert_equal(norm(b, { -65, 65}), point{{{ -2, 2, 0}, {15, 0}}, { -1, 1} }); + point a = { {{ 0, 0, 0}, { 0, 0}}, { 0, 0} }, + b = { {{ -1, 1, 2}, { 0, 15}}, { 0, 0} }, + c = { {{ -1, 1, 1}, { 7, 9}}, { 1, 31} }, + d = { {{16384,-16384,2}, {15, 0}}, { 1, 2} }; + + { constexpr auto norm = [](const point& pt, Vector2i delta) { return object::normalize_coords(pt, delta); }; + + fm_assert_equal(norm(a, {}), point{{{ 0, 0, 0}, { 0, 0}}, { 0, 0} }); + fm_assert_equal(norm(b, {}), point{{{ -1, 1, 2}, { 0, 15}}, { 0, 0} }); + fm_assert_equal(norm(b, { 1, -1} ), point{{{ -1, 1 , 2}, { 0, 15}}, { 1, -1} }); + fm_assert_equal(norm(b, { -65, 65 }), point{{{ -2, 2, 2}, {15, 0}}, { -1, 1} }); + fm_assert_equal(norm(c, { 30, -62 }), point{{{ -1, 1, 1}, { 7, 9}}, { 31, -31} }); + fm_assert_equal(norm(c, {1024, 1024}), point{{{ 0, 2, 1}, { 7, 9}}, { 1, 31} }); + fm_assert_equal(norm(d, {2048, 1087}), point{{{16386,-16383,2}, {15, 1}}, { 1, 1} }); + } } } // namespace |