blob: a0a586078afaf7b962298f470e2c172badd77f89 (
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
33
34
35
36
37
38
39
40
41
42
43
44
45
|
use std::fmt::Debug;
use ridicule::mock;
trait SomeFoobar
{
fn do_something(&self) -> bool;
}
trait Foo
{
fn bar<Baz>(&self, num: u128) -> Baz;
fn biz<Fiz: Debug, Bar>(&self, fiz: Fiz) -> &Bar;
fn baz<Foobar>(&self, name: &str, foobar: Foobar)
where
Foobar: SomeFoobar;
}
mock! {
MockFoo;
impl Foo for MockFoo {
fn bar<Baz>(self: (&Self), num: u128) -> Baz;
fn biz<Fiz: (Debug +), Bar>(self: (&Self), fiz: Fiz) -> &Bar;
fn baz<Foobar>(self: (&Self), name: &str, foobar: Foobar)
where (
Foobar: SomeFoobar
);
}
}
fn main()
{
let mut mock_foo = MockFoo::new();
mock_foo.expect_bar().returning(|_me, num| {
println!("bar was called with {num}");
});
mock_foo.bar::<()>(123);
}
|