File: codegen_shared_test.py

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (34 lines) | stat: -rwxr-xr-x 1,165 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python
# Copyright 2024 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import unittest

import codegen_shared


class CodegenSharedTest(unittest.TestCase):
  def testHash(self) -> None:
    # Must match those in //base/metrics/metrics_hashes_unittest.cc.
    self.assertEqual(codegen_shared.HashName('Back'), 0x0557fa923dcee4d0)
    self.assertEqual(codegen_shared.HashName('Forward'), 0x67d2f6740a8eaebf)
    self.assertEqual(codegen_shared.HashName('NewTab'), 0x290eb683f96572f1)

  def testHashFieldTrialName(self):
    # Must match those in //components/variations/hashing_unittest.cc.
    known_hashes = {
        'a': 937752454,
        '1': 723085877,
        'Trial Name': 2713117220,
        'Group Name': 3201815843,
        'My Favorite Experiment': 3722155194,
        'My Awesome Group Name': 4109503236,
        'abcdefghijklmonpqrstuvwxyz': 787728696,
        '0123456789ABCDEF': 348858318
    }
    for name, value in known_hashes.items():
      self.assertEqual(codegen_shared.HashFieldTrialName(name), value)

if __name__ == '__main__':
  unittest.main()