| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project 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 "src/base/functional.h" | 5 #include "src/base/functional.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "test/unittests/test-utils.h" | 10 #include "test/unittests/test-utils.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 for (int i = 0; i < 128; ++i) { | 76 for (int i = 0; i < 128; ++i) { |
| 77 TypeParam v; | 77 TypeParam v; |
| 78 this->rng()->NextBytes(&v, sizeof(v)); | 78 this->rng()->NextBytes(&v, sizeof(v)); |
| 79 EXPECT_EQ(h1(v), h2(v)); | 79 EXPECT_EQ(h1(v), h2(v)); |
| 80 } | 80 } |
| 81 } | 81 } |
| 82 | 82 |
| 83 | 83 |
| 84 TYPED_TEST(FunctionalTest, HashIsOkish) { | 84 TYPED_TEST(FunctionalTest, HashIsOkish) { |
| 85 const size_t kValues = 128; | 85 const size_t kValues = 128; |
| 86 const size_t kMinHashes = kValues / (sizeof(uint64_t) / sizeof(size_t)); | 86 const size_t kMinHashes = kValues / 4; |
| 87 std::set<TypeParam> vs; | 87 std::set<TypeParam> vs; |
| 88 while (vs.size() != kValues) { | 88 while (vs.size() != kValues) { |
| 89 TypeParam v; | 89 TypeParam v; |
| 90 this->rng()->NextBytes(&v, sizeof(v)); | 90 this->rng()->NextBytes(&v, sizeof(v)); |
| 91 vs.insert(v); | 91 vs.insert(v); |
| 92 } | 92 } |
| 93 std::set<size_t> hs; | 93 std::set<size_t> hs; |
| 94 for (const auto& v : vs) { | 94 for (const auto& v : vs) { |
| 95 hash<TypeParam> h; | 95 hash<TypeParam> h; |
| 96 hs.insert(h(v)); | 96 hs.insert(h(v)); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 122 TRACED_FOREACH(double, y, kDoubleValues) { | 122 TRACED_FOREACH(double, y, kDoubleValues) { |
| 123 hash<Foo> h; | 123 hash<Foo> h; |
| 124 Foo foo = {x, y}; | 124 Foo foo = {x, y}; |
| 125 EXPECT_EQ(hash_combine(x, y), h(foo)); | 125 EXPECT_EQ(hash_combine(x, y), h(foo)); |
| 126 } | 126 } |
| 127 } | 127 } |
| 128 } | 128 } |
| 129 | 129 |
| 130 } // namespace base | 130 } // namespace base |
| 131 } // namespace v8 | 131 } // namespace v8 |
| OLD | NEW |