summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/basic.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/examples/basic.rs b/examples/basic.rs
new file mode 100644
index 0000000..a157413
--- /dev/null
+++ b/examples/basic.rs
@@ -0,0 +1,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);
+}