gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1068HTML 999Markdown 12TOML 83188 Definitions

⎇ 48e4800f14c6af5cd26275fb570d11b93e279654 tests/generated/flex/flex_basis_unconstraint_column.rs Rust · 33 lines · 1.8 KB History Who touched what raw

Sort test fixtures and generated tests into folders (#514) 24b8faf43 · aemreaydin ·

1#[test]
2fn flex_basis_unconstraint_column() {
3    #[allow(unused_imports)]
4    use taffy::{prelude::*, tree::Layout};
5    let mut taffy = taffy::Taffy::new();
6    let node0 = taffy
7        .new_leaf(taffy::style::Style {
8            flex_basis: taffy::style::Dimension::Length(50f32),
9            size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() },
10            ..Default::default()
11        })
12        .unwrap();
13    let node = taffy
14        .new_with_children(
15            taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() },
16            &[node0],
17        )
18        .unwrap();
19    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
20    println!("\nComputed tree:");
21    taffy::util::print_tree(&taffy, node);
22    println!();
23    let Layout { size, location, .. } = taffy.layout(node).unwrap();
24    assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
25    assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height);
26    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
27    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
28    let Layout { size, location, .. } = taffy.layout(node0).unwrap();
29    assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width);
30    assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height);
31    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
32    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
33}