2
0

hash_combine_test.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. #include <utility>
  15. #include <vector>
  16. #include "gmock/gmock.h"
  17. #include "source/util/hash_combine.h"
  18. namespace spvtools {
  19. namespace utils {
  20. namespace {
  21. using HashCombineTest = ::testing::Test;
  22. TEST(HashCombineTest, Identity) { EXPECT_EQ(hash_combine(0), 0); }
  23. TEST(HashCombineTest, Variadic) {
  24. // Expect manual and variadic template versions be the same.
  25. EXPECT_EQ(hash_combine(hash_combine(hash_combine(0, 1), 2), 3),
  26. hash_combine(0, 1, 2, 3));
  27. }
  28. TEST(HashCombineTest, Vector) {
  29. // Expect variadic and vector versions be the same.
  30. EXPECT_EQ(hash_combine(0, std::vector<uint32_t>({1, 2, 3})),
  31. hash_combine(0, 1, 2, 3));
  32. }
  33. } // namespace
  34. } // namespace utils
  35. } // namespace spvtools