Skip to content

Commit

Permalink
Add randomized border to proptest
Browse files Browse the repository at this point in the history
  • Loading branch information
YaLTeR committed Dec 29, 2023
1 parent c64e96d commit 46d5f5e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/layout/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2186,6 +2186,10 @@ mod tests {
check_ops_with_options(options, &ops);
}

fn arbitrary_border() -> impl Strategy<Value = u16> {
prop_oneof![Just(0), (1..=u16::MAX)]
}

proptest! {
#![proptest_config(ProptestConfig {
cases: if std::env::var_os("RUN_SLOW_TESTS").is_none() {
Expand All @@ -2198,9 +2202,15 @@ mod tests {
})]

#[test]
fn random_operations_dont_panic(ops: Vec<Op>) {
fn random_operations_dont_panic(ops: Vec<Op>, border in arbitrary_border()) {
let mut options = Options::default();
if border != 0 {
options.border.off = false;
options.border.width = border;
}

// eprintln!("{ops:?}");
check_ops(&ops);
check_ops_with_options(options, &ops);
}
}
}

0 comments on commit 46d5f5e

Please sign in to comment.