Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(309)

Side by Side Diff: third_party/WebKit/Source/wtf/HashSetTest.cpp

Issue 2696183002: Migrate WTF::HashSet::remove() to ::erase() [part 1] (Closed)
Patch Set: one more platform-specific reference Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/wtf/HashSet.h ('k') | third_party/WebKit/Source/wtf/HashTable.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 set.insert(WTF::wrapUnique(ptr2)); 112 set.insert(WTF::wrapUnique(ptr2));
113 EXPECT_EQ(res2.storedValue->get(), ptr2); 113 EXPECT_EQ(res2.storedValue->get(), ptr2);
114 } 114 }
115 115
116 EXPECT_FALSE(deleted2); 116 EXPECT_FALSE(deleted2);
117 EXPECT_EQ(2UL, set.size()); 117 EXPECT_EQ(2UL, set.size());
118 OwnPtrSet::iterator it2 = set.find(ptr2); 118 OwnPtrSet::iterator it2 = set.find(ptr2);
119 EXPECT_NE(set.end(), it2); 119 EXPECT_NE(set.end(), it2);
120 EXPECT_EQ(ptr2, (*it2).get()); 120 EXPECT_EQ(ptr2, (*it2).get());
121 121
122 set.remove(ptr1); 122 set.erase(ptr1);
123 EXPECT_TRUE(deleted1); 123 EXPECT_TRUE(deleted1);
124 124
125 set.clear(); 125 set.clear();
126 EXPECT_TRUE(deleted2); 126 EXPECT_TRUE(deleted2);
127 EXPECT_TRUE(set.isEmpty()); 127 EXPECT_TRUE(set.isEmpty());
128 128
129 deleted1 = false; 129 deleted1 = false;
130 deleted2 = false; 130 deleted2 = false;
131 { 131 {
132 OwnPtrSet set; 132 OwnPtrSet set;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 DummyRefCounted* rawPtr = ptr.get(); 190 DummyRefCounted* rawPtr = ptr.get();
191 191
192 EXPECT_TRUE(set.contains(rawPtr)); 192 EXPECT_TRUE(set.contains(rawPtr));
193 EXPECT_NE(set.end(), set.find(rawPtr)); 193 EXPECT_NE(set.end(), set.find(rawPtr));
194 EXPECT_TRUE(set.contains(ptr)); 194 EXPECT_TRUE(set.contains(ptr));
195 EXPECT_NE(set.end(), set.find(ptr)); 195 EXPECT_NE(set.end(), set.find(ptr));
196 196
197 ptr.clear(); 197 ptr.clear();
198 EXPECT_FALSE(isDeleted); 198 EXPECT_FALSE(isDeleted);
199 199
200 set.remove(rawPtr); 200 set.erase(rawPtr);
201 EXPECT_TRUE(isDeleted); 201 EXPECT_TRUE(isDeleted);
202 EXPECT_TRUE(set.isEmpty()); 202 EXPECT_TRUE(set.isEmpty());
203 EXPECT_EQ(1, DummyRefCounted::s_refInvokesCount); 203 EXPECT_EQ(1, DummyRefCounted::s_refInvokesCount);
204 } 204 }
205 205
206 class CountCopy final { 206 class CountCopy final {
207 public: 207 public:
208 static int* const kDeletedValue; 208 static int* const kDeletedValue;
209 209
210 explicit CountCopy(int* counter = nullptr) : m_counter(counter) {} 210 explicit CountCopy(int* counter = nullptr) : m_counter(counter) {}
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 EXPECT_EQ(7, iter->id()); 381 EXPECT_EQ(7, iter->id());
382 382
383 { 383 {
384 TheSet::AddResult addResult = 384 TheSet::AddResult addResult =
385 set.insert(MoveOnly(7, 777)); // With different ID for identification. 385 set.insert(MoveOnly(7, 777)); // With different ID for identification.
386 EXPECT_FALSE(addResult.isNewEntry); 386 EXPECT_FALSE(addResult.isNewEntry);
387 EXPECT_EQ(7, addResult.storedValue->value()); 387 EXPECT_EQ(7, addResult.storedValue->value());
388 EXPECT_EQ(7, addResult.storedValue->id()); 388 EXPECT_EQ(7, addResult.storedValue->id());
389 } 389 }
390 390
391 set.remove(MoveOnly(11)); 391 set.erase(MoveOnly(11));
392 iter = set.find(MoveOnly(11)); 392 iter = set.find(MoveOnly(11));
393 EXPECT_TRUE(iter == set.end()); 393 EXPECT_TRUE(iter == set.end());
394 394
395 MoveOnly thirteen(set.take(MoveOnly(13))); 395 MoveOnly thirteen(set.take(MoveOnly(13)));
396 EXPECT_EQ(13, thirteen.value()); 396 EXPECT_EQ(13, thirteen.value());
397 EXPECT_EQ(13, thirteen.id()); 397 EXPECT_EQ(13, thirteen.id());
398 iter = set.find(MoveOnly(13)); 398 iter = set.find(MoveOnly(13));
399 EXPECT_TRUE(iter == set.end()); 399 EXPECT_TRUE(iter == set.end());
400 400
401 set.clear(); 401 set.clear();
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 499
500 // Other ways of construction: as a function parameter and in a return 500 // Other ways of construction: as a function parameter and in a return
501 // statement. 501 // statement.
502 EXPECT_TRUE(isOneTwoThree({1, 2, 3})); 502 EXPECT_TRUE(isOneTwoThree({1, 2, 3}));
503 EXPECT_TRUE(isOneTwoThree(returnOneTwoThree())); 503 EXPECT_TRUE(isOneTwoThree(returnOneTwoThree()));
504 } 504 }
505 505
506 } // anonymous namespace 506 } // anonymous namespace
507 507
508 } // namespace WTF 508 } // namespace WTF
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/HashSet.h ('k') | third_party/WebKit/Source/wtf/HashTable.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698