Extract assert invalid input data macro

pull/4/head
Diego Barrios Romero 2018-11-03 07:51:24 +01:00
parent f497e919fc
commit 77820cf6d0
1 changed files with 11 additions and 4 deletions

View File

@ -109,16 +109,23 @@ macro_rules! set_test {
}; };
} }
#[macro_export]
macro_rules! assert_invalid_input_data {
($result:expr) => {
match $result {
Err(Error::InvalidInputData) => (),
_ => panic!("InvalidInputData error not returned.")
}
};
}
#[macro_export] #[macro_export]
macro_rules! set_invalid_test { macro_rules! set_invalid_test {
($name:ident, $method:ident, $create_method:ident, $destroy_method:ident, $value:expr) => { ($name:ident, $method:ident, $create_method:ident, $destroy_method:ident, $value:expr) => {
#[test] #[test]
fn $name() { fn $name() {
let mut dev = $create_method(&[]); let mut dev = $create_method(&[]);
match dev.$method($value) { assert_invalid_input_data!(dev.$method($value));
Err(Error::InvalidInputData) => (),
_ => panic!("InvalidInputData error not returned.")
}
$destroy_method(dev); $destroy_method(dev);
} }
}; };