gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 231Rust 8TOML 3CSS 1317 Sutichaykuna

⎇ 0.2.x tests/generated/margin_should_not_be_part_of_max_width.rs Rust · 44 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 margin_should_not_be_part_of_max_width() {
3    let mut taffy = taffy::Taffy::new();
4    let node0 = taffy
5        .new_with_children(
6            taffy::style::Style {
7                size: taffy::geometry::Size {
8                    width: taffy::style::Dimension::Points(100f32),
9                    height: taffy::style::Dimension::Points(100f32),
10                    ..Default::default()
11                },
12                max_size: taffy::geometry::Size {
13                    width: taffy::style::Dimension::Points(100f32),
14                    ..Default::default()
15                },
16                margin: taffy::geometry::Rect { left: taffy::style::Dimension::Points(20f32), ..Default::default() },
17                ..Default::default()
18            },
19            &[],
20        )
21        .unwrap();
22    let node = taffy
23        .new_with_children(
24            taffy::style::Style {
25                size: taffy::geometry::Size {
26                    width: taffy::style::Dimension::Points(250f32),
27                    height: taffy::style::Dimension::Points(250f32),
28                    ..Default::default()
29                },
30                ..Default::default()
31            },
32            &[node0],
33        )
34        .unwrap();
35    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
36    assert_eq!(taffy.layout(node).unwrap().size.width, 250f32);
37    assert_eq!(taffy.layout(node).unwrap().size.height, 250f32);
38    assert_eq!(taffy.layout(node).unwrap().location.x, 0f32);
39    assert_eq!(taffy.layout(node).unwrap().location.y, 0f32);
40    assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32);
41    assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32);
42    assert_eq!(taffy.layout(node0).unwrap().location.x, 20f32);
43    assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32);
44}