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