1 //===-- Unittests for IntegerSequence -------------------------------------===// 2 // 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 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "src/__support/CPP/Utility.h" 10 #include "utils/UnitTest/Test.h" 11 12 using namespace __llvm_libc::cpp; 13 14 TEST(LlvmLibcIntegerSequencetTest, Basic) { 15 EXPECT_TRUE((IsSameV<IntegerSequence<int>, MakeIntegerSequence<int, 0>>)); 16 using ISeq = IntegerSequence<int, 0, 1, 2, 3>; 17 EXPECT_TRUE((IsSameV<ISeq, MakeIntegerSequence<int, 4>>)); 18 using LSeq = IntegerSequence<long, 0, 1, 2, 3>; 19 EXPECT_TRUE((IsSameV<LSeq, MakeIntegerSequence<long, 4>>)); 20 using ULLSeq = IntegerSequence<unsigned long long, 0ull, 1ull, 2ull, 3ull>; 21 EXPECT_TRUE((IsSameV<ULLSeq, MakeIntegerSequence<unsigned long long, 4>>)); 22 } 23 24 template <typename T, T... Ts> 25 bool checkArray(IntegerSequence<T, Ts...> seq) { 26 T arr[sizeof...(Ts)]{Ts...}; 27 28 for (T i = 0; i < static_cast<T>(sizeof...(Ts)); i++) 29 if (arr[i] != i) 30 return false; 31 32 return true; 33 } 34 35 TEST(LlvmLibcIntegerSequencetTest, Many) { 36 EXPECT_TRUE(checkArray(MakeIntegerSequence<int, 100>{})); 37 } 38