#[cfg(test)]
#[macro_export]
macro_rules! fuzz_bytes {
($test_name:ident, $type:ty, $max_size:expr) => {
proptest::proptest! {
#[test]
fn $test_name(bytes in proptest::collection::vec(proptest::arbitrary::any::<u8>(), 0..$max_size)) {
let _ = <$type>::from_bytes(&bytes);
}
}
};
}
#[cfg(test)]
#[macro_export]
macro_rules! fuzz_bytes_fn {
($test_name:ident, $fn_name:ident, $max_size:expr) => {
proptest::proptest! {
#[test]
fn $test_name(bytes in proptest::collection::vec(proptest::arbitrary::any::<u8>(), 0..$max_size)) {
let _ = $fn_name(&bytes);
}
}
};
}
#[cfg(test)]
#[macro_export]
macro_rules! fuzz_bytes_with_type {
($test_name:ident, $type:ty, $hint_type:ty, [$($variant:ident),+ $(,)?], $max_size:expr) => {
proptest::proptest! {
#[test]
fn $test_name(bytes in proptest::collection::vec(proptest::arbitrary::any::<u8>(), 0..$max_size)) {
$(
let _ = <$type>::from_bytes(&bytes, <$hint_type>::$variant);
)+
}
}
};
}