[llvm] 3678938 - unittest: Convert EXPECT_EQ iterator checks to use EXPECT_TRUE instead

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 27 14:20:33 PST 2020


Author: Vedant Kumar
Date: 2020-02-27T14:19:45-08:00
New Revision: 36789388d01fc4a24088f214145414a043582671

URL: https://github.com/llvm/llvm-project/commit/36789388d01fc4a24088f214145414a043582671
DIFF: https://github.com/llvm/llvm-project/commit/36789388d01fc4a24088f214145414a043582671.diff

LOG: unittest: Convert EXPECT_EQ iterator checks to use EXPECT_TRUE instead

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<long unsigned int>::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<long unsigned int>::const_iterator’ has no member named ‘end’
        it != container.end(); ++it, ++count) {
           ^

Added: 
    

Modified: 
    llvm/unittests/ADT/CoalescingBitVectorTest.cpp

Removed: 
    


################################################################################
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);


        


More information about the llvm-commits mailing list