Switch to standard integer types in base/.
BUG=138542
TBR=mark@chromium.org
NOPRESUBMIT=true
Review URL: https://codereview.chromium.org/1538743002
Cr-Commit-Position: refs/heads/master@{#366910}
diff --git a/base/rand_util_unittest.cc b/base/rand_util_unittest.cc
index 689b8ad39..ea803ee 100644
--- a/base/rand_util_unittest.cc
+++ b/base/rand_util_unittest.cc
@@ -4,6 +4,9 @@
#include "base/rand_util.h"
+#include <stddef.h>
+#include <stdint.h>
+
#include <algorithm>
#include <limits>
@@ -67,7 +70,7 @@
TEST(RandUtilTest, RandGeneratorForRandomShuffle) {
EXPECT_EQ(base::RandGenerator(1), 0U);
EXPECT_LE(std::numeric_limits<ptrdiff_t>::max(),
- std::numeric_limits<int64>::max());
+ std::numeric_limits<int64_t>::max());
}
TEST(RandUtilTest, RandGeneratorIsUniform) {
@@ -83,16 +86,17 @@
// top half. A bit of calculus care of jar@ shows that the largest
// measurable delta is when the top of the range is 3/4ths of the
// way, so that's what we use in the test.
- const uint64 kTopOfRange = (std::numeric_limits<uint64>::max() / 4ULL) * 3ULL;
- const uint64 kExpectedAverage = kTopOfRange / 2ULL;
- const uint64 kAllowedVariance = kExpectedAverage / 50ULL; // +/- 2%
+ const uint64_t kTopOfRange =
+ (std::numeric_limits<uint64_t>::max() / 4ULL) * 3ULL;
+ const uint64_t kExpectedAverage = kTopOfRange / 2ULL;
+ const uint64_t kAllowedVariance = kExpectedAverage / 50ULL; // +/- 2%
const int kMinAttempts = 1000;
const int kMaxAttempts = 1000000;
double cumulative_average = 0.0;
int count = 0;
while (count < kMaxAttempts) {
- uint64 value = base::RandGenerator(kTopOfRange);
+ uint64_t value = base::RandGenerator(kTopOfRange);
cumulative_average = (count * cumulative_average + value) / (count + 1);
// Don't quit too quickly for things to start converging, or we may have
@@ -113,13 +117,13 @@
TEST(RandUtilTest, RandUint64ProducesBothValuesOfAllBits) {
// This tests to see that our underlying random generator is good
// enough, for some value of good enough.
- uint64 kAllZeros = 0ULL;
- uint64 kAllOnes = ~kAllZeros;
- uint64 found_ones = kAllZeros;
- uint64 found_zeros = kAllOnes;
+ uint64_t kAllZeros = 0ULL;
+ uint64_t kAllOnes = ~kAllZeros;
+ uint64_t found_ones = kAllZeros;
+ uint64_t found_zeros = kAllOnes;
for (size_t i = 0; i < 1000; ++i) {
- uint64 value = base::RandUint64();
+ uint64_t value = base::RandUint64();
found_ones |= value;
found_zeros &= value;
@@ -139,7 +143,7 @@
const int kTestIterations = 10;
const size_t kTestBufferSize = 1 * 1024 * 1024;
- scoped_ptr<uint8[]> buffer(new uint8[kTestBufferSize]);
+ scoped_ptr<uint8_t[]> buffer(new uint8_t[kTestBufferSize]);
const base::TimeTicks now = base::TimeTicks::Now();
for (int i = 0; i < kTestIterations; ++i)
base::RandBytes(buffer.get(), kTestBufferSize);