Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Side by Side Diff: base/metrics/bucket_ranges_unittest.cc

Issue 1538743002: Switch to standard integer types in base/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DEPS roll too Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/metrics/bucket_ranges.cc ('k') | base/metrics/field_trial.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // 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 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/bucket_ranges.h" 5 #include "base/metrics/bucket_ranges.h"
6 6
7 #include <stdint.h>
8
7 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
8 10
9 namespace base { 11 namespace base {
10 namespace { 12 namespace {
11 13
12 TEST(BucketRangesTest, NormalSetup) { 14 TEST(BucketRangesTest, NormalSetup) {
13 BucketRanges ranges(5); 15 BucketRanges ranges(5);
14 ASSERT_EQ(5u, ranges.size()); 16 ASSERT_EQ(5u, ranges.size());
15 ASSERT_EQ(4u, ranges.bucket_count()); 17 ASSERT_EQ(4u, ranges.bucket_count());
16 18
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 71
70 ranges.ResetChecksum(); 72 ranges.ResetChecksum();
71 EXPECT_EQ(2843835776u, ranges.checksum()); 73 EXPECT_EQ(2843835776u, ranges.checksum());
72 EXPECT_TRUE(ranges.HasValidChecksum()); 74 EXPECT_TRUE(ranges.HasValidChecksum());
73 } 75 }
74 76
75 // Table was generated similarly to sample code for CRC-32 given on: 77 // Table was generated similarly to sample code for CRC-32 given on:
76 // http://www.w3.org/TR/PNG/#D-CRCAppendix. 78 // http://www.w3.org/TR/PNG/#D-CRCAppendix.
77 TEST(BucketRangesTest, Crc32TableTest) { 79 TEST(BucketRangesTest, Crc32TableTest) {
78 for (int i = 0; i < 256; ++i) { 80 for (int i = 0; i < 256; ++i) {
79 uint32 checksum = i; 81 uint32_t checksum = i;
80 for (int j = 0; j < 8; ++j) { 82 for (int j = 0; j < 8; ++j) {
81 const uint32 kReversedPolynomial = 0xedb88320L; 83 const uint32_t kReversedPolynomial = 0xedb88320L;
82 if (checksum & 1) 84 if (checksum & 1)
83 checksum = kReversedPolynomial ^ (checksum >> 1); 85 checksum = kReversedPolynomial ^ (checksum >> 1);
84 else 86 else
85 checksum >>= 1; 87 checksum >>= 1;
86 } 88 }
87 EXPECT_EQ(kCrcTable[i], checksum); 89 EXPECT_EQ(kCrcTable[i], checksum);
88 } 90 }
89 } 91 }
90 92
91 } // namespace 93 } // namespace
92 } // namespace base 94 } // namespace base
OLDNEW
« no previous file with comments | « base/metrics/bucket_ranges.cc ('k') | base/metrics/field_trial.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698