summaryrefslogtreecommitdiff
path: root/examples/basic.rs
blob: a157413e0ae4dec19a8c67abbefc0bd52e5451c0 (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
use ridicule::mock;

trait Foo: Sized
{
    fn bar(&self, num: u128) -> &Self;
}

mock! {
    MockFoo {}

    impl Foo for MockFoo
    {
        fn bar(&self, num: u128) -> &Self;
    }
}

fn main()
{
    let mut mock_foo = MockFoo::new();

    mock_foo.expect_bar().returning(|me, num| {
        println!("bar was called with {num}");

        me
    });

    mock_foo.bar(123);
}