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

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

Issue 11272044: Add explicit tests for histogram factory matching. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | base/metrics/histogram.h » ('j') | base/metrics/histogram_unittest.cc » ('J')
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 "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace base { 9 namespace base {
10 namespace { 10 namespace {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 ranges.set_range(2, 3); 66 ranges.set_range(2, 3);
67 EXPECT_FALSE(ranges.HasValidChecksum()); 67 EXPECT_FALSE(ranges.HasValidChecksum());
68 68
69 ranges.ResetChecksum(); 69 ranges.ResetChecksum();
70 EXPECT_EQ(2843835776u, ranges.checksum()); 70 EXPECT_EQ(2843835776u, ranges.checksum());
71 EXPECT_TRUE(ranges.HasValidChecksum()); 71 EXPECT_TRUE(ranges.HasValidChecksum());
72 } 72 }
73 73
74 // Table was generated similarly to sample code for CRC-32 given on: 74 // Table was generated similarly to sample code for CRC-32 given on:
75 // http://www.w3.org/TR/PNG/#D-CRCAppendix. 75 // http://www.w3.org/TR/PNG/#D-CRCAppendix.
76 TEST(HistogramTest, Crc32TableTest) { 76 TEST(BucketRangesTest, Crc32TableTest) {
77 for (int i = 0; i < 256; ++i) { 77 for (int i = 0; i < 256; ++i) {
78 uint32 checksum = i; 78 uint32 checksum = i;
79 for (int j = 0; j < 8; ++j) { 79 for (int j = 0; j < 8; ++j) {
80 const uint32 kReversedPolynomial = 0xedb88320L; 80 const uint32 kReversedPolynomial = 0xedb88320L;
81 if (checksum & 1) 81 if (checksum & 1)
82 checksum = kReversedPolynomial ^ (checksum >> 1); 82 checksum = kReversedPolynomial ^ (checksum >> 1);
83 else 83 else
84 checksum >>= 1; 84 checksum >>= 1;
85 } 85 }
86 EXPECT_EQ(kCrcTable[i], checksum); 86 EXPECT_EQ(kCrcTable[i], checksum);
87 } 87 }
88 } 88 }
89 89
90 } // namespace 90 } // namespace
91 } // namespace base 91 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/metrics/histogram.h » ('j') | base/metrics/histogram_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698