mirror of https://github.com/eldruin/ds323x-rs
Extract assert invalid input data macro
parent
f497e919fc
commit
77820cf6d0
|
@ -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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue