⎇ 368b7da13d700e20ed1ef0fa2399fade0ca5ea3f
tests/generated/flex/rounding_fractial_input_5.rs
Historia
Quién tocó qué
crudo
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn rounding_fractial_input_5__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 {
10 width: taffy::style::Dimension::from_length(100.3f32),
11 height: taffy::style::Dimension::from_length(100.3f32),
12 },
13 ..Default::default()
14 })
15 .unwrap();
16 let node1 = taffy
17 .new_leaf(taffy::style::Style {
18 size: taffy::geometry::Size {
19 width: taffy::style::Dimension::from_length(100.3f32),
20 height: taffy::style::Dimension::from_length(100.3f32),
21 },
22 ..Default::default()
23 })
24 .unwrap();
25 let node = taffy
26 .new_with_children(
27 taffy::style::Style {
28 justify_content: Some(taffy::style::JustifyContent::Center),
29 size: taffy::geometry::Size {
30 width: taffy::style::Dimension::from_length(963.333f32),
31 height: taffy::style::Dimension::from_length(100f32),
32 },
33 ..Default::default()
34 },
35 &[node0, node1],
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, 963f32, "width of node {:?}. Expected {}. Actual {}", node, 963f32, 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, 101f32, "width of node {:?}. Expected {}. Actual {}", node0, 101f32, size.width);
51 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height);
52 assert_eq!(location.x, 381f32, "x of node {:?}. Expected {}. Actual {}", node0, 381f32, location.x);
53 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
54 let layout = taffy.layout(node1).unwrap();
55 let Layout { size, location, .. } = layout;
56 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width);
57 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height);
58 assert_eq!(location.x, 482f32, "x of node {:?}. Expected {}. Actual {}", node1, 482f32, location.x);
59 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
60}
61
62#[test]
63#[allow(non_snake_case)]
64fn rounding_fractial_input_5__content_box() {
65 #[allow(unused_imports)]
66 use taffy::{prelude::*, Layout};
67 let mut taffy = crate::new_test_tree();
68 let node0 = taffy
69 .new_leaf(taffy::style::Style {
70 box_sizing: taffy::style::BoxSizing::ContentBox,
71 size: taffy::geometry::Size {
72 width: taffy::style::Dimension::from_length(100.3f32),
73 height: taffy::style::Dimension::from_length(100.3f32),
74 },
75 ..Default::default()
76 })
77 .unwrap();
78 let node1 = taffy
79 .new_leaf(taffy::style::Style {
80 box_sizing: taffy::style::BoxSizing::ContentBox,
81 size: taffy::geometry::Size {
82 width: taffy::style::Dimension::from_length(100.3f32),
83 height: taffy::style::Dimension::from_length(100.3f32),
84 },
85 ..Default::default()
86 })
87 .unwrap();
88 let node = taffy
89 .new_with_children(
90 taffy::style::Style {
91 box_sizing: taffy::style::BoxSizing::ContentBox,
92 justify_content: Some(taffy::style::JustifyContent::Center),
93 size: taffy::geometry::Size {
94 width: taffy::style::Dimension::from_length(963.333f32),
95 height: taffy::style::Dimension::from_length(100f32),
96 },
97 ..Default::default()
98 },
99 &[node0, node1],
100 )
101 .unwrap();
102 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
103 println!("\nComputed tree:");
104 taffy.print_tree(node);
105 println!();
106 let layout = taffy.layout(node).unwrap();
107 let Layout { size, location, .. } = layout;
108 assert_eq!(size.width, 963f32, "width of node {:?}. Expected {}. Actual {}", node, 963f32, size.width);
109 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
110 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
111 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
112 let layout = taffy.layout(node0).unwrap();
113 let Layout { size, location, .. } = layout;
114 assert_eq!(size.width, 101f32, "width of node {:?}. Expected {}. Actual {}", node0, 101f32, size.width);
115 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height);
116 assert_eq!(location.x, 381f32, "x of node {:?}. Expected {}. Actual {}", node0, 381f32, location.x);
117 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
118 let layout = taffy.layout(node1).unwrap();
119 let Layout { size, location, .. } = layout;
120 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width);
121 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height);
122 assert_eq!(location.x, 482f32, "x of node {:?}. Expected {}. Actual {}", node1, 482f32, location.x);
123 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
124}