diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-10-07 23:27:06 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-10-07 23:27:06 +0200 |
commit | 9c8e8fce490df6c9f0bedd680a76c3697247b33b (patch) | |
tree | 4dfb0a5fa516f10b4032b35f4d3e499d1758eae1 /src/global-coords.cpp | |
parent | 4e36541f57c872c0f1308e559e5bddf367124aba (diff) |
src: add sorting global_coords
Diffstat (limited to 'src/global-coords.cpp')
-rw-r--r-- | src/global-coords.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/global-coords.cpp b/src/global-coords.cpp index 17b8d7fd..694447c1 100644 --- a/src/global-coords.cpp +++ b/src/global-coords.cpp @@ -1,4 +1,7 @@ #include "global-coords.hpp" +#include "compat/defs.hpp" +#include <array> +#include <algorithm> namespace floormat { @@ -33,6 +36,37 @@ static_assert(g1 - g2 == Vector2i(0, 1)); static_assert((g1 + Vector2i(0, -1)).chunk() == g2.chunk()); static_assert(g1 + Vector2i(0, -1) == g2); +constexpr bool test_comparison1() +{ + auto a = point{{2, 8, 2}, {0, 0}}; + auto b = point{{1, 1, 2}, {9, 1}}; + auto c = point{{1, 0, 2}, {1, 2}}; + auto d = point{{1, 9, 1}, {1, 9}}; + auto e = point{{3, 1, 2}, {0, 0}}; + auto f = point{{9, 8, 0}, {9, 9}}; + auto g = point{{1, 9, 1}, {9, 0}}; + + const auto sorted = std::array{ + f, g, d, c, b, e, a, + }; + auto array1 = std::array{ + a, b, c, d, e, f, g, + }; + auto array2 = std::array { + a, c, e, g, b, d, f, + }; + + std::sort(array1.begin(), array1.end()); + fm_assert(array1 == sorted); + + std::sort(array2.begin(), array2.end()); + fm_assert(array2 == sorted); + + return true; +} + +static_assert(test_comparison1()); + } // namespace } // namespace floormat |