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