Skip to content

Commit 67c55ea

Browse files
committed
Fix tests on no_std
1 parent 0c85fb8 commit 67c55ea

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/distributions/bernoulli.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,13 @@ impl Distribution<bool> for Bernoulli {
7979

8080
#[cfg(test)]
8181
mod test {
82-
use rngs::SmallRng;
83-
use {Rng, FromEntropy};
82+
use Rng;
8483
use distributions::Distribution;
8584
use super::Bernoulli;
8685

8786
#[test]
8887
fn test_trivial() {
89-
let mut r = SmallRng::from_entropy();
88+
let mut r = ::test::rng(1);
9089
let always_false = Bernoulli::new(0.0);
9190
let always_true = Bernoulli::new(1.0);
9291
for _ in 0..5 {
@@ -104,7 +103,7 @@ mod test {
104103
const N: u32 = 10_000_000;
105104

106105
let mut sum: u32 = 0;
107-
let mut rng = SmallRng::from_entropy();
106+
let mut rng = ::test::rng(2);
108107
for _ in 0..N {
109108
if d.sample(&mut rng) {
110109
sum += 1;

tests/bool.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
extern crate rand;
44

5+
use rand::SeedableRng;
56
use rand::rngs::SmallRng;
6-
use rand::FromEntropy;
77
use rand::distributions::{Distribution, Bernoulli};
88

99
/// This test should make sure that we don't accidentally have undefined
@@ -15,7 +15,8 @@ fn large_probability() {
1515
let p = 1. - ::core::f64::EPSILON / 2.;
1616
assert!(p < 1.);
1717
let d = Bernoulli::new(p);
18-
let mut rng = SmallRng::from_entropy();
18+
let mut rng = SmallRng::from_seed(
19+
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
1920
for _ in 0..10 {
2021
assert!(d.sample(&mut rng), "extremely unlikely to fail by accident");
2122
}

0 commit comments

Comments
 (0)