Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn bevy_issue_7976_reduced__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 ..Default::default()
11 })
12 .unwrap();
13 let node = taffy
14 .new_with_children(
15 taffy::style::Style {
16 align_content: Some(taffy::style::AlignContent::Start),
17 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(200f32) },
18 ..Default::default()
19 },
20 &[node0],
21 )
22 .unwrap();
23 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
24 println!("\nComputed tree:");
25 taffy.print_tree(node);
26 println!();
27 let layout = taffy.layout(node).unwrap();
28 let Layout { size, location, .. } = layout;
29 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width);
30 assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height);
31 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
32 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
33 let layout = taffy.layout(node0).unwrap();
34 let Layout { size, location, .. } = layout;
35 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width);
36 assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node0, 200f32, size.height);
37 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
38 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
39}
40
41#[test]
42#[allow(non_snake_case)]
43fn bevy_issue_7976_reduced__content_box() {
44 #[allow(unused_imports)]
45 use taffy::{prelude::*, Layout};
46 let mut taffy = crate::new_test_tree();
47 let node0 = taffy
48 .new_leaf(taffy::style::Style {
49 box_sizing: taffy::style::BoxSizing::ContentBox,
50 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(40f32), height: auto() },
51 ..Default::default()
52 })
53 .unwrap();
54 let node = taffy
55 .new_with_children(
56 taffy::style::Style {
57 box_sizing: taffy::style::BoxSizing::ContentBox,
58 align_content: Some(taffy::style::AlignContent::Start),
59 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(200f32) },
60 ..Default::default()
61 },
62 &[node0],
63 )
64 .unwrap();
65 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
66 println!("\nComputed tree:");
67 taffy.print_tree(node);
68 println!();
69 let layout = taffy.layout(node).unwrap();
70 let Layout { size, location, .. } = layout;
71 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width);
72 assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height);
73 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
74 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
75 let layout = taffy.layout(node0).unwrap();
76 let Layout { size, location, .. } = layout;
77 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width);
78 assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node0, 200f32, size.height);
79 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
80 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
81}