⎇ 368b7da13d700e20ed1ef0fa2399fade0ca5ea3f
tests/generated/flex/overflow_main_axis.rs
Historia
Quién tocó qué
crudo
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn overflow_main_axis__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_shrink: 0f32,
10 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), 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 ..Default::default()
22 },
23 &[node0],
24 )
25 .unwrap();
26 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
27 println!("\nComputed tree:");
28 taffy.print_tree(node);
29 println!();
30 let layout = taffy.layout(node).unwrap();
31 let Layout { size, location, .. } = layout;
32 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
33 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
34 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
35 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
36 let layout = taffy.layout(node0).unwrap();
37 let Layout { size, location, .. } = layout;
38 assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width);
39 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height);
40 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
41 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
42}
43
44#[test]
45#[allow(non_snake_case)]
46fn overflow_main_axis__content_box() {
47 #[allow(unused_imports)]
48 use taffy::{prelude::*, Layout};
49 let mut taffy = crate::new_test_tree();
50 let node0 = taffy
51 .new_leaf(taffy::style::Style {
52 box_sizing: taffy::style::BoxSizing::ContentBox,
53 flex_shrink: 0f32,
54 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() },
55 ..Default::default()
56 })
57 .unwrap();
58 let node = taffy
59 .new_with_children(
60 taffy::style::Style {
61 box_sizing: taffy::style::BoxSizing::ContentBox,
62 size: taffy::geometry::Size {
63 width: taffy::style::Dimension::from_length(100f32),
64 height: taffy::style::Dimension::from_length(100f32),
65 },
66 ..Default::default()
67 },
68 &[node0],
69 )
70 .unwrap();
71 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
72 println!("\nComputed tree:");
73 taffy.print_tree(node);
74 println!();
75 let layout = taffy.layout(node).unwrap();
76 let Layout { size, location, .. } = layout;
77 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
78 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
79 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
80 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
81 let layout = taffy.layout(node0).unwrap();
82 let Layout { size, location, .. } = layout;
83 assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width);
84 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height);
85 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
86 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
87}