Fix tests on no_std

This commit is contained in:
Vinzent Steinberg
2018-05-11 13:23:09 +02:00
parent 0c85fb8a1d
commit 67c55eaf21
2 changed files with 6 additions and 6 deletions
+3 -4
View File
@@ -79,14 +79,13 @@ impl Distribution<bool> for Bernoulli {
#[cfg(test)]
mod test {
use rngs::SmallRng;
use {Rng, FromEntropy};
use Rng;
use distributions::Distribution;
use super::Bernoulli;
#[test]
fn test_trivial() {
let mut r = SmallRng::from_entropy();
let mut r = ::test::rng(1);
let always_false = Bernoulli::new(0.0);
let always_true = Bernoulli::new(1.0);
for _ in 0..5 {
@@ -104,7 +103,7 @@ mod test {
const N: u32 = 10_000_000;
let mut sum: u32 = 0;
let mut rng = SmallRng::from_entropy();
let mut rng = ::test::rng(2);
for _ in 0..N {
if d.sample(&mut rng) {
sum += 1;
+3 -2
View File
@@ -2,8 +2,8 @@
extern crate rand;
use rand::SeedableRng;
use rand::rngs::SmallRng;
use rand::FromEntropy;
use rand::distributions::{Distribution, Bernoulli};
/// This test should make sure that we don't accidentally have undefined
@@ -15,7 +15,8 @@ fn large_probability() {
let p = 1. - ::core::f64::EPSILON / 2.;
assert!(p < 1.);
let d = Bernoulli::new(p);
let mut rng = SmallRng::from_entropy();
let mut rng = SmallRng::from_seed(
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
for _ in 0..10 {
assert!(d.sample(&mut rng), "extremely unlikely to fail by accident");
}