⎇ 368b7da13d700e20ed1ef0fa2399fade0ca5ea3f
tests/generated/flex/border_flex_child.rs
Historia
Quién tocó qué
crudo
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn border_flex_child__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 flex_grow: 1f32,
10 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() },
11 ..Default::default()
12 })
13 .unwrap();
14 let node = taffy
15 .new_with_children(
16 taffy::style::Style {
17 size: taffy::geometry::Size {
18 width: taffy::style::Dimension::from_length(100f32),
19 height: taffy::style::Dimension::from_length(100f32),
20 },
21 border: taffy::geometry::Rect {
22 left: length(10f32),
23 right: length(10f32),
24 top: length(10f32),
25 bottom: length(10f32),
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, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width);
45 assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, 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 border_flex_child__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 flex_grow: 1f32,
60 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(10f32), height: auto() },
61 ..Default::default()
62 })
63 .unwrap();
64 let node = taffy
65 .new_with_children(
66 taffy::style::Style {
67 box_sizing: taffy::style::BoxSizing::ContentBox,
68 size: taffy::geometry::Size {
69 width: taffy::style::Dimension::from_length(100f32),
70 height: taffy::style::Dimension::from_length(100f32),
71 },
72 border: taffy::geometry::Rect {
73 left: length(10f32),
74 right: length(10f32),
75 top: length(10f32),
76 bottom: length(10f32),
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, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width);
90 assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, 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, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width);
96 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, 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}