⎇ f99b57fbad456aa2756b374ff40c876e4b9574c2
tests/generated/flex/flex_grow_in_at_most_container.rs
History
Who touched what
raw
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn flex_grow_in_at_most_container__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 flex_grow: 1f32,
10 flex_basis: taffy::style::Dimension::from_length(0f32),
11 ..Default::default()
12 })
13 .unwrap();
14 let node0 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node00]).unwrap();
15 let node = taffy
16 .new_with_children(
17 taffy::style::Style {
18 align_items: Some(taffy::style::AlignItems::FlexStart),
19 size: taffy::geometry::Size {
20 width: taffy::style::Dimension::from_length(100f32),
21 height: taffy::style::Dimension::from_length(100f32),
22 },
23 ..Default::default()
24 },
25 &[node0],
26 )
27 .unwrap();
28 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
29 println!("\nComputed tree:");
30 taffy.print_tree(node);
31 println!();
32 let layout = taffy.layout(node).unwrap();
33 let Layout { size, location, .. } = layout;
34 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
35 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
36 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
37 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
38 let layout = taffy.layout(node0).unwrap();
39 let Layout { size, location, .. } = layout;
40 assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width);
41 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height);
42 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
43 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
44 let layout = taffy.layout(node00).unwrap();
45 let Layout { size, location, .. } = layout;
46 assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width);
47 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height);
48 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x);
49 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y);
50}
51
52#[test]
53#[allow(non_snake_case)]
54fn flex_grow_in_at_most_container__content_box() {
55 #[allow(unused_imports)]
56 use taffy::{prelude::*, Layout};
57 let mut taffy = crate::new_test_tree();
58 let node00 = taffy
59 .new_leaf(taffy::style::Style {
60 box_sizing: taffy::style::BoxSizing::ContentBox,
61 flex_grow: 1f32,
62 flex_basis: taffy::style::Dimension::from_length(0f32),
63 ..Default::default()
64 })
65 .unwrap();
66 let node0 = taffy
67 .new_with_children(
68 taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() },
69 &[node00],
70 )
71 .unwrap();
72 let node = taffy
73 .new_with_children(
74 taffy::style::Style {
75 box_sizing: taffy::style::BoxSizing::ContentBox,
76 align_items: Some(taffy::style::AlignItems::FlexStart),
77 size: taffy::geometry::Size {
78 width: taffy::style::Dimension::from_length(100f32),
79 height: taffy::style::Dimension::from_length(100f32),
80 },
81 ..Default::default()
82 },
83 &[node0],
84 )
85 .unwrap();
86 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
87 println!("\nComputed tree:");
88 taffy.print_tree(node);
89 println!();
90 let layout = taffy.layout(node).unwrap();
91 let Layout { size, location, .. } = layout;
92 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
93 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
94 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
95 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
96 let layout = taffy.layout(node0).unwrap();
97 let Layout { size, location, .. } = layout;
98 assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width);
99 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height);
100 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
101 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
102 let layout = taffy.layout(node00).unwrap();
103 let Layout { size, location, .. } = layout;
104 assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width);
105 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height);
106 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x);
107 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y);
108}