forge
Explore
Log in

Don't you dare go Hollow

Add negative struts to tests

Browse files at this commit

b454fd5d9ee5b1fc9797a9ccbd8b3d0d1f49f05dIvan MolodetskikhParent: 2a830ed
src/layout/mod.rsmodified+13 -4
@@ -4271,12 +4271,21 @@ mod tests {
4271 prop_oneof![Just(0.), Just(4.), ((1.)..=65535.)]4271 prop_oneof![Just(0.), Just(4.), ((1.)..=65535.)]
4272 }4272 }
4273 4273
4274+ fn arbitrary_spacing_neg() -> impl Strategy<Value = f64> {
4275+ // Give equal weight to:
4276+ // - 0: the element is disabled
4277+ // - 4: some reasonable value
4278+ // - -4: some reasonable negative value
4279+ // - random value, likely unreasonably big
4280+ prop_oneof![Just(0.), Just(4.), Just(-4.), ((1.)..=65535.)]
4281+ }
4282+
4274 fn arbitrary_struts() -> impl Strategy<Value = Struts> {4283 fn arbitrary_struts() -> impl Strategy<Value = Struts> {
4275 (4284 (
4276- arbitrary_spacing(),4285+ arbitrary_spacing_neg(),
4277- arbitrary_spacing(),4286+ arbitrary_spacing_neg(),
4278- arbitrary_spacing(),4287+ arbitrary_spacing_neg(),
4279- arbitrary_spacing(),4288+ arbitrary_spacing_neg(),
4280 )4289 )
4281 .prop_map(|(left, right, top, bottom)| Struts {4290 .prop_map(|(left, right, top, bottom)| Struts {
4282 left: FloatOrInt(left),4291 left: FloatOrInt(left),