• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "base/hash/legacy_hash.h"
6 
7 #include <stdint.h>
8 
9 #include <string_view>
10 
11 #include "base/containers/span.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13 
14 namespace base {
15 namespace legacy {
16 
TEST(LegacyHashTest,CityHashV103)17 TEST(LegacyHashTest, CityHashV103) {
18   constexpr struct {
19     std::string_view input;
20     uint64_t output;
21     uint64_t output_with_seed;
22   } kTestCases[] = {
23       {"", 11160318154034397263ull, 14404538258149959151ull},
24       {"0123456789", 12631666426400459317ull, 12757304017804637665ull},
25       {"hello world", 12386028635079221413ull, 4144044770257928618ull},
26   };
27   for (const auto& test_case : kTestCases) {
28     SCOPED_TRACE(test_case.input);
29     EXPECT_EQ(test_case.output, CityHash64(as_byte_span(test_case.input)));
30   }
31   for (const auto& test_case : kTestCases) {
32     SCOPED_TRACE(test_case.input);
33     EXPECT_EQ(test_case.output_with_seed,
34               CityHash64WithSeed(as_byte_span(test_case.input), 112358));
35   }
36 }
37 
38 }  // namespace legacy
39 }  // namespace base
40