⎇ 368b7da13d700e20ed1ef0fa2399fade0ca5ea3f
tests/generated/flex/align_self_baseline.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn align_self_baseline__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 align_self: Some(taffy::style::AlignSelf::Baseline),
10 size: taffy::geometry::Size {
11 width: taffy::style::Dimension::from_length(50f32),
12 height: taffy::style::Dimension::from_length(50f32),
13 },
14 ..Default::default()
15 })
16 .unwrap();
17 let node10 = taffy
18 .new_leaf(taffy::style::Style {
19 size: taffy::geometry::Size {
20 width: taffy::style::Dimension::from_length(50f32),
21 height: taffy::style::Dimension::from_length(10f32),
22 },
23 ..Default::default()
24 })
25 .unwrap();
26 let node1 = taffy
27 .new_with_children(
28 taffy::style::Style {
29 align_self: Some(taffy::style::AlignSelf::Baseline),
30 size: taffy::geometry::Size {
31 width: taffy::style::Dimension::from_length(50f32),
32 height: taffy::style::Dimension::from_length(20f32),
33 },
34 ..Default::default()
35 },
36 &[node10],
37 )
38 .unwrap();
39 let node = taffy
40 .new_with_children(
41 taffy::style::Style {
42 size: taffy::geometry::Size {
43 width: taffy::style::Dimension::from_length(100f32),
44 height: taffy::style::Dimension::from_length(100f32),
45 },
46 ..Default::default()
47 },
48 &[node0, node1],
49 )
50 .unwrap();
51 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
52 println!("\nComputed tree:");
53 taffy.print_tree(node);
54 println!();
55 let layout = taffy.layout(node).unwrap();
56 let Layout { size, location, .. } = layout;
57 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
58 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
59 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
60 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
61 let layout = taffy.layout(node0).unwrap();
62 let Layout { size, location, .. } = layout;
63 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
64 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height);
65 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
66 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
67 let layout = taffy.layout(node1).unwrap();
68 let Layout { size, location, .. } = layout;
69 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width);
70 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height);
71 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x);
72 assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y);
73 let layout = taffy.layout(node10).unwrap();
74 let Layout { size, location, .. } = layout;
75 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width);
76 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height);
77 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x);
78 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y);
79}
80
81#[test]
82#[allow(non_snake_case)]
83fn align_self_baseline__content_box() {
84 #[allow(unused_imports)]
85 use taffy::{prelude::*, Layout};
86 let mut taffy = crate::new_test_tree();
87 let node0 = taffy
88 .new_leaf(taffy::style::Style {
89 box_sizing: taffy::style::BoxSizing::ContentBox,
90 align_self: Some(taffy::style::AlignSelf::Baseline),
91 size: taffy::geometry::Size {
92 width: taffy::style::Dimension::from_length(50f32),
93 height: taffy::style::Dimension::from_length(50f32),
94 },
95 ..Default::default()
96 })
97 .unwrap();
98 let node10 = taffy
99 .new_leaf(taffy::style::Style {
100 box_sizing: taffy::style::BoxSizing::ContentBox,
101 size: taffy::geometry::Size {
102 width: taffy::style::Dimension::from_length(50f32),
103 height: taffy::style::Dimension::from_length(10f32),
104 },
105 ..Default::default()
106 })
107 .unwrap();
108 let node1 = taffy
109 .new_with_children(
110 taffy::style::Style {
111 box_sizing: taffy::style::BoxSizing::ContentBox,
112 align_self: Some(taffy::style::AlignSelf::Baseline),
113 size: taffy::geometry::Size {
114 width: taffy::style::Dimension::from_length(50f32),
115 height: taffy::style::Dimension::from_length(20f32),
116 },
117 ..Default::default()
118 },
119 &[node10],
120 )
121 .unwrap();
122 let node = taffy
123 .new_with_children(
124 taffy::style::Style {
125 box_sizing: taffy::style::BoxSizing::ContentBox,
126 size: taffy::geometry::Size {
127 width: taffy::style::Dimension::from_length(100f32),
128 height: taffy::style::Dimension::from_length(100f32),
129 },
130 ..Default::default()
131 },
132 &[node0, node1],
133 )
134 .unwrap();
135 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
136 println!("\nComputed tree:");
137 taffy.print_tree(node);
138 println!();
139 let layout = taffy.layout(node).unwrap();
140 let Layout { size, location, .. } = layout;
141 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
142 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
143 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
144 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
145 let layout = taffy.layout(node0).unwrap();
146 let Layout { size, location, .. } = layout;
147 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
148 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height);
149 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
150 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
151 let layout = taffy.layout(node1).unwrap();
152 let Layout { size, location, .. } = layout;
153 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width);
154 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height);
155 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x);
156 assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y);
157 let layout = taffy.layout(node10).unwrap();
158 let Layout { size, location, .. } = layout;
159 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width);
160 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height);
161 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x);
162 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y);
163}