tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 790HTML 742Markdown 12TOML 62540 Sutichaykuna

⎇ ca514f6c8ddc2a934f97170227bbe109223c80b8 tests/generated/absolute_layout_width_height_start_top.rs Rust · 45 siq'ikuna · 1.8 KB Ñawpa willay Pi imata llamkarqan ch'uya

Rename Rect field start->left end->right (#257) ca514f6c8 · Nico Burns ·

1#[test]
2fn absolute_layout_width_height_start_top() {
3    let mut taffy = taffy::Taffy::new();
4    let node0 = taffy
5        .new_with_children(
6            taffy::style::Style {
7                position_type: taffy::style::PositionType::Absolute,
8                size: taffy::geometry::Size {
9                    width: taffy::style::Dimension::Points(10f32),
10                    height: taffy::style::Dimension::Points(10f32),
11                    ..Default::default()
12                },
13                position: taffy::geometry::Rect {
14                    left: taffy::style::Dimension::Points(10f32),
15                    top: taffy::style::Dimension::Points(10f32),
16                    ..Default::default()
17                },
18                ..Default::default()
19            },
20            &[],
21        )
22        .unwrap();
23    let node = taffy
24        .new_with_children(
25            taffy::style::Style {
26                size: taffy::geometry::Size {
27                    width: taffy::style::Dimension::Points(100f32),
28                    height: taffy::style::Dimension::Points(100f32),
29                    ..Default::default()
30                },
31                ..Default::default()
32            },
33            &[node0],
34        )
35        .unwrap();
36    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
37    assert_eq!(taffy.layout(node).unwrap().size.width, 100f32);
38    assert_eq!(taffy.layout(node).unwrap().size.height, 100f32);
39    assert_eq!(taffy.layout(node).unwrap().location.x, 0f32);
40    assert_eq!(taffy.layout(node).unwrap().location.y, 0f32);
41    assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32);
42    assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32);
43    assert_eq!(taffy.layout(node0).unwrap().location.x, 10f32);
44    assert_eq!(taffy.layout(node0).unwrap().location.y, 10f32);
45}