From 36789388d01fc4a24088f214145414a043582671 Mon Sep 17 00:00:00 2001 From: Vedant Kumar Date: Thu, 27 Feb 2020 14:19:42 -0800 Subject: [PATCH] unittest: Convert EXPECT_EQ iterator checks to use EXPECT_TRUE instead MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hopefully fixes compile errors on some bots, like: http://lab.llvm.org:8011/builders/clang-cmake-x86_64-avx2-linux/builds/13383/steps/ninja%20check%201/logs/stdio /home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/unittests/ADT/CoalescingBitVectorTest.cpp:452:3: required from here /home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/utils/unittest/googletest/include/gtest/gtest-printers.h:377:56: error: ‘const class llvm::CoalescingBitVector::const_iterator’ has no member named ‘begin’ for (typename C::const_iterator it = container.begin(); ^ /home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/utils/unittest/googletest/include/gtest/gtest-printers.h:378:11: error: ‘const class llvm::CoalescingBitVector::const_iterator’ has no member named ‘end’ it != container.end(); ++it, ++count) { ^ --- .../unittests/ADT/CoalescingBitVectorTest.cpp | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/llvm/unittests/ADT/CoalescingBitVectorTest.cpp b/llvm/unittests/ADT/CoalescingBitVectorTest.cpp index 9dfb32aecff7..02a5bde2bfac 100644 --- a/llvm/unittests/ADT/CoalescingBitVectorTest.cpp +++ b/llvm/unittests/ADT/CoalescingBitVectorTest.cpp @@ -94,25 +94,23 @@ TEST(CoalescingBitVectorTest, Iterators) { BV.set({0, 1, 2}); -#if 0 auto It = BV.begin(); - EXPECT_EQ(It, BV.begin()); + EXPECT_TRUE(It == BV.begin()); EXPECT_EQ(*It, 0u); ++It; EXPECT_EQ(*It, 1u); ++It; EXPECT_EQ(*It, 2u); ++It; - EXPECT_EQ(It, BV.end()); - EXPECT_EQ(BV.end(), BV.end()); + EXPECT_TRUE(It == BV.end()); + EXPECT_TRUE(BV.end() == BV.end()); It = BV.begin(); - EXPECT_EQ(It, BV.begin()); + EXPECT_TRUE(It == BV.begin()); auto ItCopy = It++; - EXPECT_EQ(ItCopy, BV.begin()); + EXPECT_TRUE(ItCopy == BV.begin()); EXPECT_EQ(*ItCopy, 0u); EXPECT_EQ(*It, 1u); -#endif EXPECT_TRUE(elementsMatch(BV, {0, 1, 2})); @@ -132,13 +130,11 @@ TEST(CoalescingBitVectorTest, Iterators) { BV.set({1000, 1001, 1002}); EXPECT_TRUE(elementsMatch(BV, {0, 1, 2, 4, 5, 6, 10, 1000, 1001, 1002})); -#if 0 auto It1 = BV.begin(); - EXPECT_EQ(It1, BV.begin()); - EXPECT_EQ(++It1, ++BV.begin()); - EXPECT_NE(It1, BV.begin()); - EXPECT_NE(It1, BV.end()); -#endif + EXPECT_TRUE(It1 == BV.begin()); + EXPECT_TRUE(++It1 == ++BV.begin()); + EXPECT_TRUE(It1 != BV.begin()); + EXPECT_TRUE(It1 != BV.end()); } TEST(CoalescingBitVectorTest, Reset) { @@ -449,7 +445,7 @@ TEST(CoalescingBitVectorTest, FindLowerBound) { U64BitVec BV(Alloc); uint64_t BigNum1 = uint64_t(1) << 32; uint64_t BigNum2 = (uint64_t(1) << 33) + 1; - EXPECT_EQ(BV.find(BigNum1), BV.end()); + EXPECT_TRUE(BV.find(BigNum1) == BV.end()); BV.set(BigNum1); auto Find1 = BV.find(BigNum1); EXPECT_EQ(*Find1, BigNum1);