Just to have a chance to try it out: Switch to proptest.

This commit is contained in:
2022-01-08 16:34:40 -08:00
parent aa414fd527
commit 811580c64f
10 changed files with 123 additions and 192 deletions

View File

@@ -1,32 +1,15 @@
#[cfg(test)]
use quickcheck::{Arbitrary, Gen};
#[cfg(test)]
pub fn arbitrary_socks_string(g: &mut Gen) -> String {
loop {
let mut potential = String::arbitrary(g);
potential.truncate(255);
let bytestring = potential.as_bytes();
if !bytestring.is_empty() && bytestring.len() < 256 {
return potential;
}
}
}
#[doc(hidden)]
#[macro_export]
macro_rules! standard_roundtrip {
($name: ident, $t: ty) => {
#[cfg(test)]
quickcheck! {
fn $name(xs: $t) -> bool {
proptest! {
#[test]
fn $name(xs: $t) {
let mut buffer = vec![];
task::block_on(xs.write(&mut buffer)).unwrap();
let mut cursor = Cursor::new(buffer);
let ys = <$t>::read(&mut cursor);
xs == task::block_on(ys).unwrap()
assert_eq!(xs, task::block_on(ys).unwrap());
}
}
};