⎇ f99b57fbad456aa2756b374ff40c876e4b9574c2
tests/generated/flex/flex_basis_smaller_than_main_dimen_row.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn flex_basis_smaller_than_main_dimen_row__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_basis: taffy::style::Dimension::from_length(10f32),
10 size: taffy::geometry::Size {
11 width: taffy::style::Dimension::from_length(50f32),
12 height: taffy::style::Dimension::from_length(50f32),
13 },
14 ..Default::default()
15 })
16 .unwrap();
17 let node = taffy
18 .new_with_children(
19 taffy::style::Style {
20 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() },
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, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, 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, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width);
39 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, 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 flex_basis_smaller_than_main_dimen_row__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_basis: taffy::style::Dimension::from_length(10f32),
54 size: taffy::geometry::Size {
55 width: taffy::style::Dimension::from_length(50f32),
56 height: taffy::style::Dimension::from_length(50f32),
57 },
58 ..Default::default()
59 })
60 .unwrap();
61 let node = taffy
62 .new_with_children(
63 taffy::style::Style {
64 box_sizing: taffy::style::BoxSizing::ContentBox,
65 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() },
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, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, 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, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width);
84 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, 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}