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