1 //===-- Unittests for IntegerSequence -------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "src/__support/CPP/utility.h"
10 #include "test/UnitTest/Test.h"
12 using namespace LIBC_NAMESPACE::cpp
;
14 TEST(LlvmLibcIntegerSequencetTest
, Basic
) {
16 (is_same_v
<integer_sequence
<int>, make_integer_sequence
<int, 0>>));
17 using ISeq
= integer_sequence
<int, 0, 1, 2, 3>;
18 EXPECT_TRUE((is_same_v
<ISeq
, make_integer_sequence
<int, 4>>));
19 using LSeq
= integer_sequence
<long, 0, 1, 2, 3>;
20 EXPECT_TRUE((is_same_v
<LSeq
, make_integer_sequence
<long, 4>>));
21 using ULLSeq
= integer_sequence
<unsigned long long, 0ull, 1ull, 2ull, 3ull>;
23 (is_same_v
<ULLSeq
, make_integer_sequence
<unsigned long long, 4>>));
26 template <typename T
, T
... Ts
> bool checkArray(integer_sequence
<T
, Ts
...> seq
) {
27 T arr
[sizeof...(Ts
)]{Ts
...};
29 for (T i
= 0; i
< static_cast<T
>(sizeof...(Ts
)); i
++)
36 TEST(LlvmLibcIntegerSequencetTest
, Many
) {
37 EXPECT_TRUE(checkArray(make_integer_sequence
<int, 100>{}));