tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 735HTML 687Markdown 12TOML 62433 Definitions

⎇ f99b57fbad456aa2756b374ff40c876e4b9574c2 tests/generated/flex/position_root_with_rtl_should_position_withoutdirection.rs Rust · 75 lines · 4.0 KB History Who touched what raw

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

1#[test]
2#[allow(non_snake_case)]
3fn position_root_with_rtl_should_position_withoutdirection__border_box() {
4    #[allow(unused_imports)]
5    use taffy::{prelude::*, Layout};
6    let mut taffy = crate::new_test_tree();
7    let node0 = taffy
8        .new_leaf(taffy::style::Style {
9            size: taffy::geometry::Size {
10                width: taffy::style::Dimension::from_length(52f32),
11                height: taffy::style::Dimension::from_length(52f32),
12            },
13            inset: taffy::geometry::Rect { left: length(72f32), right: auto(), top: auto(), bottom: auto() },
14            ..Default::default()
15        })
16        .unwrap();
17    let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).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, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width);
25    assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, 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    let layout = taffy.layout(node0).unwrap();
29    let Layout { size, location, .. } = layout;
30    assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node0, 52f32, size.width);
31    assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node0, 52f32, size.height);
32    assert_eq!(location.x, 72f32, "x of node {:?}. Expected {}. Actual {}", node0, 72f32, location.x);
33    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
34}
35
36#[test]
37#[allow(non_snake_case)]
38fn position_root_with_rtl_should_position_withoutdirection__content_box() {
39    #[allow(unused_imports)]
40    use taffy::{prelude::*, Layout};
41    let mut taffy = crate::new_test_tree();
42    let node0 = taffy
43        .new_leaf(taffy::style::Style {
44            box_sizing: taffy::style::BoxSizing::ContentBox,
45            size: taffy::geometry::Size {
46                width: taffy::style::Dimension::from_length(52f32),
47                height: taffy::style::Dimension::from_length(52f32),
48            },
49            inset: taffy::geometry::Rect { left: length(72f32), right: auto(), top: auto(), bottom: auto() },
50            ..Default::default()
51        })
52        .unwrap();
53    let node = taffy
54        .new_with_children(
55            taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() },
56            &[node0],
57        )
58        .unwrap();
59    taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
60    println!("\nComputed tree:");
61    taffy.print_tree(node);
62    println!();
63    let layout = taffy.layout(node).unwrap();
64    let Layout { size, location, .. } = layout;
65    assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width);
66    assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height);
67    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
68    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
69    let layout = taffy.layout(node0).unwrap();
70    let Layout { size, location, .. } = layout;
71    assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node0, 52f32, size.width);
72    assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node0, 52f32, size.height);
73    assert_eq!(location.x, 72f32, "x of node {:?}. Expected {}. Actual {}", node0, 72f32, location.x);
74    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
75}