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

Side by Side Diff: mojo/public/cpp/bindings/tests/wtf_map_unittest.cc

Issue 2715153004: Mojo: Support enums as map keys in WTF (Closed)
Patch Set: Fix merge mistake 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
OLDNEW
(Empty)
1 // Copyright 2016 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 "mojo/public/cpp/bindings/tests/rect_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"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 namespace mojo {
11 namespace test {
12 namespace {
13
14 TEST(WTFMapTest, StructKey) {
15 WTF::HashMap<blink::RectPtr, int32_t> map;
16 map.insert(blink::Rect::New(1, 2, 3, 4), 123);
17
18 blink::RectPtr key = blink::Rect::New(1, 2, 3, 4);
19 ASSERT_NE(map.end(), map.find(key));
20 ASSERT_EQ(123, map.find(key)->value);
21
22 map.remove(key);
23 ASSERT_EQ(0u, map.size());
24 }
25
26 TEST(WTFMapTest, TypemappedStructKey) {
27 WTF::HashMap<blink::ContainsHashablePtr, int32_t> map;
28 map.insert(blink::ContainsHashable::New(RectBlink(1, 2, 3, 4)), 123);
29
30 blink::ContainsHashablePtr key =
31 blink::ContainsHashable::New(RectBlink(1, 2, 3, 4));
32 ASSERT_NE(map.end(), map.find(key));
33 ASSERT_EQ(123, map.find(key)->value);
34
35 map.remove(key);
36 ASSERT_EQ(0u, map.size());
37 }
38
39 } // namespace
40 } // namespace test
41 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698