OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "mojo/public/cpp/bindings/tests/rect_blink.h" | 5 #include "mojo/public/cpp/bindings/tests/rect_blink.h" |
6 #include "mojo/public/interfaces/bindings/tests/rect.mojom-blink.h" | 6 #include "mojo/public/interfaces/bindings/tests/rect.mojom-blink.h" |
7 #include "mojo/public/interfaces/bindings/tests/test_structs.mojom-blink.h" | 7 #include "mojo/public/interfaces/bindings/tests/test_structs.mojom-blink.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace mojo { | 10 namespace mojo { |
11 namespace test { | 11 namespace test { |
12 namespace { | 12 namespace { |
13 | 13 |
14 TEST(WTFMapTest, StructKey) { | 14 TEST(WTFMapTest, StructKey) { |
15 WTF::HashMap<blink::RectPtr, int32_t> map; | 15 WTF::HashMap<blink::RectPtr, int32_t> map; |
16 map.insert(blink::Rect::New(1, 2, 3, 4), 123); | 16 map.insert(blink::Rect::New(1, 2, 3, 4), 123); |
17 | 17 |
18 blink::RectPtr key = blink::Rect::New(1, 2, 3, 4); | 18 blink::RectPtr key = blink::Rect::New(1, 2, 3, 4); |
19 ASSERT_NE(map.end(), map.find(key)); | 19 ASSERT_NE(map.end(), map.find(key)); |
20 ASSERT_EQ(123, map.find(key)->value); | 20 ASSERT_EQ(123, map.find(key)->value); |
21 | 21 |
22 map.remove(key); | 22 map.erase(key); |
23 ASSERT_EQ(0u, map.size()); | 23 ASSERT_EQ(0u, map.size()); |
24 } | 24 } |
25 | 25 |
26 TEST(WTFMapTest, TypemappedStructKey) { | 26 TEST(WTFMapTest, TypemappedStructKey) { |
27 WTF::HashMap<blink::ContainsHashablePtr, int32_t> map; | 27 WTF::HashMap<blink::ContainsHashablePtr, int32_t> map; |
28 map.insert(blink::ContainsHashable::New(RectBlink(1, 2, 3, 4)), 123); | 28 map.insert(blink::ContainsHashable::New(RectBlink(1, 2, 3, 4)), 123); |
29 | 29 |
30 blink::ContainsHashablePtr key = | 30 blink::ContainsHashablePtr key = |
31 blink::ContainsHashable::New(RectBlink(1, 2, 3, 4)); | 31 blink::ContainsHashable::New(RectBlink(1, 2, 3, 4)); |
32 ASSERT_NE(map.end(), map.find(key)); | 32 ASSERT_NE(map.end(), map.find(key)); |
33 ASSERT_EQ(123, map.find(key)->value); | 33 ASSERT_EQ(123, map.find(key)->value); |
34 | 34 |
35 map.remove(key); | 35 map.erase(key); |
36 ASSERT_EQ(0u, map.size()); | 36 ASSERT_EQ(0u, map.size()); |
37 } | 37 } |
38 | 38 |
39 } // namespace | 39 } // namespace |
40 } // namespace test | 40 } // namespace test |
41 } // namespace mojo | 41 } // namespace mojo |
OLD | NEW |