blob: 189b45aad3620c918d2983d76c9e0588be83c2ed (
plain)
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
|
use ridicule::mock;
use ridicule::predicate::{always, eq};
trait Foo
{
fn bar(&self, num: u128, text: &str);
}
mock! {
MockFoo {}
impl Foo for MockFoo
{
fn bar(&self, num: u128, text: &str);
}
}
fn main()
{
let mut mock_foo = MockFoo::new();
unsafe {
mock_foo
.expect_bar()
.with(eq(1234), always())
.returning(|_, num, text| {
println!("bar was called with {num} and '{text}'");
});
}
mock_foo.bar(1234, "Hello");
}
|