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