summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
authorextrawurst <mail@rusticorn.com>2022-12-21 08:17:33 +0100
committerextrawurst <mail@rusticorn.com>2022-12-21 08:17:33 +0100
commit669ea61019e7a3a461aeacc13532444d160f992c (patch)
tree69169c75ca777a231e857822a436b687cd65ee50 /src/ui
parent03dd0de07a5a2a974d55a3afe61b13f065c209af (diff)
followup 9ca6068
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/mod.rs32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/ui/mod.rs b/src/ui/mod.rs
index 72b74cfa..eac3e3b6 100644
--- a/src/ui/mod.rs
+++ b/src/ui/mod.rs
@@ -94,7 +94,7 @@ pub fn rect_inside(min: Size, max: Size, r: Rect) -> Rect {
};
let new_height = if min.height > max.height {
- max.width
+ max.height
} else {
r.height.clamp(min.height, max.height)
};
@@ -188,4 +188,34 @@ mod test {
}
);
}
+
+ #[test]
+ fn test_small_rect_in_rect2() {
+ let rect = rect_inside(
+ Size {
+ width: 1,
+ height: 3,
+ },
+ Size {
+ width: 1,
+ height: 2,
+ },
+ Rect {
+ x: 0,
+ y: 0,
+ width: 10,
+ height: 10,
+ },
+ );
+
+ assert_eq!(
+ rect,
+ Rect {
+ x: 0,
+ y: 0,
+ width: 1,
+ height: 2
+ }
+ );
+ }
}