diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2024-08-10 18:36:41 +0200 |
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-08-11 11:07:56 +0200 |
| commit | 4a3dd8b6fe07961f5f9b4b839f718019657f8dd2 (patch) | |
| tree | 480a10d268168c20542459b8d72f82a4e71c6baf /test/util.cpp | |
| parent | dd9b8bd02f301291aa47cf4b52f19c6f5805ac1f (diff) | |
compat, test: improve {static_,}array_size
Diffstat (limited to 'test/util.cpp')
| -rw-r--r-- | test/util.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/util.cpp b/test/util.cpp new file mode 100644 index 00000000..48332621 --- /dev/null +++ b/test/util.cpp @@ -0,0 +1,40 @@ +#include "app.hpp" +#include "compat/array-size.hpp" + +namespace floormat::Test { + +namespace { + +struct Foo +{ + static constexpr std::array<int, 11> Array_1 = {}; + static constexpr const void* Array_2[22] = {}; + + std::array<int, 33> array_3; +}; + +constexpr bool test_array_size() +{ + fm_assert(static_array_size<decltype(Foo::Array_1)> == 11); + fm_assert(array_size(Foo::Array_1) == 11); + + fm_assert(static_array_size<decltype(Foo::Array_2)> == 22); + fm_assert(array_size(&Foo::Array_2) == 22); + + fm_assert(static_array_size<decltype(Foo{}.array_3)> == 33); + fm_assert(array_size(Foo{}.array_3) == 33); + fm_assert(array_size(&Foo::array_3) == 33); + + fm_assert(static_array_size<const int(&)[44]> == 44); + + return true; +} + +} // namespace + +void test_util() +{ + static_assert(test_array_size()); +} + +} // namespace floormat::Test |
