1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
use rand::SeedableRng;
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub enum ShouldFail {
No,
Yes,
YesWithMessage(&'static str),
}
pub trait Test: Send + Sync {
fn name(&self) -> &'static str;
fn ignored(&self) -> bool {
false
}
fn should_fail(&self) -> ShouldFail {
ShouldFail::No
}
}
impl<T: Test + ?Sized> Test for &T {
fn name(&self) -> &'static str {
(**self).name()
}
fn ignored(&self) -> bool {
(**self).ignored()
}
fn should_fail(&self) -> ShouldFail {
(**self).should_fail()
}
}
#[derive(Debug)]
pub struct CoreContext {
rng: ::rand::rngs::StdRng,
}
impl CoreContext {
pub fn new(rng: ::rand::rngs::StdRng) -> Self {
Self { rng }
}
pub fn from_rng<R: ::rand::RngCore + ::rand::CryptoRng>(rng: R) -> Self {
Self {
rng: ::rand::rngs::StdRng::from_rng(rng).unwrap(),
}
}
pub fn rng(&mut self) -> &mut ::rand::rngs::StdRng {
&mut self.rng
}
}