| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/rand_util.h" | 5 #include "base/rand_util.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/googletest/include/gtest/gtest.h" |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 const int kIntMin = std::numeric_limits<int>::min(); | 17 const int kIntMin = std::numeric_limits<int>::min(); |
| 18 const int kIntMax = std::numeric_limits<int>::max(); | 18 const int kIntMax = std::numeric_limits<int>::max(); |
| 19 | 19 |
| 20 } // namespace | 20 } // namespace |
| 21 | 21 |
| 22 TEST(RandUtilTest, RandInt) { | 22 TEST(RandUtilTest, RandInt) { |
| 23 EXPECT_EQ(base::RandInt(0, 0), 0); | 23 EXPECT_EQ(base::RandInt(0, 0), 0); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 141 |
| 142 scoped_ptr<uint8[]> buffer(new uint8[kTestBufferSize]); | 142 scoped_ptr<uint8[]> buffer(new uint8[kTestBufferSize]); |
| 143 const base::TimeTicks now = base::TimeTicks::Now(); | 143 const base::TimeTicks now = base::TimeTicks::Now(); |
| 144 for (int i = 0; i < kTestIterations; ++i) | 144 for (int i = 0; i < kTestIterations; ++i) |
| 145 base::RandBytes(buffer.get(), kTestBufferSize); | 145 base::RandBytes(buffer.get(), kTestBufferSize); |
| 146 const base::TimeTicks end = base::TimeTicks::Now(); | 146 const base::TimeTicks end = base::TimeTicks::Now(); |
| 147 | 147 |
| 148 LOG(INFO) << "RandBytes(" << kTestBufferSize << ") took: " | 148 LOG(INFO) << "RandBytes(" << kTestBufferSize << ") took: " |
| 149 << (end - now).InMicroseconds() << "µs"; | 149 << (end - now).InMicroseconds() << "µs"; |
| 150 } | 150 } |
| OLD | NEW |