1
0
Fork 0
forked from wry/wry

rect: safer construction

This commit is contained in:
Stipe Kotarac 2025-12-29 10:42:17 +01:00 committed by Julian Orth
parent 411af0ea18
commit a1dfc473a2
33 changed files with 245 additions and 159 deletions

View file

@ -688,3 +688,19 @@ fn intersect3() {
],
);
}
#[test]
fn new_saturating() {
let r1 = Rect::new_sized_saturating(10, 10, -5, -5);
assert!(r1.is_empty());
assert_eq!(r1.x1(), 10);
assert_eq!(r1.x2(), 10);
let r2 = Rect::new_saturating(100, 100, 50, 50);
assert!(r2.is_empty());
assert_eq!(r2.x1(), 100);
assert_eq!(r2.x2(), 100);
let r3 = Rect::new_sized_saturating(i32::MAX - 10, 0, 100, 10);
assert_eq!(r3.x2(), i32::MAX);
}