diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2023-12-23 14:42:15 +0100 |
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-12-26 04:39:12 +0100 |
| commit | 3370445a2e22ee00687ecef2e9dc88f47bb2b4c6 (patch) | |
| tree | a99ec32a02fc91d729205fc26d7183b6b4214b28 /test/map.cpp | |
| parent | c141a9efcfaecadffe771bd0c37bea0e46a3f9aa (diff) | |
a
Diffstat (limited to 'test/map.cpp')
| -rw-r--r-- | test/map.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/test/map.cpp b/test/map.cpp new file mode 100644 index 00000000..62860b22 --- /dev/null +++ b/test/map.cpp @@ -0,0 +1,37 @@ +#ifdef __GNUG__ +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + +#include "compat/map.hpp" +#include "compat/assert.hpp" + +namespace floormat { + +namespace { + +constexpr bool test1() +{ + constexpr auto array = std::array{0, 1, 2, 3, 4}; + auto array2 = map(array, [](int x) constexpr { + return (unsigned)(x - 1); + }); + constexpr auto array3 = std::array{(unsigned)-1, 0u, 1u, 2u, 3u}; + fm_assert(array2.size() == array.size()); + fm_assert(array3.size() == array.size()); + for (auto i = 0uz; i < array.size(); i++) + fm_assert(array2[i] == array3[i]); + return true; +} + +constexpr bool test2() +{ + fm_assert(map(std::array<int, 0>{}, [](int x) constexpr { return x;}).size() == 0); + return true; +} + +static_assert(test1()); +static_assert(test2()); + +} // namespace + +} // namespace floormat |
