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