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 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 SmallMap<hash_map<int, int> > hm; | 407 SmallMap<hash_map<int, int> > hm; |
408 EXPECT_EQ(0u, hm.size()); | 408 EXPECT_EQ(0u, hm.size()); |
409 SmallMap<std::map<int, int> > m; | 409 SmallMap<std::map<int, int> > m; |
410 EXPECT_EQ(0u, m.size()); | 410 EXPECT_EQ(0u, m.size()); |
411 } | 411 } |
412 | 412 |
413 namespace { | 413 namespace { |
414 | 414 |
415 class hash_map_add_item : public hash_map<int, int> { | 415 class hash_map_add_item : public hash_map<int, int> { |
416 public: | 416 public: |
417 hash_map_add_item() : hash_map<int, int>() {} | 417 hash_map_add_item() {} |
418 explicit hash_map_add_item(const std::pair<int, int>& item) | 418 explicit hash_map_add_item(const std::pair<int, int>& item) { |
419 : hash_map<int, int>() { | |
420 insert(item); | 419 insert(item); |
421 } | 420 } |
422 }; | 421 }; |
423 | 422 |
424 void InitMap(ManualConstructor<hash_map_add_item>* map_ctor) { | 423 void InitMap(ManualConstructor<hash_map_add_item>* map_ctor) { |
425 map_ctor->Init(std::make_pair(0, 0)); | 424 map_ctor->Init(std::make_pair(0, 0)); |
426 } | 425 } |
427 | 426 |
428 class hash_map_add_item_initializer { | 427 class hash_map_add_item_initializer { |
429 public: | 428 public: |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 EXPECT_EQ(4u, m.size()); | 473 EXPECT_EQ(4u, m.size()); |
475 EXPECT_EQ(0u, m.count(-1)); | 474 EXPECT_EQ(0u, m.count(-1)); |
476 | 475 |
477 m[5] = 5; | 476 m[5] = 5; |
478 EXPECT_EQ(6u, m.size()); | 477 EXPECT_EQ(6u, m.size()); |
479 // Our functor adds an extra item when we convert to a map. | 478 // Our functor adds an extra item when we convert to a map. |
480 EXPECT_EQ(1u, m.count(-1)); | 479 EXPECT_EQ(1u, m.count(-1)); |
481 } | 480 } |
482 | 481 |
483 } // namespace base | 482 } // namespace base |
OLD | NEW |