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