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

Side by Side Diff: base/stl_util_unittest.cc

Issue 2746053002: Fix Template Parameter List for Associative Containers in base::EraseIf (Closed)
Patch Set: Created 3 years, 9 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 | « base/stl_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/stl_util.h" 5 #include "base/stl_util.h"
6 6
7 #include <deque> 7 #include <deque>
8 #include <forward_list> 8 #include <forward_list>
9 #include <functional> 9 #include <functional>
10 #include <iterator> 10 #include <iterator>
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 } 72 }
73 73
74 for (auto test_case : test_data) { 74 for (auto test_case : test_data) {
75 base::EraseIf(test_case.input, [](const std::pair<int, int>& elem) { 75 base::EraseIf(test_case.input, [](const std::pair<int, int>& elem) {
76 return elem.first & 1; 76 return elem.first & 1;
77 }); 77 });
78 EXPECT_EQ(test_case.erase_odd, test_case.input); 78 EXPECT_EQ(test_case.erase_odd, test_case.input);
79 } 79 }
80 } 80 }
81 81
82 struct CustomIntHash {
83 size_t operator()(int elem) const { return std::hash<int>()(elem) + 1; }
84 };
85
82 struct HashByFirst { 86 struct HashByFirst {
83 size_t operator()(const std::pair<int, int>& elem) const { 87 size_t operator()(const std::pair<int, int>& elem) const {
84 return std::hash<int>()(elem.first); 88 return std::hash<int>()(elem.first);
85 } 89 }
86 }; 90 };
87 91
88 } // namespace 92 } // namespace
89 93
90 namespace base { 94 namespace base {
91 namespace { 95 namespace {
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 RunEraseIfTest<std::forward_list<std::pair<int, int>>>(); 374 RunEraseIfTest<std::forward_list<std::pair<int, int>>>();
371 } 375 }
372 376
373 TEST(Erase, List) { 377 TEST(Erase, List) {
374 RunEraseTest<std::list<int>>(); 378 RunEraseTest<std::list<int>>();
375 RunEraseIfTest<std::list<std::pair<int, int>>>(); 379 RunEraseIfTest<std::list<std::pair<int, int>>>();
376 } 380 }
377 381
378 TEST(Erase, Map) { 382 TEST(Erase, Map) {
379 RunEraseIfTest<std::map<int, int>>(); 383 RunEraseIfTest<std::map<int, int>>();
384 RunEraseIfTest<std::map<int, int, std::greater<int>>>();
380 } 385 }
381 386
382 TEST(Erase, Multimap) { 387 TEST(Erase, Multimap) {
383 RunEraseIfTest<std::multimap<int, int>>(); 388 RunEraseIfTest<std::multimap<int, int>>();
389 RunEraseIfTest<std::multimap<int, int, std::greater<int>>>();
384 } 390 }
385 391
386 TEST(Erase, Set) { 392 TEST(Erase, Set) {
387 RunEraseIfTest<std::set<std::pair<int, int>>>(); 393 RunEraseIfTest<std::set<std::pair<int, int>>>();
394 RunEraseIfTest<
395 std::set<std::pair<int, int>, std::greater<std::pair<int, int>>>>();
388 } 396 }
389 397
390 TEST(Erase, Multiset) { 398 TEST(Erase, Multiset) {
391 RunEraseIfTest<std::multiset<std::pair<int, int>>>(); 399 RunEraseIfTest<std::multiset<std::pair<int, int>>>();
400 RunEraseIfTest<
401 std::multiset<std::pair<int, int>, std::greater<std::pair<int, int>>>>();
392 } 402 }
393 403
394 TEST(Erase, UnorderedMap) { 404 TEST(Erase, UnorderedMap) {
395 RunEraseIfTest<std::unordered_map<int, int>>(); 405 RunEraseIfTest<std::unordered_map<int, int>>();
406 RunEraseIfTest<std::unordered_map<int, int, CustomIntHash>>();
396 } 407 }
397 408
398 TEST(Erase, UnorderedMultimap) { 409 TEST(Erase, UnorderedMultimap) {
399 RunEraseIfTest<std::unordered_multimap<int, int>>(); 410 RunEraseIfTest<std::unordered_multimap<int, int>>();
411 RunEraseIfTest<std::unordered_multimap<int, int, CustomIntHash>>();
400 } 412 }
401 413
402 TEST(Erase, UnorderedSet) { 414 TEST(Erase, UnorderedSet) {
403 RunEraseIfTest<std::unordered_set<std::pair<int, int>, HashByFirst>>(); 415 RunEraseIfTest<std::unordered_set<std::pair<int, int>, HashByFirst>>();
404 } 416 }
405 417
406 TEST(Erase, UnorderedMultiset) { 418 TEST(Erase, UnorderedMultiset) {
407 RunEraseIfTest<std::unordered_multiset<std::pair<int, int>, HashByFirst>>(); 419 RunEraseIfTest<std::unordered_multiset<std::pair<int, int>, HashByFirst>>();
408 } 420 }
409 421
410 } // namespace 422 } // namespace
411 } // namespace base 423 } // namespace base
OLDNEW
« no previous file with comments | « base/stl_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698