tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 499HTML 238Markdown 7TOML 41214 Sutichaykuna

⎇ a149c6b6b8f7d25328e78ba649b76d1841c55d9d tests/generated/flex_grow_less_than_factor_one.rs Rust · 51 siq'ikuna · 2.3 KB Ñawpa willay Pi imata llamkarqan ch'uya

index: update tests to API changes 48c69198a · msiglreith ·

1#[test]
2fn flex_grow_less_than_factor_one() {
3    let mut stretch = stretch::Stretch::new();
4    let node0 = stretch
5        .new_node(
6            stretch::style::Style {
7                flex_grow: 0.2f32,
8                flex_shrink: 0f32,
9                flex_basis: stretch::style::Dimension::Points(40f32),
10                ..Default::default()
11            },
12            vec![],
13        )
14        .unwrap();
15    let node1 = stretch
16        .new_node(stretch::style::Style { flex_grow: 0.2f32, flex_shrink: 0f32, ..Default::default() }, vec![])
17        .unwrap();
18    let node2 = stretch
19        .new_node(stretch::style::Style { flex_grow: 0.4f32, flex_shrink: 0f32, ..Default::default() }, vec![])
20        .unwrap();
21    let node = stretch
22        .new_node(
23            stretch::style::Style {
24                size: stretch::geometry::Size {
25                    width: stretch::style::Dimension::Points(500f32),
26                    height: stretch::style::Dimension::Points(200f32),
27                    ..Default::default()
28                },
29                ..Default::default()
30            },
31            vec![node0, node1, node2],
32        )
33        .unwrap();
34    stretch.compute_layout(node, stretch::geometry::Size::undefined()).unwrap();
35    assert_eq!(stretch.layout(node).unwrap().size.width, 500f32);
36    assert_eq!(stretch.layout(node).unwrap().size.height, 200f32);
37    assert_eq!(stretch.layout(node).unwrap().location.x, 0f32);
38    assert_eq!(stretch.layout(node).unwrap().location.y, 0f32);
39    assert_eq!(stretch.layout(node0).unwrap().size.width, 132f32);
40    assert_eq!(stretch.layout(node0).unwrap().size.height, 200f32);
41    assert_eq!(stretch.layout(node0).unwrap().location.x, 0f32);
42    assert_eq!(stretch.layout(node0).unwrap().location.y, 0f32);
43    assert_eq!(stretch.layout(node1).unwrap().size.width, 92f32);
44    assert_eq!(stretch.layout(node1).unwrap().size.height, 200f32);
45    assert_eq!(stretch.layout(node1).unwrap().location.x, 132f32);
46    assert_eq!(stretch.layout(node1).unwrap().location.y, 0f32);
47    assert_eq!(stretch.layout(node2).unwrap().size.width, 184f32);
48    assert_eq!(stretch.layout(node2).unwrap().size.height, 200f32);
49    assert_eq!(stretch.layout(node2).unwrap().location.x, 224f32);
50    assert_eq!(stretch.layout(node2).unwrap().location.y, 0f32);
51}