blob: b821f43be2381357a035a28c9e79f4f86d2f29eb (
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
|
use std::fmt::Display;
use ridicule::mock;
trait Foo<Something: Display>
{
fn bar(&self, something: &Something);
}
mock! {
MockFoo {}
impl<Something: Display> Foo<Something> for MockFoo
{
fn bar(&self, something: &Something);
}
}
fn main()
{
let mut mock_foo = MockFoo::new();
unsafe {
mock_foo.expect_bar().returning(|_me, something: &f32| {
println!("bar was called with {something}");
});
}
unsafe {
mock_foo.expect_bar().returning(|_me, something: &f64| {
println!("bar was called with {something}");
});
}
mock_foo.bar(&0.826f32);
mock_foo.bar(&0.410f64);
}
|