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
use crate::reactor::*;
impl<'a, S, T> Reactor<S> for &'a mut T
where
S: ?Sized,
T: Reactor<S> + ?Sized,
{
type Error = T::Error;
fn react(&mut self, state: &S) -> Result<(), Self::Error> {
(**self).react(state)
}
}
#[cfg(test)]
mod tests {
use super::*;
use mockall::predicate::*;
use test_strategy::proptest;
#[proptest]
fn react(state: u8, result: Result<(), u8>) {
let mut mock = MockReactor::new();
mock.expect_react()
.with(eq(state))
.once()
.return_const(result);
let mut reactor = &mut mock;
assert_eq!(Reactor::react(&mut reactor, &state), result);
}
}