⎇ f99b57fbad456aa2756b374ff40c876e4b9574c2
tests/generated/flex/bevy_issue_9530_reduced2.rs
Historia
Quién tocó qué
crudo
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn bevy_issue_9530_reduced2__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_with_context(
9 taffy::style::Style { flex_grow: 1f32, ..Default::default() },
10 crate::TestNodeContext::ahem_text(
11 "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH",
12 crate::WritingMode::Horizontal,
13 ),
14 )
15 .unwrap();
16 let node0 = taffy
17 .new_with_children(
18 taffy::style::Style {
19 flex_direction: taffy::style::FlexDirection::Column,
20 flex_grow: 1f32,
21 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), height: auto() },
22 margin: taffy::geometry::Rect {
23 left: length(20f32),
24 right: length(20f32),
25 top: length(0f32),
26 bottom: length(0f32),
27 },
28 ..Default::default()
29 },
30 &[node00],
31 )
32 .unwrap();
33 let node = taffy
34 .new_with_children(
35 taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() },
36 &[node0],
37 )
38 .unwrap();
39 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
40 println!("\nComputed tree:");
41 taffy.print_tree(node);
42 println!();
43 let layout = taffy.layout(node).unwrap();
44 let Layout { size, location, .. } = layout;
45 assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width);
46 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height);
47 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
48 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
49 let layout = taffy.layout(node0).unwrap();
50 let Layout { size, location, .. } = layout;
51 assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width);
52 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height);
53 assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x);
54 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
55 let layout = taffy.layout(node00).unwrap();
56 let Layout { size, location, .. } = layout;
57 assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node00, 80f32, size.width);
58 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height);
59 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x);
60 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y);
61}
62
63#[test]
64#[allow(non_snake_case)]
65fn bevy_issue_9530_reduced2__content_box() {
66 #[allow(unused_imports)]
67 use taffy::{prelude::*, Layout};
68 let mut taffy = crate::new_test_tree();
69 let node00 = taffy
70 .new_leaf_with_context(
71 taffy::style::Style {
72 box_sizing: taffy::style::BoxSizing::ContentBox,
73 flex_grow: 1f32,
74 ..Default::default()
75 },
76 crate::TestNodeContext::ahem_text(
77 "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH",
78 crate::WritingMode::Horizontal,
79 ),
80 )
81 .unwrap();
82 let node0 = taffy
83 .new_with_children(
84 taffy::style::Style {
85 box_sizing: taffy::style::BoxSizing::ContentBox,
86 flex_direction: taffy::style::FlexDirection::Column,
87 flex_grow: 1f32,
88 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(80f32), height: auto() },
89 margin: taffy::geometry::Rect {
90 left: length(20f32),
91 right: length(20f32),
92 top: length(0f32),
93 bottom: length(0f32),
94 },
95 ..Default::default()
96 },
97 &[node00],
98 )
99 .unwrap();
100 let node = taffy
101 .new_with_children(
102 taffy::style::Style {
103 box_sizing: taffy::style::BoxSizing::ContentBox,
104 flex_direction: taffy::style::FlexDirection::Column,
105 ..Default::default()
106 },
107 &[node0],
108 )
109 .unwrap();
110 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
111 println!("\nComputed tree:");
112 taffy.print_tree(node);
113 println!();
114 let layout = taffy.layout(node).unwrap();
115 let Layout { size, location, .. } = layout;
116 assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width);
117 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height);
118 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
119 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
120 let layout = taffy.layout(node0).unwrap();
121 let Layout { size, location, .. } = layout;
122 assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width);
123 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height);
124 assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x);
125 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
126 let layout = taffy.layout(node00).unwrap();
127 let Layout { size, location, .. } = layout;
128 assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node00, 80f32, size.width);
129 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height);
130 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x);
131 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y);
132}