From 4a3dd8b6fe07961f5f9b4b839f718019657f8dd2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 10 Aug 2024 18:36:41 +0200 Subject: compat, test: improve {static_,}array_size --- test/util.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 test/util.cpp (limited to 'test/util.cpp') 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 Array_1 = {}; + static constexpr const void* Array_2[22] = {}; + + std::array array_3; +}; + +constexpr bool test_array_size() +{ + fm_assert(static_array_size == 11); + fm_assert(array_size(Foo::Array_1) == 11); + + fm_assert(static_array_size == 22); + fm_assert(array_size(&Foo::Array_2) == 22); + + fm_assert(static_array_size == 33); + fm_assert(array_size(Foo{}.array_3) == 33); + fm_assert(array_size(&Foo::array_3) == 33); + + fm_assert(static_array_size == 44); + + return true; +} + +} // namespace + +void test_util() +{ + static_assert(test_array_size()); +} + +} // namespace floormat::Test -- cgit v1.2.3