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