| Index: third_party/WebKit/Source/wtf/HashMapTest.cpp
|
| diff --git a/third_party/WebKit/Source/wtf/HashMapTest.cpp b/third_party/WebKit/Source/wtf/HashMapTest.cpp
|
| index 622124f1ac0ca56430d2784379dd14c3da48d0ba..87ae865d508591beea47909b6b7939f9921e51e8 100644
|
| --- a/third_party/WebKit/Source/wtf/HashMapTest.cpp
|
| +++ b/third_party/WebKit/Source/wtf/HashMapTest.cpp
|
| @@ -40,7 +40,7 @@ using IntHashMap = HashMap<int, int>;
|
|
|
| TEST(HashMapTest, IteratorComparison) {
|
| IntHashMap map;
|
| - map.add(1, 2);
|
| + map.insert(1, 2);
|
| EXPECT_TRUE(map.begin() != map.end());
|
| EXPECT_FALSE(map.begin() == map.end());
|
|
|
| @@ -78,9 +78,9 @@ TEST(HashMapTest, DoubleHashCollisions) {
|
|
|
| DoubleHashMap map;
|
|
|
| - map.add(clobberKey, 1);
|
| - map.add(zeroKey, 2);
|
| - map.add(negativeZeroKey, 3);
|
| + map.insert(clobberKey, 1);
|
| + map.insert(zeroKey, 2);
|
| + map.insert(negativeZeroKey, 3);
|
|
|
| EXPECT_EQ(bucketForKey(clobberKey), bucketForKey(negativeZeroKey));
|
| EXPECT_EQ(1, map.get(clobberKey));
|
| @@ -106,8 +106,8 @@ using OwnPtrHashMap = HashMap<int, std::unique_ptr<DestructCounter>>;
|
| TEST(HashMapTest, OwnPtrAsValue) {
|
| int destructNumber = 0;
|
| OwnPtrHashMap map;
|
| - map.add(1, WTF::wrapUnique(new DestructCounter(1, &destructNumber)));
|
| - map.add(2, WTF::wrapUnique(new DestructCounter(2, &destructNumber)));
|
| + map.insert(1, WTF::wrapUnique(new DestructCounter(1, &destructNumber)));
|
| + map.insert(2, WTF::wrapUnique(new DestructCounter(2, &destructNumber)));
|
|
|
| DestructCounter* counter1 = map.get(1);
|
| EXPECT_EQ(1, counter1->get());
|
| @@ -170,7 +170,7 @@ TEST(HashMapTest, RefPtrAsKey) {
|
| RefPtr<DummyRefCounted> ptr = adoptRef(new DummyRefCounted(isDeleted));
|
| EXPECT_EQ(0, DummyRefCounted::m_refInvokesCount);
|
| HashMap<RefPtr<DummyRefCounted>, int> map;
|
| - map.add(ptr, 1);
|
| + map.insert(ptr, 1);
|
| // Referenced only once (to store a copy in the container).
|
| EXPECT_EQ(1, DummyRefCounted::m_refInvokesCount);
|
| EXPECT_EQ(1, map.get(ptr));
|
| @@ -202,7 +202,7 @@ TEST(HashMaptest, RemoveAdd) {
|
| RefPtr<DummyRefCounted> ptr = adoptRef(new DummyRefCounted(isDeleted));
|
| EXPECT_EQ(0, DummyRefCounted::m_refInvokesCount);
|
|
|
| - map.add(1, ptr);
|
| + map.insert(1, ptr);
|
| // Referenced only once (to store a copy in the container).
|
| EXPECT_EQ(1, DummyRefCounted::m_refInvokesCount);
|
| EXPECT_EQ(ptr, map.get(1));
|
| @@ -219,7 +219,7 @@ TEST(HashMaptest, RemoveAdd) {
|
| for (int i = 1; i < 100; i++) {
|
| bool isDeleted2 = false;
|
| RefPtr<DummyRefCounted> ptr2 = adoptRef(new DummyRefCounted(isDeleted2));
|
| - map.add(i, ptr2);
|
| + map.insert(i, ptr2);
|
| EXPECT_FALSE(isDeleted2);
|
| ptr2.clear();
|
| EXPECT_FALSE(isDeleted2);
|
| @@ -240,7 +240,7 @@ using IntSimpleMap = HashMap<int, std::unique_ptr<SimpleClass>>;
|
|
|
| TEST(HashMapTest, AddResult) {
|
| IntSimpleMap map;
|
| - IntSimpleMap::AddResult result = map.add(1, nullptr);
|
| + IntSimpleMap::AddResult result = map.insert(1, nullptr);
|
| EXPECT_TRUE(result.isNewEntry);
|
| EXPECT_EQ(1, result.storedValue->key);
|
| EXPECT_EQ(0, result.storedValue->value.get());
|
| @@ -249,7 +249,8 @@ TEST(HashMapTest, AddResult) {
|
| result.storedValue->value = WTF::wrapUnique(simple1);
|
| EXPECT_EQ(simple1, map.get(1));
|
|
|
| - IntSimpleMap::AddResult result2 = map.add(1, WTF::makeUnique<SimpleClass>(2));
|
| + IntSimpleMap::AddResult result2 =
|
| + map.insert(1, WTF::makeUnique<SimpleClass>(2));
|
| EXPECT_FALSE(result2.isNewEntry);
|
| EXPECT_EQ(1, result.storedValue->key);
|
| EXPECT_EQ(1, result.storedValue->value->v());
|
| @@ -259,7 +260,7 @@ TEST(HashMapTest, AddResult) {
|
| TEST(HashMapTest, AddResultVectorValue) {
|
| using IntVectorMap = HashMap<int, Vector<int>>;
|
| IntVectorMap map;
|
| - IntVectorMap::AddResult result = map.add(1, Vector<int>());
|
| + IntVectorMap::AddResult result = map.insert(1, Vector<int>());
|
| EXPECT_TRUE(result.isNewEntry);
|
| EXPECT_EQ(1, result.storedValue->key);
|
| EXPECT_EQ(0u, result.storedValue->value.size());
|
| @@ -268,7 +269,7 @@ TEST(HashMapTest, AddResultVectorValue) {
|
| EXPECT_EQ(1u, map.find(1)->value.size());
|
| EXPECT_EQ(11, map.find(1)->value.front());
|
|
|
| - IntVectorMap::AddResult result2 = map.add(1, Vector<int>());
|
| + IntVectorMap::AddResult result2 = map.insert(1, Vector<int>());
|
| EXPECT_FALSE(result2.isNewEntry);
|
| EXPECT_EQ(1, result.storedValue->key);
|
| EXPECT_EQ(1u, result.storedValue->value.size());
|
| @@ -361,7 +362,7 @@ TEST(HashMapTest, MoveOnlyValueType) {
|
| using TheMap = HashMap<int, MoveOnly>;
|
| TheMap map;
|
| {
|
| - TheMap::AddResult addResult = map.add(1, MoveOnly(10));
|
| + TheMap::AddResult addResult = map.insert(1, MoveOnly(10));
|
| EXPECT_TRUE(addResult.isNewEntry);
|
| EXPECT_EQ(1, addResult.storedValue->key);
|
| EXPECT_EQ(10, addResult.storedValue->value.value());
|
| @@ -376,7 +377,7 @@ TEST(HashMapTest, MoveOnlyValueType) {
|
|
|
| // Try to add more to trigger rehashing.
|
| for (int i = 2; i < 32; ++i) {
|
| - TheMap::AddResult addResult = map.add(i, MoveOnly(i * 10));
|
| + TheMap::AddResult addResult = map.insert(i, MoveOnly(i * 10));
|
| EXPECT_TRUE(addResult.isNewEntry);
|
| EXPECT_EQ(i, addResult.storedValue->key);
|
| EXPECT_EQ(i * 10, addResult.storedValue->value.value());
|
| @@ -417,7 +418,7 @@ TEST(HashMapTest, MoveOnlyKeyType) {
|
| using TheMap = HashMap<MoveOnly, int>;
|
| TheMap map;
|
| {
|
| - TheMap::AddResult addResult = map.add(MoveOnly(1), 10);
|
| + TheMap::AddResult addResult = map.insert(MoveOnly(1), 10);
|
| EXPECT_TRUE(addResult.isNewEntry);
|
| EXPECT_EQ(1, addResult.storedValue->key.value());
|
| EXPECT_EQ(10, addResult.storedValue->value);
|
| @@ -431,7 +432,7 @@ TEST(HashMapTest, MoveOnlyKeyType) {
|
| EXPECT_TRUE(iter == map.end());
|
|
|
| for (int i = 2; i < 32; ++i) {
|
| - TheMap::AddResult addResult = map.add(MoveOnly(i), i * 10);
|
| + TheMap::AddResult addResult = map.insert(MoveOnly(i), i * 10);
|
| EXPECT_TRUE(addResult.isNewEntry);
|
| EXPECT_EQ(i, addResult.storedValue->key.value());
|
| EXPECT_EQ(i * 10, addResult.storedValue->value);
|
| @@ -488,7 +489,7 @@ class CountCopy final {
|
| TEST(HashMapTest, MoveShouldNotMakeCopy) {
|
| HashMap<int, CountCopy> map;
|
| int counter = 0;
|
| - map.add(1, CountCopy(counter));
|
| + map.insert(1, CountCopy(counter));
|
|
|
| HashMap<int, CountCopy> other(map);
|
| counter = 0;
|
| @@ -506,7 +507,7 @@ TEST(HashMapTest, UniquePtrAsKey) {
|
| Map map;
|
| int* onePointer = new int(1);
|
| {
|
| - Map::AddResult addResult = map.add(Pointer(onePointer), 1);
|
| + Map::AddResult addResult = map.insert(Pointer(onePointer), 1);
|
| EXPECT_TRUE(addResult.isNewEntry);
|
| EXPECT_EQ(onePointer, addResult.storedValue->key.get());
|
| EXPECT_EQ(1, *addResult.storedValue->key);
|
| @@ -523,7 +524,7 @@ TEST(HashMapTest, UniquePtrAsKey) {
|
|
|
| // Insert more to cause a rehash.
|
| for (int i = 2; i < 32; ++i) {
|
| - Map::AddResult addResult = map.add(Pointer(new int(i)), i);
|
| + Map::AddResult addResult = map.insert(Pointer(new int(i)), i);
|
| EXPECT_TRUE(addResult.isNewEntry);
|
| EXPECT_EQ(i, *addResult.storedValue->key);
|
| EXPECT_EQ(i, addResult.storedValue->value);
|
| @@ -546,7 +547,7 @@ TEST(HashMapTest, UniquePtrAsValue) {
|
| using Map = HashMap<int, Pointer>;
|
| Map map;
|
| {
|
| - Map::AddResult addResult = map.add(1, Pointer(new int(1)));
|
| + Map::AddResult addResult = map.insert(1, Pointer(new int(1)));
|
| EXPECT_TRUE(addResult.isNewEntry);
|
| EXPECT_EQ(1, addResult.storedValue->key);
|
| EXPECT_EQ(1, *addResult.storedValue->value);
|
| @@ -564,7 +565,7 @@ TEST(HashMapTest, UniquePtrAsValue) {
|
| EXPECT_TRUE(iter == map.end());
|
|
|
| for (int i = 2; i < 32; ++i) {
|
| - Map::AddResult addResult = map.add(i, Pointer(new int(i)));
|
| + Map::AddResult addResult = map.insert(i, Pointer(new int(i)));
|
| EXPECT_TRUE(addResult.isNewEntry);
|
| EXPECT_EQ(i, addResult.storedValue->key);
|
| EXPECT_EQ(i, *addResult.storedValue->value);
|
| @@ -586,7 +587,7 @@ TEST(HashMapTest, UniquePtrAsValue) {
|
| EXPECT_TRUE(iter == map.end());
|
|
|
| {
|
| - Map::AddResult addResult = map.add(1, std::move(one));
|
| + Map::AddResult addResult = map.insert(1, std::move(one));
|
| EXPECT_TRUE(addResult.isNewEntry);
|
| EXPECT_EQ(1, addResult.storedValue->key);
|
| EXPECT_EQ(1, *addResult.storedValue->value);
|
| @@ -598,7 +599,7 @@ TEST(HashMapTest, MoveOnlyPairKeyType) {
|
| using TheMap = HashMap<Pair, int>;
|
| TheMap map;
|
| {
|
| - TheMap::AddResult addResult = map.add(Pair(MoveOnly(1), -1), 10);
|
| + TheMap::AddResult addResult = map.insert(Pair(MoveOnly(1), -1), 10);
|
| EXPECT_TRUE(addResult.isNewEntry);
|
| EXPECT_EQ(1, addResult.storedValue->key.first.value());
|
| EXPECT_EQ(-1, addResult.storedValue->key.second);
|
| @@ -614,7 +615,7 @@ TEST(HashMapTest, MoveOnlyPairKeyType) {
|
| EXPECT_TRUE(iter == map.end());
|
|
|
| for (int i = 2; i < 32; ++i) {
|
| - TheMap::AddResult addResult = map.add(Pair(MoveOnly(i), -i), i * 10);
|
| + TheMap::AddResult addResult = map.insert(Pair(MoveOnly(i), -i), i * 10);
|
| EXPECT_TRUE(addResult.isNewEntry);
|
| EXPECT_EQ(i, addResult.storedValue->key.first.value());
|
| EXPECT_EQ(-i, addResult.storedValue->key.second);
|
| @@ -682,9 +683,9 @@ TEST(HashMapTest, InitializerList) {
|
| EXPECT_EQ(oneTwoThree.get(3), 33);
|
|
|
| // Put some jank so we can check if the assignments can clear them later.
|
| - empty.add(9999, 99999);
|
| - one.add(9999, 99999);
|
| - oneTwoThree.add(9999, 99999);
|
| + empty.insert(9999, 99999);
|
| + one.insert(9999, 99999);
|
| + oneTwoThree.insert(9999, 99999);
|
|
|
| empty = {};
|
| EXPECT_TRUE(empty.isEmpty());
|
|
|