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