OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
yzshen1
2017/03/02 17:25:03
2017?
tibell
2017/03/02 23:16:50
Done.
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include <stddef.h> | |
6 #include <stdint.h> | |
7 #include <unordered_map> | |
8 #include <utility> | |
9 | |
10 #include "mojo/public/cpp/bindings/tests/rect_chromium.h" | |
11 #include "mojo/public/interfaces/bindings/tests/rect.mojom.h" | |
12 #include "mojo/public/interfaces/bindings/tests/test_structs.mojom.h" | |
13 #include "testing/gtest/include/gtest/gtest.h" | |
14 | |
15 namespace mojo { | |
16 namespace test { | |
17 namespace { | |
18 | |
19 TEST(MapTest, StructKey) { | |
20 std::unordered_map<RectPtr, int32_t> map; | |
21 map.insert(std::make_pair(Rect::New(1, 2, 3, 4), 123)); | |
22 | |
23 RectPtr key = Rect::New(1, 2, 3, 4); | |
24 ASSERT_NE(map.end(), map.find(key)); | |
25 ASSERT_EQ(123, map.find(key)->second); | |
26 | |
27 map.erase(key); | |
28 ASSERT_EQ(0u, map.size()); | |
29 } | |
30 | |
31 TEST(MapTest, TypemappedStructKey) { | |
32 std::unordered_map<ContainsHashablePtr, int32_t> map; | |
33 map.insert( | |
34 std::make_pair(ContainsHashable::New(RectChromium(1, 2, 3, 4)), 123)); | |
35 | |
36 ContainsHashablePtr key = ContainsHashable::New(RectChromium(1, 2, 3, 4)); | |
37 ASSERT_NE(map.end(), map.find(key)); | |
38 ASSERT_EQ(123, map.find(key)->second); | |
39 | |
40 map.erase(key); | |
41 ASSERT_EQ(0u, map.size()); | |
42 } | |
43 | |
44 } // namespace | |
45 } // namespace test | |
46 } // namespace mojo | |
OLD | NEW |