⎇ f99b57fbad456aa2756b374ff40c876e4b9574c2
tests/generated/flex/multiline_min_max_5.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 multiline_min_max_5__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 box_sizing: taffy::style::BoxSizing::ContentBox,
10 flex_grow: 1f32,
11 flex_shrink: 1f32,
12 flex_basis: taffy::style::Dimension::from_length(600f32),
13 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) },
14 max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(300f32), height: auto() },
15 ..Default::default()
16 })
17 .unwrap();
18 let node1 = taffy
19 .new_leaf(taffy::style::Style {
20 box_sizing: taffy::style::BoxSizing::ContentBox,
21 flex_grow: 1f32,
22 flex_shrink: 1f32,
23 flex_basis: taffy::style::Dimension::AUTO,
24 size: taffy::geometry::Size {
25 width: taffy::style::Dimension::from_length(100f32),
26 height: taffy::style::Dimension::from_length(10f32),
27 },
28 ..Default::default()
29 })
30 .unwrap();
31 let node2 = taffy
32 .new_leaf(taffy::style::Style {
33 box_sizing: taffy::style::BoxSizing::ContentBox,
34 flex_grow: 1f32,
35 flex_shrink: 1f32,
36 flex_basis: taffy::style::Dimension::AUTO,
37 size: taffy::geometry::Size {
38 width: taffy::style::Dimension::from_length(100f32),
39 height: taffy::style::Dimension::from_length(10f32),
40 },
41 ..Default::default()
42 })
43 .unwrap();
44 let node3 = taffy
45 .new_leaf(taffy::style::Style {
46 box_sizing: taffy::style::BoxSizing::ContentBox,
47 flex_grow: 1f32,
48 flex_shrink: 1f32,
49 flex_basis: taffy::style::Dimension::AUTO,
50 size: taffy::geometry::Size {
51 width: taffy::style::Dimension::from_length(100f32),
52 height: taffy::style::Dimension::from_length(10f32),
53 },
54 ..Default::default()
55 })
56 .unwrap();
57 let node = taffy
58 .new_with_children(
59 taffy::style::Style {
60 display: taffy::style::Display::Flex,
61 box_sizing: taffy::style::BoxSizing::ContentBox,
62 flex_wrap: taffy::style::FlexWrap::Wrap,
63 size: taffy::geometry::Size {
64 width: taffy::style::Dimension::from_length(600f32),
65 height: taffy::style::Dimension::from_length(20f32),
66 },
67 border: taffy::geometry::Rect {
68 left: length(5f32),
69 right: length(5f32),
70 top: length(5f32),
71 bottom: length(5f32),
72 },
73 ..Default::default()
74 },
75 &[node0, node1, node2, node3],
76 )
77 .unwrap();
78 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
79 println!("\nComputed tree:");
80 taffy.print_tree(node);
81 println!();
82 let layout = taffy.layout(node).unwrap();
83 let Layout { size, location, .. } = layout;
84 assert_eq!(size.width, 610f32, "width of node {:?}. Expected {}. Actual {}", node, 610f32, size.width);
85 assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height);
86 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
87 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
88 let layout = taffy.layout(node0).unwrap();
89 let Layout { size, location, .. } = layout;
90 assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node0, 300f32, size.width);
91 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height);
92 assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x);
93 assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y);
94 let layout = taffy.layout(node1).unwrap();
95 let Layout { size, location, .. } = layout;
96 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width);
97 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height);
98 assert_eq!(location.x, 305f32, "x of node {:?}. Expected {}. Actual {}", node1, 305f32, location.x);
99 assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node1, 5f32, location.y);
100 let layout = taffy.layout(node2).unwrap();
101 let Layout { size, location, .. } = layout;
102 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width);
103 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height);
104 assert_eq!(location.x, 405f32, "x of node {:?}. Expected {}. Actual {}", node2, 405f32, location.x);
105 assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node2, 5f32, location.y);
106 let layout = taffy.layout(node3).unwrap();
107 let Layout { size, location, .. } = layout;
108 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node3, 100f32, size.width);
109 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height);
110 assert_eq!(location.x, 505f32, "x of node {:?}. Expected {}. Actual {}", node3, 505f32, location.x);
111 assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node3, 5f32, location.y);
112}
113
114#[test]
115#[allow(non_snake_case)]
116fn multiline_min_max_5__content_box() {
117 #[allow(unused_imports)]
118 use taffy::{prelude::*, Layout};
119 let mut taffy = crate::new_test_tree();
120 let node0 = taffy
121 .new_leaf(taffy::style::Style {
122 box_sizing: taffy::style::BoxSizing::ContentBox,
123 flex_grow: 1f32,
124 flex_shrink: 1f32,
125 flex_basis: taffy::style::Dimension::from_length(600f32),
126 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) },
127 max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(300f32), height: auto() },
128 ..Default::default()
129 })
130 .unwrap();
131 let node1 = taffy
132 .new_leaf(taffy::style::Style {
133 box_sizing: taffy::style::BoxSizing::ContentBox,
134 flex_grow: 1f32,
135 flex_shrink: 1f32,
136 flex_basis: taffy::style::Dimension::AUTO,
137 size: taffy::geometry::Size {
138 width: taffy::style::Dimension::from_length(100f32),
139 height: taffy::style::Dimension::from_length(10f32),
140 },
141 ..Default::default()
142 })
143 .unwrap();
144 let node2 = taffy
145 .new_leaf(taffy::style::Style {
146 box_sizing: taffy::style::BoxSizing::ContentBox,
147 flex_grow: 1f32,
148 flex_shrink: 1f32,
149 flex_basis: taffy::style::Dimension::AUTO,
150 size: taffy::geometry::Size {
151 width: taffy::style::Dimension::from_length(100f32),
152 height: taffy::style::Dimension::from_length(10f32),
153 },
154 ..Default::default()
155 })
156 .unwrap();
157 let node3 = taffy
158 .new_leaf(taffy::style::Style {
159 box_sizing: taffy::style::BoxSizing::ContentBox,
160 flex_grow: 1f32,
161 flex_shrink: 1f32,
162 flex_basis: taffy::style::Dimension::AUTO,
163 size: taffy::geometry::Size {
164 width: taffy::style::Dimension::from_length(100f32),
165 height: taffy::style::Dimension::from_length(10f32),
166 },
167 ..Default::default()
168 })
169 .unwrap();
170 let node = taffy
171 .new_with_children(
172 taffy::style::Style {
173 display: taffy::style::Display::Flex,
174 box_sizing: taffy::style::BoxSizing::ContentBox,
175 flex_wrap: taffy::style::FlexWrap::Wrap,
176 size: taffy::geometry::Size {
177 width: taffy::style::Dimension::from_length(600f32),
178 height: taffy::style::Dimension::from_length(20f32),
179 },
180 border: taffy::geometry::Rect {
181 left: length(5f32),
182 right: length(5f32),
183 top: length(5f32),
184 bottom: length(5f32),
185 },
186 ..Default::default()
187 },
188 &[node0, node1, node2, node3],
189 )
190 .unwrap();
191 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
192 println!("\nComputed tree:");
193 taffy.print_tree(node);
194 println!();
195 let layout = taffy.layout(node).unwrap();
196 let Layout { size, location, .. } = layout;
197 assert_eq!(size.width, 610f32, "width of node {:?}. Expected {}. Actual {}", node, 610f32, size.width);
198 assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height);
199 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
200 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
201 let layout = taffy.layout(node0).unwrap();
202 let Layout { size, location, .. } = layout;
203 assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node0, 300f32, size.width);
204 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height);
205 assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x);
206 assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y);
207 let layout = taffy.layout(node1).unwrap();
208 let Layout { size, location, .. } = layout;
209 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width);
210 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height);
211 assert_eq!(location.x, 305f32, "x of node {:?}. Expected {}. Actual {}", node1, 305f32, location.x);
212 assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node1, 5f32, location.y);
213 let layout = taffy.layout(node2).unwrap();
214 let Layout { size, location, .. } = layout;
215 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width);
216 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height);
217 assert_eq!(location.x, 405f32, "x of node {:?}. Expected {}. Actual {}", node2, 405f32, location.x);
218 assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node2, 5f32, location.y);
219 let layout = taffy.layout(node3).unwrap();
220 let Layout { size, location, .. } = layout;
221 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node3, 100f32, size.width);
222 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height);
223 assert_eq!(location.x, 505f32, "x of node {:?}. Expected {}. Actual {}", node3, 505f32, location.x);
224 assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node3, 5f32, location.y);
225}