OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium 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 "base/metrics/metrics_hashes.h" | 5 #include "base/metrics/metrics_hashes.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
7 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
8 #include "base/macros.h" | 11 #include "base/macros.h" |
9 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
11 | 14 |
12 namespace base { | 15 namespace base { |
13 | 16 |
14 // Make sure our ID hashes are the same as what we see on the server side. | 17 // Make sure our ID hashes are the same as what we see on the server side. |
15 TEST(MetricsUtilTest, HashMetricName) { | 18 TEST(MetricsUtilTest, HashMetricName) { |
16 static const struct { | 19 static const struct { |
17 std::string input; | 20 std::string input; |
18 std::string output; | 21 std::string output; |
19 } cases[] = { | 22 } cases[] = { |
20 {"Back", "0x0557fa923dcee4d0"}, | 23 {"Back", "0x0557fa923dcee4d0"}, |
21 {"Forward", "0x67d2f6740a8eaebf"}, | 24 {"Forward", "0x67d2f6740a8eaebf"}, |
22 {"NewTab", "0x290eb683f96572f1"}, | 25 {"NewTab", "0x290eb683f96572f1"}, |
23 }; | 26 }; |
24 | 27 |
25 for (size_t i = 0; i < arraysize(cases); ++i) { | 28 for (size_t i = 0; i < arraysize(cases); ++i) { |
26 uint64_t hash = HashMetricName(cases[i].input); | 29 uint64_t hash = HashMetricName(cases[i].input); |
27 std::string hash_hex = base::StringPrintf("0x%016" PRIx64, hash); | 30 std::string hash_hex = base::StringPrintf("0x%016" PRIx64, hash); |
28 EXPECT_EQ(cases[i].output, hash_hex); | 31 EXPECT_EQ(cases[i].output, hash_hex); |
29 } | 32 } |
30 } | 33 } |
31 | 34 |
32 } // namespace metrics | 35 } // namespace metrics |
OLD | NEW |