1 //===- SequenceTest.cpp - Unit tests for a sequence abstraciton -----------===//
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 "llvm/ADT/Sequence.h"
10 #include "gtest/gtest.h"
18 TEST(SequenceTest
, Basic
) {
20 for (int i
: seq(0, 10)) {
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