blob: 5a2ee3598ca1c8fadb20022ad166cb58d653d029 [file] [log] [blame]
Alexei Svitkine9de32cb2018-02-06 20:21:211// Copyright (c) 2012 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 "components/variations/hashing.h"
6
7#include <stddef.h>
8#include <stdint.h>
9
10#include "base/macros.h"
Byoungkown1bb50222018-09-11 01:14:4111#include "base/stl_util.h"
Alexei Svitkine9de32cb2018-02-06 20:21:2112#include "testing/gtest/include/gtest/gtest.h"
13
14namespace variations {
15
16TEST(HashingTest, HashName) {
17 // Checks that hashing is stable on all platforms.
18 struct {
19 const char* name;
20 uint32_t hash_value;
21 } known_hashes[] = {{"a", 937752454u},
22 {"1", 723085877u},
23 {"Trial Name", 2713117220u},
24 {"Group Name", 3201815843u},
25 {"My Favorite Experiment", 3722155194u},
26 {"My Awesome Group Name", 4109503236u},
27 {"abcdefghijklmonpqrstuvwxyz", 787728696u},
28 {"0123456789ABCDEF", 348858318U}};
29
Byoungkown1bb50222018-09-11 01:14:4130 for (size_t i = 0; i < base::size(known_hashes); ++i) {
Alexei Svitkine9de32cb2018-02-06 20:21:2131 EXPECT_EQ(known_hashes[i].hash_value, HashName(known_hashes[i].name));
32 }
33}
34
35} // namespace variations