| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 BucketTestUnsignedInterval(7, 100000, 1, 14, 3, &prng); | 192 BucketTestUnsignedInterval(7, 100000, 1, 14, 3, &prng); |
| 193 BucketTestUnsignedInterval(11, 100000, 1000, 1010, 3, &prng); | 193 BucketTestUnsignedInterval(11, 100000, 1000, 1010, 3, &prng); |
| 194 BucketTestUnsignedInterval(100, 100000, 0, 99, 3, &prng); | 194 BucketTestUnsignedInterval(100, 100000, 0, 99, 3, &prng); |
| 195 BucketTestUnsignedInterval(2, 100000, 0, 4294967295, 3, &prng); | 195 BucketTestUnsignedInterval(2, 100000, 0, 4294967295, 3, &prng); |
| 196 BucketTestUnsignedInterval(17, 100000, 455, 2147484110, 3, &prng); | 196 BucketTestUnsignedInterval(17, 100000, 455, 2147484110, 3, &prng); |
| 197 // 99.7% of all samples will be within 3 standard deviations of the mean, | 197 // 99.7% of all samples will be within 3 standard deviations of the mean, |
| 198 // but since we test 1000 buckets we allow an interval of 4 sigma. | 198 // but since we test 1000 buckets we allow an interval of 4 sigma. |
| 199 BucketTestUnsignedInterval(1000, 1000000, 0, 2147483999, 4, &prng); | 199 BucketTestUnsignedInterval(1000, 1000000, 0, 2147483999, 4, &prng); |
| 200 } | 200 } |
| 201 | 201 |
| 202 // Disabled for UBSan: https://bugs.chromium.org/p/webrtc/issues/detail?id=5491 | 202 TEST(RandomNumberGeneratorTest, UniformSignedInterval) { |
| 203 #ifdef UNDEFINED_SANITIZER | |
| 204 #define MAYBE_UniformSignedInterval DISABLED_UniformSignedInterval | |
| 205 #else | |
| 206 #define MAYBE_UniformSignedInterval UniformSignedInterval | |
| 207 #endif | |
| 208 TEST(RandomNumberGeneratorTest, MAYBE_UniformSignedInterval) { | |
| 209 Random prng(66260695729ull); | 203 Random prng(66260695729ull); |
| 210 BucketTestSignedInterval(2, 100000, 0, 1, 3, &prng); | 204 BucketTestSignedInterval(2, 100000, 0, 1, 3, &prng); |
| 211 BucketTestSignedInterval(7, 100000, -2, 4, 3, &prng); | 205 BucketTestSignedInterval(7, 100000, -2, 4, 3, &prng); |
| 212 BucketTestSignedInterval(11, 100000, 1000, 1010, 3, &prng); | 206 BucketTestSignedInterval(11, 100000, 1000, 1010, 3, &prng); |
| 213 BucketTestSignedInterval(100, 100000, 0, 99, 3, &prng); | 207 BucketTestSignedInterval(100, 100000, 0, 99, 3, &prng); |
| 214 BucketTestSignedInterval(2, 100000, std::numeric_limits<int32_t>::min(), | 208 BucketTestSignedInterval(2, 100000, std::numeric_limits<int32_t>::min(), |
| 215 std::numeric_limits<int32_t>::max(), 3, &prng); | 209 std::numeric_limits<int32_t>::max(), 3, &prng); |
| 216 BucketTestSignedInterval(17, 100000, -1073741826, 1073741829, 3, &prng); | 210 BucketTestSignedInterval(17, 100000, -1073741826, 1073741829, 3, &prng); |
| 217 // 99.7% of all samples will be within 3 standard deviations of the mean, | 211 // 99.7% of all samples will be within 3 standard deviations of the mean, |
| 218 // but since we test 1000 buckets we allow an interval of 4 sigma. | 212 // but since we test 1000 buckets we allow an interval of 4 sigma. |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 double f_mid = kScale * exp((n - kMean) * (n - kMean) / kDiv); | 294 double f_mid = kScale * exp((n - kMean) * (n - kMean) / kDiv); |
| 301 double f_right = kScale * exp((n - kMean + 0.5) * (n - kMean + 0.5) / kDiv); | 295 double f_right = kScale * exp((n - kMean + 0.5) * (n - kMean + 0.5) / kDiv); |
| 302 double normal_dist = (f_left + 4 * f_mid + f_right) / 6; | 296 double normal_dist = (f_left + 4 * f_mid + f_right) / 6; |
| 303 // Expect the number of samples to be within 3 standard deviations | 297 // Expect the number of samples to be within 3 standard deviations |
| 304 // (rounded up) of the expected number of samples in the bucket. | 298 // (rounded up) of the expected number of samples in the bucket. |
| 305 EXPECT_NEAR(buckets[n], kN * normal_dist, 3 * sqrt(kN * normal_dist) + 1); | 299 EXPECT_NEAR(buckets[n], kN * normal_dist, 3 * sqrt(kN * normal_dist) + 1); |
| 306 } | 300 } |
| 307 } | 301 } |
| 308 | 302 |
| 309 } // namespace webrtc | 303 } // namespace webrtc |
| OLD | NEW |