1 // Copyright (c) 2022 The Khronos Group Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include <utility>
16 #include <vector>
17 
18 #include "gmock/gmock.h"
19 #include "source/util/hash_combine.h"
20 
21 namespace spvtools {
22 namespace utils {
23 namespace {
24 
25 using HashCombineTest = ::testing::Test;
26 
TEST(HashCombineTest,Identity)27 TEST(HashCombineTest, Identity) { EXPECT_EQ(hash_combine(0), 0); }
28 
TEST(HashCombineTest,Variadic)29 TEST(HashCombineTest, Variadic) {
30   // Expect manual and variadic template versions be the same.
31   EXPECT_EQ(hash_combine(hash_combine(hash_combine(0, 1), 2), 3),
32             hash_combine(0, 1, 2, 3));
33 }
34 
TEST(HashCombineTest,Vector)35 TEST(HashCombineTest, Vector) {
36   // Expect variadic and vector versions be the same.
37   EXPECT_EQ(hash_combine(0, std::vector<uint32_t>({1, 2, 3})),
38             hash_combine(0, 1, 2, 3));
39 }
40 
41 }  // namespace
42 }  // namespace utils
43 }  // namespace spvtools
44