tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 707HTML 660Markdown 12TOML 62344 Sutichaykuna

⎇ 368b7da13d700e20ed1ef0fa2399fade0ca5ea3f tests/generated/flex/padding_no_child.rs Rust · 58 siq'ikuna · 2.4 KB Ñawpa willay Pi imata llamkarqan ch'uya

Use tagged pointer to represent size/length values (#769) afa6437b0 · Nico Burns ·

1#[test]
2#[allow(non_snake_case)]
3fn padding_no_child__border_box() {
4    #[allow(unused_imports)]
5    use taffy::{prelude::*, Layout};
6    let mut taffy = crate::new_test_tree();
7    let node = taffy
8        .new_leaf(taffy::style::Style {
9            padding: taffy::geometry::Rect {
10                left: length(10f32),
11                right: length(10f32),
12                top: length(10f32),
13                bottom: length(10f32),
14            },
15            ..Default::default()
16        })
17        .unwrap();
18    taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
19    println!("\nComputed tree:");
20    taffy.print_tree(node);
21    println!();
22    let layout = taffy.layout(node).unwrap();
23    let Layout { size, location, .. } = layout;
24    assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width);
25    assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, 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}
29
30#[test]
31#[allow(non_snake_case)]
32fn padding_no_child__content_box() {
33    #[allow(unused_imports)]
34    use taffy::{prelude::*, Layout};
35    let mut taffy = crate::new_test_tree();
36    let node = taffy
37        .new_leaf(taffy::style::Style {
38            box_sizing: taffy::style::BoxSizing::ContentBox,
39            padding: taffy::geometry::Rect {
40                left: length(10f32),
41                right: length(10f32),
42                top: length(10f32),
43                bottom: length(10f32),
44            },
45            ..Default::default()
46        })
47        .unwrap();
48    taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
49    println!("\nComputed tree:");
50    taffy.print_tree(node);
51    println!();
52    let layout = taffy.layout(node).unwrap();
53    let Layout { size, location, .. } = layout;
54    assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width);
55    assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height);
56    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
57    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
58}