tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 707HTML 660Markdown 12TOML 62344 Definiciones

⎇ 368b7da13d700e20ed1ef0fa2399fade0ca5ea3f tests/generated/flex/rounding_fractial_input_6.rs Rust · 244 líneas · 12.8 KB Historia Quién tocó qué crudo

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

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