⎇ 40dd6120fc73aa866f30e52a51d1abaf39adce6f
tests/generated/flex/align_baseline_child_top.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 align_baseline_child_top__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 size: taffy::geometry::Size {
10 width: taffy::style::Dimension::from_length(50f32),
11 height: taffy::style::Dimension::from_length(50f32),
12 },
13 inset: taffy::geometry::Rect { left: auto(), right: auto(), top: length(10f32), bottom: auto() },
14 ..Default::default()
15 })
16 .unwrap();
17 let node10 = taffy
18 .new_leaf(taffy::style::Style {
19 size: taffy::geometry::Size {
20 width: taffy::style::Dimension::from_length(50f32),
21 height: taffy::style::Dimension::from_length(10f32),
22 },
23 ..Default::default()
24 })
25 .unwrap();
26 let node1 = taffy
27 .new_with_children(
28 taffy::style::Style {
29 flex_direction: taffy::style::FlexDirection::Column,
30 size: taffy::geometry::Size {
31 width: taffy::style::Dimension::from_length(50f32),
32 height: taffy::style::Dimension::from_length(20f32),
33 },
34 ..Default::default()
35 },
36 &[node10],
37 )
38 .unwrap();
39 let node = taffy
40 .new_with_children(
41 taffy::style::Style {
42 align_items: Some(taffy::style::AlignItems::Baseline),
43 size: taffy::geometry::Size {
44 width: taffy::style::Dimension::from_length(100f32),
45 height: taffy::style::Dimension::from_length(100f32),
46 },
47 ..Default::default()
48 },
49 &[node0, node1],
50 )
51 .unwrap();
52 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
53 println!("\nComputed tree:");
54 taffy.print_tree(node);
55 println!();
56 let layout = taffy.layout(node).unwrap();
57 let Layout { size, location, .. } = layout;
58 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
59 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
60 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
61 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
62 let layout = taffy.layout(node0).unwrap();
63 let Layout { size, location, .. } = layout;
64 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
65 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height);
66 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
67 assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y);
68 let layout = taffy.layout(node1).unwrap();
69 let Layout { size, location, .. } = layout;
70 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width);
71 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height);
72 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x);
73 assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y);
74 let layout = taffy.layout(node10).unwrap();
75 let Layout { size, location, .. } = layout;
76 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width);
77 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height);
78 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x);
79 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y);
80}
81
82#[test]
83#[allow(non_snake_case)]
84fn align_baseline_child_top__content_box() {
85 #[allow(unused_imports)]
86 use taffy::{prelude::*, Layout};
87 let mut taffy = crate::new_test_tree();
88 let node0 = taffy
89 .new_leaf(taffy::style::Style {
90 box_sizing: taffy::style::BoxSizing::ContentBox,
91 size: taffy::geometry::Size {
92 width: taffy::style::Dimension::from_length(50f32),
93 height: taffy::style::Dimension::from_length(50f32),
94 },
95 inset: taffy::geometry::Rect { left: auto(), right: auto(), top: length(10f32), bottom: auto() },
96 ..Default::default()
97 })
98 .unwrap();
99 let node10 = taffy
100 .new_leaf(taffy::style::Style {
101 box_sizing: taffy::style::BoxSizing::ContentBox,
102 size: taffy::geometry::Size {
103 width: taffy::style::Dimension::from_length(50f32),
104 height: taffy::style::Dimension::from_length(10f32),
105 },
106 ..Default::default()
107 })
108 .unwrap();
109 let node1 = taffy
110 .new_with_children(
111 taffy::style::Style {
112 box_sizing: taffy::style::BoxSizing::ContentBox,
113 flex_direction: taffy::style::FlexDirection::Column,
114 size: taffy::geometry::Size {
115 width: taffy::style::Dimension::from_length(50f32),
116 height: taffy::style::Dimension::from_length(20f32),
117 },
118 ..Default::default()
119 },
120 &[node10],
121 )
122 .unwrap();
123 let node = taffy
124 .new_with_children(
125 taffy::style::Style {
126 box_sizing: taffy::style::BoxSizing::ContentBox,
127 align_items: Some(taffy::style::AlignItems::Baseline),
128 size: taffy::geometry::Size {
129 width: taffy::style::Dimension::from_length(100f32),
130 height: taffy::style::Dimension::from_length(100f32),
131 },
132 ..Default::default()
133 },
134 &[node0, node1],
135 )
136 .unwrap();
137 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
138 println!("\nComputed tree:");
139 taffy.print_tree(node);
140 println!();
141 let layout = taffy.layout(node).unwrap();
142 let Layout { size, location, .. } = layout;
143 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
144 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
145 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
146 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
147 let layout = taffy.layout(node0).unwrap();
148 let Layout { size, location, .. } = layout;
149 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
150 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height);
151 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
152 assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y);
153 let layout = taffy.layout(node1).unwrap();
154 let Layout { size, location, .. } = layout;
155 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width);
156 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height);
157 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x);
158 assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y);
159 let layout = taffy.layout(node10).unwrap();
160 let Layout { size, location, .. } = layout;
161 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width);
162 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height);
163 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x);
164 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y);
165}