tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 707HTML 660Markdown 12TOML 62344 Definitions

⎇ a9acf58cd4179aba3230ea7abd27003dc445c034 tests/generated/rounding_total_fractial.rs Rust · 59 lines · 2.5 KB History Who touched what raw

[gentest] Refactor gentest to use WebDriver & quote crate. a9acf58cd · Adam Perry ·

1#[test]
2fn rounding_total_fractial() {
3    let layout = stretch::compute(
4        &stretch::style::Node {
5            flex_direction: stretch::style::FlexDirection::Column,
6            size: stretch::geometry::Size {
7                width: stretch::style::Dimension::Points(87.4f32),
8                height: stretch::style::Dimension::Points(113.4f32),
9                ..Default::default()
10            },
11            children: vec![
12                stretch::style::Node {
13                    flex_grow: 0.7f32,
14                    flex_basis: stretch::style::Dimension::Points(50.3f32),
15                    size: stretch::geometry::Size {
16                        height: stretch::style::Dimension::Points(20.3f32),
17                        ..Default::default()
18                    },
19                    ..Default::default()
20                },
21                stretch::style::Node {
22                    flex_grow: 1.6f32,
23                    size: stretch::geometry::Size {
24                        height: stretch::style::Dimension::Points(10f32),
25                        ..Default::default()
26                    },
27                    ..Default::default()
28                },
29                stretch::style::Node {
30                    flex_grow: 1.1f32,
31                    size: stretch::geometry::Size {
32                        height: stretch::style::Dimension::Points(10.7f32),
33                        ..Default::default()
34                    },
35                    ..Default::default()
36                },
37            ],
38            ..Default::default()
39        },
40        stretch::geometry::Size::undefined(),
41    )
42    .unwrap();
43    assert_eq!(layout.size.width, 87f32);
44    assert_eq!(layout.size.height, 113f32);
45    assert_eq!(layout.location.x, 0f32);
46    assert_eq!(layout.location.y, 0f32);
47    assert_eq!(layout.children[0usize].size.width, 87f32);
48    assert_eq!(layout.children[0usize].size.height, 59f32);
49    assert_eq!(layout.children[0usize].location.x, 0f32);
50    assert_eq!(layout.children[0usize].location.y, 0f32);
51    assert_eq!(layout.children[1usize].size.width, 87f32);
52    assert_eq!(layout.children[1usize].size.height, 30f32);
53    assert_eq!(layout.children[1usize].location.x, 0f32);
54    assert_eq!(layout.children[1usize].location.y, 59f32);
55    assert_eq!(layout.children[2usize].size.width, 87f32);
56    assert_eq!(layout.children[2usize].size.height, 24f32);
57    assert_eq!(layout.children[2usize].location.x, 0f32);
58    assert_eq!(layout.children[2usize].location.y, 89f32);
59}