⎇ 40dd6120fc73aa866f30e52a51d1abaf39adce6f
tests/generated/flex/min_width_overrides_max_width.rs
Historia
Quién tocó qué
crudo
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn min_width_overrides_max_width__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(100f32), height: auto() },
10 max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() },
11 ..Default::default()
12 })
13 .unwrap();
14 let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap();
15 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
16 println!("\nComputed tree:");
17 taffy.print_tree(node);
18 println!();
19 let layout = taffy.layout(node).unwrap();
20 let Layout { size, location, .. } = layout;
21 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
22 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height);
23 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
24 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
25 let layout = taffy.layout(node0).unwrap();
26 let Layout { size, location, .. } = layout;
27 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width);
28 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height);
29 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
30 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
31}
32
33#[test]
34#[allow(non_snake_case)]
35fn min_width_overrides_max_width__content_box() {
36 #[allow(unused_imports)]
37 use taffy::{prelude::*, Layout};
38 let mut taffy = crate::new_test_tree();
39 let node0 = taffy
40 .new_leaf(taffy::style::Style {
41 box_sizing: taffy::style::BoxSizing::ContentBox,
42 min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() },
43 max_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() },
44 ..Default::default()
45 })
46 .unwrap();
47 let node = taffy
48 .new_with_children(
49 taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() },
50 &[node0],
51 )
52 .unwrap();
53 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
54 println!("\nComputed tree:");
55 taffy.print_tree(node);
56 println!();
57 let layout = taffy.layout(node).unwrap();
58 let Layout { size, location, .. } = layout;
59 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
60 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height);
61 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
62 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
63 let layout = taffy.layout(node0).unwrap();
64 let Layout { size, location, .. } = layout;
65 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width);
66 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height);
67 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
68 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
69}