summaryrefslogtreecommitdiffhomepage
path: root/test/util.cpp
blob: 48332621c089202fca2f64ae5b024eadc7cf24a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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