tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 499HTML 238Markdown 7TOML 41214 Sutichaykuna

⎇ bce89b1006f36ce35abfaf1f1c2b3dd95f3dffd3 tests/generated/rounding_flex_basis_flex_shrink_row.rs Rust · 56 siq'ikuna · 2.3 KB Ñawpa willay Pi imata llamkarqan ch'uya

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

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