fix(bytecode): make sure the proptest runs long enough

This commit is contained in:
Alain Zscheile 2022-09-23 07:54:00 +02:00
parent 7c992a5c84
commit ec6eed9a7f
2 changed files with 16 additions and 6 deletions

View file

@ -93,11 +93,16 @@ mod tests {
use super::*;
proptest::proptest! {
#![proptest_config(proptest::prelude::ProptestConfig::with_cases(4096))]
#[test]
fn doesnt_crash(inp in proptest::collection::vec(0..=u8::MAX, 0..256)) {
if let Ok((_, v)) = <Instr as crate::Parse<'_>>::parse(&inp[..]) {
let mut buf = alloc::vec::Vec::with_capacity(inp.len());
fn doesnt_crash(inp in proptest::collection::vec(0..=u8::MAX, 0..1024)) {
let mut inp = &inp[..];
while let Ok((xinp, v)) = <Instr as crate::Parse<'_>>::parse(&inp[..]) {
let mut buf = alloc::vec::Vec::with_capacity(inp.len() - xinp.len());
v.write_to(&mut buf).unwrap();
assert_eq!(buf[..], inp[..inp.len() - xinp.len()]);
inp = xinp;
}
}
}

View file

@ -110,11 +110,16 @@ mod tests {
use super::*;
proptest::proptest! {
#![proptest_config(proptest::prelude::ProptestConfig::with_cases(4096))]
#[test]
fn doesnt_crash(inp in proptest::collection::vec(0..=u8::MAX, 0..256)) {
if let Ok((_, v)) = <Value as crate::Parse<'_>>::parse(&inp[..]) {
let mut buf = alloc::vec::Vec::with_capacity(inp.len());
fn doesnt_crash(inp in proptest::collection::vec(0..=u8::MAX, 0..1024)) {
let mut inp = &inp[..];
while let Ok((xinp, v)) = <Value as crate::Parse<'_>>::parse(&inp[..]) {
let mut buf = alloc::vec::Vec::with_capacity(inp.len() - xinp.len());
v.write_to(&mut buf).unwrap();
assert_eq!(buf[..], inp[..inp.len() - xinp.len()]);
inp = xinp;
}
}
}