⎇ float-layout
tests/generated/flex/bevy_issue_9530_reduced4.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 bevy_issue_9530_reduced4__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_with_context(
9 taffy::style::Style {
10 margin: taffy::geometry::Rect {
11 left: length(20f32),
12 right: length(20f32),
13 top: length(20f32),
14 bottom: length(20f32),
15 },
16 ..Default::default()
17 },
18 crate::TestNodeContext::ahem_text(
19 "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH",
20 crate::WritingMode::Horizontal,
21 ),
22 )
23 .unwrap();
24 let node = taffy
25 .new_with_children(
26 taffy::style::Style {
27 flex_direction: taffy::style::FlexDirection::Column,
28 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), height: auto() },
29 ..Default::default()
30 },
31 &[node0],
32 )
33 .unwrap();
34 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
35 println!("\nComputed tree:");
36 taffy.print_tree(node);
37 println!();
38 let layout = taffy.layout(node).unwrap();
39 let Layout { size, location, .. } = layout;
40 assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width);
41 assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height);
42 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
43 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
44 let layout = taffy.layout(node0).unwrap();
45 let Layout { size, location, .. } = layout;
46 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width);
47 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height);
48 assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x);
49 assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y);
50}
51
52#[test]
53#[allow(non_snake_case)]
54fn bevy_issue_9530_reduced4__content_box() {
55 #[allow(unused_imports)]
56 use taffy::{prelude::*, Layout};
57 let mut taffy = crate::new_test_tree();
58 let node0 = taffy
59 .new_leaf_with_context(
60 taffy::style::Style {
61 box_sizing: taffy::style::BoxSizing::ContentBox,
62 margin: taffy::geometry::Rect {
63 left: length(20f32),
64 right: length(20f32),
65 top: length(20f32),
66 bottom: length(20f32),
67 },
68 ..Default::default()
69 },
70 crate::TestNodeContext::ahem_text(
71 "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH",
72 crate::WritingMode::Horizontal,
73 ),
74 )
75 .unwrap();
76 let node = taffy
77 .new_with_children(
78 taffy::style::Style {
79 box_sizing: taffy::style::BoxSizing::ContentBox,
80 flex_direction: taffy::style::FlexDirection::Column,
81 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), height: auto() },
82 ..Default::default()
83 },
84 &[node0],
85 )
86 .unwrap();
87 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
88 println!("\nComputed tree:");
89 taffy.print_tree(node);
90 println!();
91 let layout = taffy.layout(node).unwrap();
92 let Layout { size, location, .. } = layout;
93 assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width);
94 assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height);
95 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
96 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
97 let layout = taffy.layout(node0).unwrap();
98 let Layout { size, location, .. } = layout;
99 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width);
100 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height);
101 assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x);
102 assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y);
103}