Skip to content

Commit 1d12ddb

Browse files
lithdewfdehau
authored andcommitted
layout: add vertical split constraint test on height
1 parent f474c76 commit 1d12ddb

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/layout.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,31 @@ impl Rect {
463463
mod tests {
464464
use super::*;
465465

466+
#[test]
467+
fn test_vertical_split_by_height() {
468+
let target = Rect {
469+
x: 2,
470+
y: 2,
471+
width: 10,
472+
height: 10,
473+
};
474+
475+
let chunks = Layout::default()
476+
.direction(Direction::Vertical)
477+
.constraints(
478+
[
479+
Constraint::Percentage(10),
480+
Constraint::Max(5),
481+
Constraint::Min(1),
482+
]
483+
.as_ref(),
484+
)
485+
.split(target);
486+
487+
assert_eq!(target.height, chunks.iter().map(|r| r.height).sum::<u16>());
488+
chunks.windows(2).for_each(|w| assert!(w[0].y <= w[1].y));
489+
}
490+
466491
#[test]
467492
fn test_rect_size_truncation() {
468493
for width in 256u16..300u16 {

0 commit comments

Comments
 (0)