⎇ 368b7da13d700e20ed1ef0fa2399fade0ca5ea3f
tests/generated/flex/blitz_issue_88.rs
History
Who touched what
raw
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn blitz_issue_88__border_box() {
4 #[allow(unused_imports)]
5 use taffy::{prelude::*, Layout};
6 let mut taffy = crate::new_test_tree();
7 let node000 = taffy
8 .new_leaf_with_context(
9 taffy::style::Style {
10 display: taffy::style::Display::Block,
11 flex_grow: 1f32,
12 flex_basis: taffy::style::Dimension::from_length(0f32),
13 ..Default::default()
14 },
15 crate::TestNodeContext::ahem_text(
16 "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH",
17 crate::WritingMode::Horizontal,
18 ),
19 )
20 .unwrap();
21 let node00 = taffy
22 .new_with_children(
23 taffy::style::Style { display: taffy::style::Display::Flex, flex_grow: 1f32, ..Default::default() },
24 &[node000],
25 )
26 .unwrap();
27 let node0 = taffy
28 .new_with_children(
29 taffy::style::Style {
30 display: taffy::style::Display::Flex,
31 flex_direction: taffy::style::FlexDirection::Column,
32 justify_content: Some(taffy::style::JustifyContent::Start),
33 ..Default::default()
34 },
35 &[node00],
36 )
37 .unwrap();
38 let node = taffy
39 .new_with_children(
40 taffy::style::Style {
41 display: taffy::style::Display::Block,
42 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(600f32), height: auto() },
43 ..Default::default()
44 },
45 &[node0],
46 )
47 .unwrap();
48 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
49 println!("\nComputed tree:");
50 taffy.print_tree(node);
51 println!();
52 let layout = taffy.layout(node).unwrap();
53 let Layout { size, location, .. } = layout;
54 assert_eq!(size.width, 600f32, "width of node {:?}. Expected {}. Actual {}", node, 600f32, size.width);
55 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height);
56 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
57 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
58 let layout = taffy.layout(node0).unwrap();
59 let Layout { size, location, .. } = layout;
60 assert_eq!(size.width, 600f32, "width of node {:?}. Expected {}. Actual {}", node0, 600f32, size.width);
61 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height);
62 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
63 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
64 let layout = taffy.layout(node00).unwrap();
65 let Layout { size, location, .. } = layout;
66 assert_eq!(size.width, 600f32, "width of node {:?}. Expected {}. Actual {}", node00, 600f32, size.width);
67 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height);
68 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x);
69 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y);
70 let layout = taffy.layout(node000).unwrap();
71 let Layout { size, location, .. } = layout;
72 assert_eq!(size.width, 600f32, "width of node {:?}. Expected {}. Actual {}", node000, 600f32, size.width);
73 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height);
74 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x);
75 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y);
76}
77
78#[test]
79#[allow(non_snake_case)]
80fn blitz_issue_88__content_box() {
81 #[allow(unused_imports)]
82 use taffy::{prelude::*, Layout};
83 let mut taffy = crate::new_test_tree();
84 let node000 = taffy
85 .new_leaf_with_context(
86 taffy::style::Style {
87 display: taffy::style::Display::Block,
88 box_sizing: taffy::style::BoxSizing::ContentBox,
89 flex_grow: 1f32,
90 flex_basis: taffy::style::Dimension::from_length(0f32),
91 ..Default::default()
92 },
93 crate::TestNodeContext::ahem_text(
94 "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH",
95 crate::WritingMode::Horizontal,
96 ),
97 )
98 .unwrap();
99 let node00 = taffy
100 .new_with_children(
101 taffy::style::Style {
102 display: taffy::style::Display::Flex,
103 box_sizing: taffy::style::BoxSizing::ContentBox,
104 flex_grow: 1f32,
105 ..Default::default()
106 },
107 &[node000],
108 )
109 .unwrap();
110 let node0 = taffy
111 .new_with_children(
112 taffy::style::Style {
113 display: taffy::style::Display::Flex,
114 box_sizing: taffy::style::BoxSizing::ContentBox,
115 flex_direction: taffy::style::FlexDirection::Column,
116 justify_content: Some(taffy::style::JustifyContent::Start),
117 ..Default::default()
118 },
119 &[node00],
120 )
121 .unwrap();
122 let node = taffy
123 .new_with_children(
124 taffy::style::Style {
125 display: taffy::style::Display::Block,
126 box_sizing: taffy::style::BoxSizing::ContentBox,
127 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(600f32), height: auto() },
128 ..Default::default()
129 },
130 &[node0],
131 )
132 .unwrap();
133 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
134 println!("\nComputed tree:");
135 taffy.print_tree(node);
136 println!();
137 let layout = taffy.layout(node).unwrap();
138 let Layout { size, location, .. } = layout;
139 assert_eq!(size.width, 600f32, "width of node {:?}. Expected {}. Actual {}", node, 600f32, size.width);
140 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height);
141 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
142 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
143 let layout = taffy.layout(node0).unwrap();
144 let Layout { size, location, .. } = layout;
145 assert_eq!(size.width, 600f32, "width of node {:?}. Expected {}. Actual {}", node0, 600f32, size.width);
146 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height);
147 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
148 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
149 let layout = taffy.layout(node00).unwrap();
150 let Layout { size, location, .. } = layout;
151 assert_eq!(size.width, 600f32, "width of node {:?}. Expected {}. Actual {}", node00, 600f32, size.width);
152 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height);
153 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x);
154 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y);
155 let layout = taffy.layout(node000).unwrap();
156 let Layout { size, location, .. } = layout;
157 assert_eq!(size.width, 600f32, "width of node {:?}. Expected {}. Actual {}", node000, 600f32, size.width);
158 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height);
159 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x);
160 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y);
161}