1
0
Fork 0
forked from wry/wry

rect: fix overflow in dist_squared

This commit is contained in:
Julian Orth 2026-03-06 13:10:25 +01:00
parent c689bc37b4
commit 872a028eb6
3 changed files with 27 additions and 10 deletions

View file

@ -704,3 +704,12 @@ fn new_saturating() {
let r3 = Rect::new_sized_saturating(i32::MAX - 10, 0, 100, 10);
assert_eq!(r3.x2(), i32::MAX);
}
#[test]
fn dist_squared() {
let r1 = Rect::new_sized_saturating(i32::MIN, i32::MIN, 0, 0);
assert_eq!(
r1.dist_squared(i32::MAX, i32::MAX),
(1 << 65) + 2 - (1 << 34),
);
}