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