[llvm] r264416 - Ensure that the StringMap does not grow during the test for pre-allocation/reserve

Mehdi Amini via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 25 09:09:34 PDT 2016


Author: mehdi_amini
Date: Fri Mar 25 11:09:34 2016
New Revision: 264416

URL: http://llvm.org/viewvc/llvm-project?rev=264416&view=rev
Log:
Ensure that the StringMap does not grow during the test for pre-allocation/reserve

From: Mehdi Amini <mehdi.amini at apple.com>

Modified:
    llvm/trunk/unittests/ADT/StringMapTest.cpp

Modified: llvm/trunk/unittests/ADT/StringMapTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/StringMapTest.cpp?rev=264416&r1=264415&r2=264416&view=diff
==============================================================================
--- llvm/trunk/unittests/ADT/StringMapTest.cpp (original)
+++ llvm/trunk/unittests/ADT/StringMapTest.cpp Fri Mar 25 11:09:34 2016
@@ -390,6 +390,7 @@ TEST(StringMapCustomTest, InitialSizeTes
   // arbitrary prime, picked without any good reason.
   for (auto Size : {1, 32, 67}) {
     StringMap<CountCtorCopyAndMove> Map(Size);
+    auto NumBuckets = Map.getNumBuckets();
     CountCtorCopyAndMove::Move = 0;
     CountCtorCopyAndMove::Copy = 0;
     for (int i = 0; i < Size; ++i)
@@ -398,6 +399,8 @@ TEST(StringMapCustomTest, InitialSizeTes
     //   EXPECT_EQ((unsigned)Size * 3, CountCtorCopyAndMove::Move);
     // No copy is expected.
     EXPECT_EQ(0u, CountCtorCopyAndMove::Copy);
+    // Check that the map didn't grow
+    EXPECT_EQ(Map.getNumBuckets(), NumBuckets);
   }
 }
 




More information about the llvm-commits mailing list