⎇ 48e4800f14c6af5cd26275fb570d11b93e279654
tests/generated/flex/min_width.rs
History
Who touched what
raw
Sort test fixtures and generated tests into folders (#514)
1#[test]
2fn min_width() {
3 #[allow(unused_imports)]
4 use taffy::{prelude::*, tree::Layout};
5 let mut taffy = taffy::Taffy::new();
6 let node0 = taffy
7 .new_leaf(taffy::style::Style {
8 flex_grow: 1f32,
9 min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() },
10 ..Default::default()
11 })
12 .unwrap();
13 let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap();
14 let node = taffy
15 .new_with_children(
16 taffy::style::Style {
17 size: taffy::geometry::Size {
18 width: taffy::style::Dimension::Length(100f32),
19 height: taffy::style::Dimension::Length(100f32),
20 },
21 ..Default::default()
22 },
23 &[node0, node1],
24 )
25 .unwrap();
26 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
27 println!("\nComputed tree:");
28 taffy::util::print_tree(&taffy, node);
29 println!();
30 let Layout { size, location, .. } = taffy.layout(node).unwrap();
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 { size, location, .. } = taffy.layout(node0).unwrap();
36 assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width);
37 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, 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 let Layout { size, location, .. } = taffy.layout(node1).unwrap();
41 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width);
42 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height);
43 assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x);
44 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
45}