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