[Alignment][NFC] Use Align with TargetLowering::setMinFunctionAlignment
[llvm-core.git] / unittests / ADT / SequenceTest.cpp
blob4356bb18a0cd923d749da89f5818c6d1664e5e1f
1 //===- SequenceTest.cpp - Unit tests for a sequence abstraciton -----------===//
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 //===----------------------------------------------------------------------===//
9 #include "llvm/ADT/Sequence.h"
10 #include "gtest/gtest.h"
12 #include <list>
14 using namespace llvm;
16 namespace {
18 TEST(SequenceTest, Basic) {
19 int x = 0;
20 for (int i : seq(0, 10)) {
21 EXPECT_EQ(x, i);
22 x++;
24 EXPECT_EQ(10, x);
26 auto my_seq = seq(0, 4);
27 EXPECT_EQ(4, my_seq.end() - my_seq.begin());
28 for (int i : {0, 1, 2, 3})
29 EXPECT_EQ(i, (int)my_seq.begin()[i]);
31 EXPECT_TRUE(my_seq.begin() < my_seq.end());
33 auto adjusted_begin = my_seq.begin() + 2;
34 auto adjusted_end = my_seq.end() - 2;
35 EXPECT_TRUE(adjusted_begin == adjusted_end);
36 EXPECT_EQ(2, *adjusted_begin);
37 EXPECT_EQ(2, *adjusted_end);
40 } // anonymous namespace