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