diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2015-03-01 21:05:05 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2015-03-01 21:05:05 +0000 |
commit | 030133c5db1844ced6a2e3dc90c11cceab625e23 (patch) | |
tree | 03230d7ee6266e1da9b1a3451b78d03daee90743 /llvm/unittests/ADT/ArrayRefTest.cpp | |
parent | 451dd50673f35ec12260c25e3c4e902fbdb2d756 (diff) | |
download | bcm5719-llvm-030133c5db1844ced6a2e3dc90c11cceab625e23.tar.gz bcm5719-llvm-030133c5db1844ced6a2e3dc90c11cceab625e23.zip |
ArrayRef: Remove the equals helper with many arguments.
With initializer lists there is a really neat idiomatic way to write
this, 'ArrayRef.equals({1, 2, 3, 4, 5})'. Remove the equal method which
always had a hard limit on the number of arguments. I considered
rewriting it with variadic templates but that's not really a good fit
for a function with homogeneous arguments.
'ArrayRef == {1, 2, 3, 4, 5}' would've been even more awesome, but C++11
doesn't allow init lists with binary operators.
llvm-svn: 230907
Diffstat (limited to 'llvm/unittests/ADT/ArrayRefTest.cpp')
-rw-r--r-- | llvm/unittests/ADT/ArrayRefTest.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/llvm/unittests/ADT/ArrayRefTest.cpp b/llvm/unittests/ADT/ArrayRefTest.cpp index 70f8208620e..6955036f113 100644 --- a/llvm/unittests/ADT/ArrayRefTest.cpp +++ b/llvm/unittests/ADT/ArrayRefTest.cpp @@ -57,24 +57,24 @@ TEST(ArrayRefTest, DropBack) { TEST(ArrayRefTest, Equals) { static const int A1[] = {1, 2, 3, 4, 5, 6, 7, 8}; ArrayRef<int> AR1(A1); - EXPECT_TRUE(AR1.equals(1, 2, 3, 4, 5, 6, 7, 8)); - EXPECT_FALSE(AR1.equals(8, 1, 2, 4, 5, 6, 6, 7)); - EXPECT_FALSE(AR1.equals(2, 4, 5, 6, 6, 7, 8, 1)); - EXPECT_FALSE(AR1.equals(0, 1, 2, 4, 5, 6, 6, 7)); - EXPECT_FALSE(AR1.equals(1, 2, 42, 4, 5, 6, 7, 8)); - EXPECT_FALSE(AR1.equals(42, 2, 3, 4, 5, 6, 7, 8)); - EXPECT_FALSE(AR1.equals(1, 2, 3, 4, 5, 6, 7, 42)); - EXPECT_FALSE(AR1.equals(1, 2, 3, 4, 5, 6, 7)); - EXPECT_FALSE(AR1.equals(1, 2, 3, 4, 5, 6, 7, 8, 9)); + EXPECT_TRUE(AR1.equals({1, 2, 3, 4, 5, 6, 7, 8})); + EXPECT_FALSE(AR1.equals({8, 1, 2, 4, 5, 6, 6, 7})); + EXPECT_FALSE(AR1.equals({2, 4, 5, 6, 6, 7, 8, 1})); + EXPECT_FALSE(AR1.equals({0, 1, 2, 4, 5, 6, 6, 7})); + EXPECT_FALSE(AR1.equals({1, 2, 42, 4, 5, 6, 7, 8})); + EXPECT_FALSE(AR1.equals({42, 2, 3, 4, 5, 6, 7, 8})); + EXPECT_FALSE(AR1.equals({1, 2, 3, 4, 5, 6, 7, 42})); + EXPECT_FALSE(AR1.equals({1, 2, 3, 4, 5, 6, 7})); + EXPECT_FALSE(AR1.equals({1, 2, 3, 4, 5, 6, 7, 8, 9})); ArrayRef<int> AR1a = AR1.drop_back(); - EXPECT_TRUE(AR1a.equals(1, 2, 3, 4, 5, 6, 7)); - EXPECT_FALSE(AR1a.equals(1, 2, 3, 4, 5, 6, 7, 8)); + EXPECT_TRUE(AR1a.equals({1, 2, 3, 4, 5, 6, 7})); + EXPECT_FALSE(AR1a.equals({1, 2, 3, 4, 5, 6, 7, 8})); ArrayRef<int> AR1b = AR1a.slice(2, 4); - EXPECT_TRUE(AR1b.equals(3, 4, 5, 6)); - EXPECT_FALSE(AR1b.equals(2, 3, 4, 5, 6)); - EXPECT_FALSE(AR1b.equals(3, 4, 5, 6, 7)); + EXPECT_TRUE(AR1b.equals({3, 4, 5, 6})); + EXPECT_FALSE(AR1b.equals({2, 3, 4, 5, 6})); + EXPECT_FALSE(AR1b.equals({3, 4, 5, 6, 7})); } TEST(ArrayRefTest, EmptyEquals) { |