Skip to content

Commit

Permalink
Merge pull request #6 from hobofan/pub_struct
Browse files Browse the repository at this point in the history
allow definition of pub struct via mock_trait
  • Loading branch information
DonaldWhyte authored Aug 3, 2017
2 parents 8f41c40 + 8994d84 commit 6c22eaa
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,25 @@ macro_rules! mock_trait {
}
}
);

(pub $mock_name:ident $(, $method:ident($($arg_type:ty),* ) -> $retval:ty )* ) => (
#[derive(Debug, Clone)]
pub struct $mock_name {
$(
$method: double::Mock<(($($arg_type),*)), $retval>
),*
}

impl Default for $mock_name {
fn default() -> Self {
$mock_name {
$(
$method: double::Mock::default()
),*
}
}
}
);
}

/// Macro that generates a mock implementation of a `trait` method.
Expand Down

0 comments on commit 6c22eaa

Please sign in to comment.