gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 501HTML 254C 19JavaScript 81412 Definitions

⎇ 0.2.x tests/generated/min_height_overrides_max_height.rs Rust · 30 lines · 1.3 KB History Who touched what raw

Min values should override max values (#262) b952c2b38 · George Atkinson ·

1#[test]
2fn min_height_overrides_max_height() {
3    let mut taffy = taffy::Taffy::new();
4    let node0 = taffy
5        .new_with_children(
6            taffy::style::Style {
7                min_size: taffy::geometry::Size {
8                    height: taffy::style::Dimension::Points(100f32),
9                    ..Default::default()
10                },
11                max_size: taffy::geometry::Size {
12                    height: taffy::style::Dimension::Points(50f32),
13                    ..Default::default()
14                },
15                ..Default::default()
16            },
17            &[],
18        )
19        .unwrap();
20    let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap();
21    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
22    assert_eq!(taffy.layout(node).unwrap().size.width, 0f32);
23    assert_eq!(taffy.layout(node).unwrap().size.height, 100f32);
24    assert_eq!(taffy.layout(node).unwrap().location.x, 0f32);
25    assert_eq!(taffy.layout(node).unwrap().location.y, 0f32);
26    assert_eq!(taffy.layout(node0).unwrap().size.width, 0f32);
27    assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32);
28    assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32);
29    assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32);
30}