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

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

Issue 2339413004: Allow Mojo structs as map keys (Closed)
Patch Set: Fix merge problem in BUILD.gn file Created 4 years, 2 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.
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/lib/wtf_hash_util.h"
6
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 using WTFHashTest = testing::Test;
15
16 static blink::ContainsOtherPtr MakeContainsOther(uint64_t other) {
17 blink::ContainsOtherPtr ptr = blink::ContainsOther::New();
18 ptr->other = other;
19 return ptr;
20 }
21
22 static blink::SimpleNestedStructPtr MakeSimpleNestedStruct(
23 blink::ContainsOtherPtr nested) {
24 blink::SimpleNestedStructPtr ptr = blink::SimpleNestedStruct::New();
25 ptr->nested = std::move(nested);
26 return ptr;
27 }
28
29 TEST_F(WTFHashTest, NestedStruct) {
30 ASSERT_EQ(2007u, ::mojo::internal::Hash(
31 ::mojo::internal::kHashSeed,
32 MakeSimpleNestedStruct(MakeContainsOther(1))));
33 }
34
35 TEST_F(WTFHashTest, UnmappedNativeStruct) {
36 ASSERT_EQ(31u, ::mojo::internal::Hash(::mojo::internal::kHashSeed,
37 blink::UnmappedNativeStruct::New()));
38 }
39
40 } // namespace
41 } // namespace test
42 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698