⎇ 368b7da13d700e20ed1ef0fa2399fade0ca5ea3f
tests/generated/flex/flex_column_relative_all_sides.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 flex_column_relative_all_sides__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(40f32), height: auto() },
10 inset: taffy::geometry::Rect {
11 left: length(10f32),
12 right: length(10f32),
13 top: length(10f32),
14 bottom: length(10f32),
15 },
16 ..Default::default()
17 })
18 .unwrap();
19 let node = taffy
20 .new_with_children(
21 taffy::style::Style {
22 flex_direction: taffy::style::FlexDirection::Column,
23 size: taffy::geometry::Size {
24 width: taffy::style::Dimension::from_length(100f32),
25 height: taffy::style::Dimension::from_length(100f32),
26 },
27 ..Default::default()
28 },
29 &[node0],
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, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, 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, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width);
45 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height);
46 assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x);
47 assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y);
48}
49
50#[test]
51#[allow(non_snake_case)]
52fn flex_column_relative_all_sides__content_box() {
53 #[allow(unused_imports)]
54 use taffy::{prelude::*, Layout};
55 let mut taffy = crate::new_test_tree();
56 let node0 = taffy
57 .new_leaf(taffy::style::Style {
58 box_sizing: taffy::style::BoxSizing::ContentBox,
59 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() },
60 inset: taffy::geometry::Rect {
61 left: length(10f32),
62 right: length(10f32),
63 top: length(10f32),
64 bottom: length(10f32),
65 },
66 ..Default::default()
67 })
68 .unwrap();
69 let node = taffy
70 .new_with_children(
71 taffy::style::Style {
72 box_sizing: taffy::style::BoxSizing::ContentBox,
73 flex_direction: taffy::style::FlexDirection::Column,
74 size: taffy::geometry::Size {
75 width: taffy::style::Dimension::from_length(100f32),
76 height: taffy::style::Dimension::from_length(100f32),
77 },
78 ..Default::default()
79 },
80 &[node0],
81 )
82 .unwrap();
83 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
84 println!("\nComputed tree:");
85 taffy.print_tree(node);
86 println!();
87 let layout = taffy.layout(node).unwrap();
88 let Layout { size, location, .. } = layout;
89 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
90 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
91 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
92 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
93 let layout = taffy.layout(node0).unwrap();
94 let Layout { size, location, .. } = layout;
95 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width);
96 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height);
97 assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x);
98 assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y);
99}