⎇ 368b7da13d700e20ed1ef0fa2399fade0ca5ea3f
tests/generated/flex/absolute_layout_width_height_end_bottom.rs
Historia
Quién tocó qué
crudo
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn absolute_layout_width_height_end_bottom__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 position: taffy::style::Position::Absolute,
10 size: taffy::geometry::Size {
11 width: taffy::style::Dimension::from_length(10f32),
12 height: taffy::style::Dimension::from_length(10f32),
13 },
14 inset: taffy::geometry::Rect { left: auto(), right: length(10f32), top: auto(), bottom: length(10f32) },
15 ..Default::default()
16 })
17 .unwrap();
18 let node = taffy
19 .new_with_children(
20 taffy::style::Style {
21 size: taffy::geometry::Size {
22 width: taffy::style::Dimension::from_length(100f32),
23 height: taffy::style::Dimension::from_length(100f32),
24 },
25 ..Default::default()
26 },
27 &[node0],
28 )
29 .unwrap();
30 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
31 println!("\nComputed tree:");
32 taffy.print_tree(node);
33 println!();
34 let layout = taffy.layout(node).unwrap();
35 let Layout { size, location, .. } = layout;
36 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
37 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
38 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
39 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
40 let layout = taffy.layout(node0).unwrap();
41 let Layout { size, location, .. } = layout;
42 assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width);
43 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height);
44 assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node0, 80f32, location.x);
45 assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node0, 80f32, location.y);
46}
47
48#[test]
49#[allow(non_snake_case)]
50fn absolute_layout_width_height_end_bottom__content_box() {
51 #[allow(unused_imports)]
52 use taffy::{prelude::*, Layout};
53 let mut taffy = crate::new_test_tree();
54 let node0 = taffy
55 .new_leaf(taffy::style::Style {
56 box_sizing: taffy::style::BoxSizing::ContentBox,
57 position: taffy::style::Position::Absolute,
58 size: taffy::geometry::Size {
59 width: taffy::style::Dimension::from_length(10f32),
60 height: taffy::style::Dimension::from_length(10f32),
61 },
62 inset: taffy::geometry::Rect { left: auto(), right: length(10f32), top: auto(), bottom: length(10f32) },
63 ..Default::default()
64 })
65 .unwrap();
66 let node = taffy
67 .new_with_children(
68 taffy::style::Style {
69 box_sizing: taffy::style::BoxSizing::ContentBox,
70 size: taffy::geometry::Size {
71 width: taffy::style::Dimension::from_length(100f32),
72 height: taffy::style::Dimension::from_length(100f32),
73 },
74 ..Default::default()
75 },
76 &[node0],
77 )
78 .unwrap();
79 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
80 println!("\nComputed tree:");
81 taffy.print_tree(node);
82 println!();
83 let layout = taffy.layout(node).unwrap();
84 let Layout { size, location, .. } = layout;
85 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
86 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
87 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
88 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
89 let layout = taffy.layout(node0).unwrap();
90 let Layout { size, location, .. } = layout;
91 assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width);
92 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height);
93 assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node0, 80f32, location.x);
94 assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node0, 80f32, location.y);
95}