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

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

Issue 2547053003: s/ passed(...) / WTF::passed(...) / to avoid future ambiguity w/ base::Passed. (Closed)
Patch Set: Rebasing... Created 4 years 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 private: 99 private:
100 int m_i; 100 int m_i;
101 int* m_destructNumber; 101 int* m_destructNumber;
102 }; 102 };
103 103
104 using OwnPtrHashMap = HashMap<int, std::unique_ptr<DestructCounter>>; 104 using OwnPtrHashMap = HashMap<int, std::unique_ptr<DestructCounter>>;
105 105
106 TEST(HashMapTest, OwnPtrAsValue) { 106 TEST(HashMapTest, OwnPtrAsValue) {
107 int destructNumber = 0; 107 int destructNumber = 0;
108 OwnPtrHashMap map; 108 OwnPtrHashMap map;
109 map.add(1, wrapUnique(new DestructCounter(1, &destructNumber))); 109 map.add(1, WTF::wrapUnique(new DestructCounter(1, &destructNumber)));
110 map.add(2, wrapUnique(new DestructCounter(2, &destructNumber))); 110 map.add(2, WTF::wrapUnique(new DestructCounter(2, &destructNumber)));
111 111
112 DestructCounter* counter1 = map.get(1); 112 DestructCounter* counter1 = map.get(1);
113 EXPECT_EQ(1, counter1->get()); 113 EXPECT_EQ(1, counter1->get());
114 DestructCounter* counter2 = map.get(2); 114 DestructCounter* counter2 = map.get(2);
115 EXPECT_EQ(2, counter2->get()); 115 EXPECT_EQ(2, counter2->get());
116 EXPECT_EQ(0, destructNumber); 116 EXPECT_EQ(0, destructNumber);
117 117
118 for (OwnPtrHashMap::iterator iter = map.begin(); iter != map.end(); ++iter) { 118 for (OwnPtrHashMap::iterator iter = map.begin(); iter != map.end(); ++iter) {
119 std::unique_ptr<DestructCounter>& ownCounter = iter->value; 119 std::unique_ptr<DestructCounter>& ownCounter = iter->value;
120 EXPECT_EQ(iter->key, ownCounter->get()); 120 EXPECT_EQ(iter->key, ownCounter->get());
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 using IntSimpleMap = HashMap<int, std::unique_ptr<SimpleClass>>; 239 using IntSimpleMap = HashMap<int, std::unique_ptr<SimpleClass>>;
240 240
241 TEST(HashMapTest, AddResult) { 241 TEST(HashMapTest, AddResult) {
242 IntSimpleMap map; 242 IntSimpleMap map;
243 IntSimpleMap::AddResult result = map.add(1, nullptr); 243 IntSimpleMap::AddResult result = map.add(1, nullptr);
244 EXPECT_TRUE(result.isNewEntry); 244 EXPECT_TRUE(result.isNewEntry);
245 EXPECT_EQ(1, result.storedValue->key); 245 EXPECT_EQ(1, result.storedValue->key);
246 EXPECT_EQ(0, result.storedValue->value.get()); 246 EXPECT_EQ(0, result.storedValue->value.get());
247 247
248 SimpleClass* simple1 = new SimpleClass(1); 248 SimpleClass* simple1 = new SimpleClass(1);
249 result.storedValue->value = wrapUnique(simple1); 249 result.storedValue->value = WTF::wrapUnique(simple1);
250 EXPECT_EQ(simple1, map.get(1)); 250 EXPECT_EQ(simple1, map.get(1));
251 251
252 IntSimpleMap::AddResult result2 = map.add(1, makeUnique<SimpleClass>(2)); 252 IntSimpleMap::AddResult result2 = map.add(1, WTF::makeUnique<SimpleClass>(2));
253 EXPECT_FALSE(result2.isNewEntry); 253 EXPECT_FALSE(result2.isNewEntry);
254 EXPECT_EQ(1, result.storedValue->key); 254 EXPECT_EQ(1, result.storedValue->key);
255 EXPECT_EQ(1, result.storedValue->value->v()); 255 EXPECT_EQ(1, result.storedValue->value->v());
256 EXPECT_EQ(1, map.get(1)->v()); 256 EXPECT_EQ(1, map.get(1)->v());
257 } 257 }
258 258
259 TEST(HashMapTest, AddResultVectorValue) { 259 TEST(HashMapTest, AddResultVectorValue) {
260 using IntVectorMap = HashMap<int, Vector<int>>; 260 using IntVectorMap = HashMap<int, Vector<int>>;
261 IntVectorMap map; 261 IntVectorMap map;
262 IntVectorMap::AddResult result = map.add(1, Vector<int>()); 262 IntVectorMap::AddResult result = map.add(1, Vector<int>());
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 EXPECT_EQ(130, oneThirty); 649 EXPECT_EQ(130, oneThirty);
650 iter = map.find(Pair(MoveOnly(13), -13)); 650 iter = map.find(Pair(MoveOnly(13), -13));
651 EXPECT_TRUE(iter == map.end()); 651 EXPECT_TRUE(iter == map.end());
652 652
653 map.clear(); 653 map.clear();
654 } 654 }
655 655
656 } // anonymous namespace 656 } // anonymous namespace
657 657
658 } // namespace WTF 658 } // namespace WTF
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/FunctionalTest.cpp ('k') | third_party/WebKit/Source/wtf/HashSetTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698