⎇ 639f0acdd20f914f847abffbeaa903d66cae4882
tests/rounding.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
Add `taffy_test_helpers` crate (#755)
1use taffy::prelude::*;
2use taffy_test_helpers::new_test_tree;
3
4#[test]
5fn rounding_doesnt_leave_gaps() {
6 // First create an instance of TaffyTree
7 let mut taffy = new_test_tree();
8
9 let w_square = Size { width: length(100.3), height: length(100.3) };
10 let child_a = taffy.new_leaf(Style { size: w_square, ..Default::default() }).unwrap();
11 let child_b = taffy.new_leaf(Style { size: w_square, ..Default::default() }).unwrap();
12
13 let root_node = taffy
14 .new_with_children(
15 Style {
16 size: Size { width: length(963.3333), height: length(1000.) },
17 justify_content: Some(JustifyContent::Center),
18 ..Default::default()
19 },
20 &[child_a, child_b],
21 )
22 .unwrap();
23
24 taffy.compute_layout(root_node, Size::MAX_CONTENT).unwrap();
25 taffy.print_tree(root_node);
26
27 let layout_a = taffy.layout(child_a).unwrap();
28 let layout_b = taffy.layout(child_b).unwrap();
29 assert_eq!(layout_a.location.x + layout_a.size.width, layout_b.location.x);
30}