OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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/lib/hash_util.h" | 5 #include "mojo/public/cpp/bindings/lib/hash_util.h" |
6 | 6 |
7 #include "mojo/public/interfaces/bindings/tests/test_structs.mojom.h" | 7 #include "mojo/public/interfaces/bindings/tests/test_structs.mojom.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 using HashTest = testing::Test; | 14 using HashTest = testing::Test; |
15 | 15 |
16 static ContainsOtherPtr MakeContainsOther(uint64_t other) { | |
17 ContainsOtherPtr ptr = ContainsOther::New(); | |
18 ptr->other = other; | |
19 return ptr; | |
20 } | |
21 | |
22 static SimpleNestedStructPtr MakeSimpleNestedStruct(ContainsOtherPtr nested) { | |
23 SimpleNestedStructPtr ptr = SimpleNestedStruct::New(); | |
24 ptr->nested = std::move(nested); | |
25 return ptr; | |
26 } | |
27 | |
28 TEST_F(HashTest, NestedStruct) { | 16 TEST_F(HashTest, NestedStruct) { |
29 // Just check that this template instantiation compiles. | 17 // Just check that this template instantiation compiles. |
30 ASSERT_EQ( | 18 ASSERT_EQ( |
31 ::mojo::internal::Hash(::mojo::internal::kHashSeed, | 19 ::mojo::internal::Hash(::mojo::internal::kHashSeed, |
32 MakeSimpleNestedStruct(MakeContainsOther(1))), | 20 SimpleNestedStruct::New(ContainsOther::New(1))), |
33 ::mojo::internal::Hash(::mojo::internal::kHashSeed, | 21 ::mojo::internal::Hash(::mojo::internal::kHashSeed, |
34 MakeSimpleNestedStruct(MakeContainsOther(1)))); | 22 SimpleNestedStruct::New(ContainsOther::New(1)))); |
35 } | 23 } |
36 | 24 |
37 TEST_F(HashTest, UnmappedNativeStruct) { | 25 TEST_F(HashTest, UnmappedNativeStruct) { |
38 // Just check that this template instantiation compiles. | 26 // Just check that this template instantiation compiles. |
39 ASSERT_EQ(::mojo::internal::Hash(::mojo::internal::kHashSeed, | 27 ASSERT_EQ(::mojo::internal::Hash(::mojo::internal::kHashSeed, |
40 UnmappedNativeStruct::New()), | 28 UnmappedNativeStruct::New()), |
41 ::mojo::internal::Hash(::mojo::internal::kHashSeed, | 29 ::mojo::internal::Hash(::mojo::internal::kHashSeed, |
42 UnmappedNativeStruct::New())); | 30 UnmappedNativeStruct::New())); |
43 } | 31 } |
44 | 32 |
45 } // namespace | 33 } // namespace |
46 } // namespace test | 34 } // namespace test |
47 } // namespace mojo | 35 } // namespace mojo |
OLD | NEW |