From b454fd5d9ee5b1fc9797a9ccbd8b3d0d1f49f05d Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Mon, 22 Jul 2024 12:35:57 +0300 Subject: Add negative struts to tests --- src/layout/mod.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/layout') diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 21e90668..97a839c1 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -4271,12 +4271,21 @@ mod tests { prop_oneof![Just(0.), Just(4.), ((1.)..=65535.)] } + fn arbitrary_spacing_neg() -> impl Strategy { + // Give equal weight to: + // - 0: the element is disabled + // - 4: some reasonable value + // - -4: some reasonable negative value + // - random value, likely unreasonably big + prop_oneof![Just(0.), Just(4.), Just(-4.), ((1.)..=65535.)] + } + fn arbitrary_struts() -> impl Strategy { ( - arbitrary_spacing(), - arbitrary_spacing(), - arbitrary_spacing(), - arbitrary_spacing(), + arbitrary_spacing_neg(), + arbitrary_spacing_neg(), + arbitrary_spacing_neg(), + arbitrary_spacing_neg(), ) .prop_map(|(left, right, top, bottom)| Struts { left: FloatOrInt(left), -- cgit