[−][src]Struct mockiato::Argument
A factory for creating argument matchers
Methods
impl Argument
[src]
pub fn any(&self) -> AnyArgumentMatcher
[src]
Crates an argument matcher that matches any value.
Examples
use mockiato::{mockable, Argument}; #[cfg_attr(test, mockable)] trait MessageSender { fn send_message(&self, message: &str); } let mut sender = MessageSenderMock::new(); let message = "Don't make lemonade"; sender.expect_send_message(Argument::any); sender.send_message(message);
impl Argument
[src]
pub fn nearly_eq<T, U>(&self, value: T) -> NearlyEqArgumentMatcher<T, U> where
T: NearlyEq<T, U> + MaybeDebug,
U: MaybeDebug,
[src]
T: NearlyEq<T, U> + MaybeDebug,
U: MaybeDebug,
Creates an argument matcher that matches values using NearlyEq
.
Uses the default epsilon value defined by NearlyEq
.
Examples
use mockiato::mockable; #[cfg_attr(test, mockable)] trait FloatFormatter { fn format_float(&self, value: f64) -> String; } let expected_result = String::from("0.3"); let mut formatter = FloatFormatterMock::new(); formatter .expect_format_float(|arg| arg.nearly_eq(0.3)) .returns(expected_result.clone()); assert_eq!(expected_result, formatter.format_float(0.1 + 0.2),)
pub fn nearly_eq_with_accuracy<T, U>(
&self,
value: T,
accuracy: U
) -> NearlyEqArgumentMatcher<T, U> where
T: NearlyEq<T, U> + MaybeDebug,
U: MaybeDebug,
[src]
&self,
value: T,
accuracy: U
) -> NearlyEqArgumentMatcher<T, U> where
T: NearlyEq<T, U> + MaybeDebug,
U: MaybeDebug,
Creates an argument matcher that matches values using NearlyEq
.
A custom epislon value can be passed.
Examples
use mockiato::mockable; #[cfg_attr(test, mockable)] trait FloatFormatter { fn format_float(&self, value: f64) -> String; } let expected_result = String::from("0.3"); let mut formatter = FloatFormatterMock::new(); formatter .expect_format_float(|arg| arg.nearly_eq_with_accuracy(0.3, 1e-10)) .returns(expected_result.clone()); assert_eq!(expected_result, formatter.format_float(0.1 + 0.2),)
impl Argument
[src]
pub fn partial_eq<T>(&self, value: T) -> PartialEqArgumentMatcher<T>
[src]
Creates an argument matcher that matches values using PartialEq
.
Examples
use mockiato::mockable; #[cfg_attr(test, mockable)] trait MessageSender { fn send_message(&self, message: &str); } let mut sender = MessageSenderMock::new(); let message = "Hello World"; sender.expect_send_message(|arg| arg.partial_eq(message)); sender.send_message(message);
pub fn partial_eq_owned<T>(&self, value: T) -> OwnedPartialEqArgumentMatcher<T>
[src]
Creates an argument matcher that matches an owned value against references of itself using PartialEq
.
Examples
use mockiato::mockable; #[derive(Clone, PartialEq)] enum Message { Ping, } #[cfg_attr(test, mockable)] trait MessageSender { fn send_message(&self, message: &Message); } let mut sender = MessageSenderMock::new(); sender.expect_send_message(|arg| arg.partial_eq_owned(Message::Ping)); sender.send_message(&Message::Ping);
impl Argument
[src]
pub fn unordered_vec_eq<T>(&self, vec: Vec<T>) -> UnorderedVecArgumentMatcher<T>
[src]
Creates an argument matcher that matches against Vec
s and slice
s
while disregarding the exact order of the elements.
Requires the elements to implement PartialEq
.
Examples
use mockiato::mockable; #[cfg_attr(test, mockable)] trait MessageSender { fn send_message(&self, messages: &[&str]); } let mut sender = MessageSenderMock::new(); let message = "Hello World"; sender.expect_send_message(|arg| arg.unordered_vec_eq(vec!["foo", "bar", "baz"])); sender.send_message(&["baz", "bar", "foo"]);
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,