OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/containers/small_map.h" | 5 #include "base/containers/small_map.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <functional> | 10 #include <functional> |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 EXPECT_EQ(0u, hm.size()); | 417 EXPECT_EQ(0u, hm.size()); |
418 SmallMap<std::map<int, int> > m; | 418 SmallMap<std::map<int, int> > m; |
419 EXPECT_EQ(0u, m.size()); | 419 EXPECT_EQ(0u, m.size()); |
420 } | 420 } |
421 | 421 |
422 namespace { | 422 namespace { |
423 | 423 |
424 class hash_map_add_item : public hash_map<int, int> { | 424 class hash_map_add_item : public hash_map<int, int> { |
425 public: | 425 public: |
426 hash_map_add_item() : hash_map<int, int>() {} | 426 hash_map_add_item() : hash_map<int, int>() {} |
427 hash_map_add_item(const std::pair<int, int>& item) : hash_map<int, int>() { | 427 explicit hash_map_add_item(const std::pair<int, int>& item) |
| 428 : hash_map<int, int>() { |
428 insert(item); | 429 insert(item); |
429 } | 430 } |
430 }; | 431 }; |
431 | 432 |
432 void InitMap(ManualConstructor<hash_map_add_item>* map_ctor) { | 433 void InitMap(ManualConstructor<hash_map_add_item>* map_ctor) { |
433 map_ctor->Init(std::make_pair(0, 0)); | 434 map_ctor->Init(std::make_pair(0, 0)); |
434 } | 435 } |
435 | 436 |
436 class hash_map_add_item_initializer { | 437 class hash_map_add_item_initializer { |
437 public: | 438 public: |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 EXPECT_EQ(4u, m.size()); | 483 EXPECT_EQ(4u, m.size()); |
483 EXPECT_EQ(0u, m.count(-1)); | 484 EXPECT_EQ(0u, m.count(-1)); |
484 | 485 |
485 m[5] = 5; | 486 m[5] = 5; |
486 EXPECT_EQ(6u, m.size()); | 487 EXPECT_EQ(6u, m.size()); |
487 // Our functor adds an extra item when we convert to a map. | 488 // Our functor adds an extra item when we convert to a map. |
488 EXPECT_EQ(1u, m.count(-1)); | 489 EXPECT_EQ(1u, m.count(-1)); |
489 } | 490 } |
490 | 491 |
491 } // namespace base | 492 } // namespace base |
OLD | NEW |