From d37ebfb19cc6bb1efedc2958723a074d4a94426f Mon Sep 17 00:00:00 2001 From: meloalright Date: Sat, 16 Nov 2024 16:19:22 +0800 Subject: [PATCH] feat(flex): flex reading api should be immutable borrow api --- examples/async.rs | 0 include/safe.h | 8 +- src/lib.rs | 16 +- src/safe.cc | 8 +- src/safe.rs | 8 +- tests/flex_direction_test.rs | 426 ++++----- tests/flex_test.rs | 450 ++++----- tests/flex_wrap_test.rs | 1654 +++++++++++++++++----------------- tests/layout_macro_test.rs | 8 +- 9 files changed, 1289 insertions(+), 1289 deletions(-) create mode 100644 examples/async.rs diff --git a/examples/async.rs b/examples/async.rs new file mode 100644 index 0000000..e69de29 diff --git a/include/safe.h b/include/safe.h index 1170be3..b2aa5fa 100644 --- a/include/safe.h +++ b/include/safe.h @@ -28,8 +28,8 @@ void set_align_content(std::unique_ptr & node, int align_conten void set_justify_content(std::unique_ptr & node, int justify_content); void insert_child(std::unique_ptr & node, std::unique_ptr & child, int index); void do_layout(std::unique_ptr & node, double parent_width, double parent_height, int direction); -double get_width(std::unique_ptr & node); -double get_height(std::unique_ptr & node); -double get_left(std::unique_ptr & node); -double get_top(std::unique_ptr & node); +double get_width(std::unique_ptr const & node); +double get_height(std::unique_ptr const & node); +double get_left(std::unique_ptr const & node); +double get_top(std::unique_ptr const & node); void print(std::unique_ptr const & node); diff --git a/src/lib.rs b/src/lib.rs index 667aa50..cbc5c13 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -139,15 +139,15 @@ pub fn do_layout( direction as i32, ); } -pub fn get_width(node: &mut TaitankSafeNode) -> f64 { - ffi::get_width(&mut node.unique_ptr) +pub fn get_width(node: &TaitankSafeNode) -> f64 { + ffi::get_width(&node.unique_ptr) } -pub fn get_height(node: &mut TaitankSafeNode) -> f64 { - ffi::get_height(&mut node.unique_ptr) +pub fn get_height(node: &TaitankSafeNode) -> f64 { + ffi::get_height(&node.unique_ptr) } -pub fn get_left(node: &mut TaitankSafeNode) -> f64 { - ffi::get_left(&mut node.unique_ptr) +pub fn get_left(node: &TaitankSafeNode) -> f64 { + ffi::get_left(&node.unique_ptr) } -pub fn get_top(node: &mut TaitankSafeNode) -> f64 { - ffi::get_top(&mut node.unique_ptr) +pub fn get_top(node: &TaitankSafeNode) -> f64 { + ffi::get_top(&node.unique_ptr) } diff --git a/src/safe.cc b/src/safe.cc index cb0c980..ff12f5b 100644 --- a/src/safe.cc +++ b/src/safe.cc @@ -295,19 +295,19 @@ void set_justify_content(std::unique_ptr & node, int justify) { } } -double get_width(std::unique_ptr & node) { +double get_width(std::unique_ptr const & node) { return taitank::GetWidth(node->ptr); } -double get_height(std::unique_ptr & node) { +double get_height(std::unique_ptr const & node) { return taitank::GetHeight(node->ptr); } -double get_left(std::unique_ptr & node) { +double get_left(std::unique_ptr const & node) { return taitank::GetLeft(node->ptr); } -double get_top(std::unique_ptr & node) { +double get_top(std::unique_ptr const & node) { return taitank::GetTop(node->ptr); } diff --git a/src/safe.rs b/src/safe.rs index 66d2ed6..2bb39ff 100644 --- a/src/safe.rs +++ b/src/safe.rs @@ -32,10 +32,10 @@ pub mod ffi { parent_height: f64, direction: i32, ); - fn get_width(node: &mut UniquePtr) -> f64; - fn get_height(node: &mut UniquePtr) -> f64; - fn get_left(node: &mut UniquePtr) -> f64; - fn get_top(node: &mut UniquePtr) -> f64; + fn get_width(node: &UniquePtr) -> f64; + fn get_height(node: &UniquePtr) -> f64; + fn get_left(node: &UniquePtr) -> f64; + fn get_top(node: &UniquePtr) -> f64; fn print(node: &UniquePtr); } } diff --git a/tests/flex_direction_test.rs b/tests/flex_direction_test.rs index 54f9590..607c200 100644 --- a/tests/flex_direction_test.rs +++ b/tests/flex_direction_test.rs @@ -22,47 +22,47 @@ mod tests { layout!(&mut root); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(100.0, get_width(&mut root)); - assert_eq!(30.0, get_height(&mut root)); - - assert_eq!(0.0, get_left(&mut root_child0)); - assert_eq!(0.0, get_top(&mut root_child0)); - assert_eq!(100.0, get_width(&mut root_child0)); - assert_eq!(10.0, get_height(&mut root_child0)); - - assert_eq!(0.0, get_left(&mut root_child1)); - assert_eq!(10.0, get_top(&mut root_child1)); - assert_eq!(100.0, get_width(&mut root_child1)); - assert_eq!(10.0, get_height(&mut root_child1)); - - assert_eq!(0.0, get_left(&mut root_child2)); - assert_eq!(20.0, get_top(&mut root_child2)); - assert_eq!(100.0, get_width(&mut root_child2)); - assert_eq!(10.0, get_height(&mut root_child2)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(100.0, get_width(&root)); + assert_eq!(30.0, get_height(&root)); + + assert_eq!(0.0, get_left(&root_child0)); + assert_eq!(0.0, get_top(&root_child0)); + assert_eq!(100.0, get_width(&root_child0)); + assert_eq!(10.0, get_height(&root_child0)); + + assert_eq!(0.0, get_left(&root_child1)); + assert_eq!(10.0, get_top(&root_child1)); + assert_eq!(100.0, get_width(&root_child1)); + assert_eq!(10.0, get_height(&root_child1)); + + assert_eq!(0.0, get_left(&root_child2)); + assert_eq!(20.0, get_top(&root_child2)); + assert_eq!(100.0, get_width(&root_child2)); + assert_eq!(10.0, get_height(&root_child2)); layout!(&mut root, std::f64::NAN, std::f64::NAN, Direction::RTL); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(100.0, get_width(&mut root)); - assert_eq!(30.0, get_height(&mut root)); - - assert_eq!(0.0, get_left(&mut root_child0)); - assert_eq!(0.0, get_top(&mut root_child0)); - assert_eq!(100.0, get_width(&mut root_child0)); - assert_eq!(10.0, get_height(&mut root_child0)); - - assert_eq!(0.0, get_left(&mut root_child1)); - assert_eq!(10.0, get_top(&mut root_child1)); - assert_eq!(100.0, get_width(&mut root_child1)); - assert_eq!(10.0, get_height(&mut root_child1)); - - assert_eq!(0.0, get_left(&mut root_child2)); - assert_eq!(20.0, get_top(&mut root_child2)); - assert_eq!(100.0, get_width(&mut root_child2)); - assert_eq!(10.0, get_height(&mut root_child2)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(100.0, get_width(&root)); + assert_eq!(30.0, get_height(&root)); + + assert_eq!(0.0, get_left(&root_child0)); + assert_eq!(0.0, get_top(&root_child0)); + assert_eq!(100.0, get_width(&root_child0)); + assert_eq!(10.0, get_height(&root_child0)); + + assert_eq!(0.0, get_left(&root_child1)); + assert_eq!(10.0, get_top(&root_child1)); + assert_eq!(100.0, get_width(&root_child1)); + assert_eq!(10.0, get_height(&root_child1)); + + assert_eq!(0.0, get_left(&root_child2)); + assert_eq!(20.0, get_top(&root_child2)); + assert_eq!(100.0, get_width(&root_child2)); + assert_eq!(10.0, get_height(&root_child2)); } #[test] @@ -85,47 +85,47 @@ mod tests { layout!(&mut root); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(30.0, get_width(&mut root)); - assert_eq!(100.0, get_height(&mut root)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(30.0, get_width(&root)); + assert_eq!(100.0, get_height(&root)); - assert_eq!(0.0, get_left(&mut root_child0)); - assert_eq!(0.0, get_top(&mut root_child0)); - assert_eq!(10.0, get_width(&mut root_child0)); - assert_eq!(100.0, get_height(&mut root_child0)); + assert_eq!(0.0, get_left(&root_child0)); + assert_eq!(0.0, get_top(&root_child0)); + assert_eq!(10.0, get_width(&root_child0)); + assert_eq!(100.0, get_height(&root_child0)); - assert_eq!(10.0, get_left(&mut root_child1)); - assert_eq!(0.0, get_top(&mut root_child1)); - assert_eq!(10.0, get_width(&mut root_child1)); - assert_eq!(100.0, get_height(&mut root_child1)); + assert_eq!(10.0, get_left(&root_child1)); + assert_eq!(0.0, get_top(&root_child1)); + assert_eq!(10.0, get_width(&root_child1)); + assert_eq!(100.0, get_height(&root_child1)); - assert_eq!(20.0, get_left(&mut root_child2)); - assert_eq!(0.0, get_top(&mut root_child2)); - assert_eq!(10.0, get_width(&mut root_child2)); - assert_eq!(100.0, get_height(&mut root_child2)); + assert_eq!(20.0, get_left(&root_child2)); + assert_eq!(0.0, get_top(&root_child2)); + assert_eq!(10.0, get_width(&root_child2)); + assert_eq!(100.0, get_height(&root_child2)); layout!(&mut root, std::f64::NAN, std::f64::NAN, Direction::RTL); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(30.0, get_width(&mut root)); - assert_eq!(100.0, get_height(&mut root)); - - assert_eq!(20.0, get_left(&mut root_child0)); - assert_eq!(0.0, get_top(&mut root_child0)); - assert_eq!(10.0, get_width(&mut root_child0)); - assert_eq!(100.0, get_height(&mut root_child0)); - - assert_eq!(10.0, get_left(&mut root_child1)); - assert_eq!(0.0, get_top(&mut root_child1)); - assert_eq!(10.0, get_width(&mut root_child1)); - assert_eq!(100.0, get_height(&mut root_child1)); - - assert_eq!(0.0, get_left(&mut root_child2)); - assert_eq!(0.0, get_top(&mut root_child2)); - assert_eq!(10.0, get_width(&mut root_child2)); - assert_eq!(100.0, get_height(&mut root_child2)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(30.0, get_width(&root)); + assert_eq!(100.0, get_height(&root)); + + assert_eq!(20.0, get_left(&root_child0)); + assert_eq!(0.0, get_top(&root_child0)); + assert_eq!(10.0, get_width(&root_child0)); + assert_eq!(100.0, get_height(&root_child0)); + + assert_eq!(10.0, get_left(&root_child1)); + assert_eq!(0.0, get_top(&root_child1)); + assert_eq!(10.0, get_width(&root_child1)); + assert_eq!(100.0, get_height(&root_child1)); + + assert_eq!(0.0, get_left(&root_child2)); + assert_eq!(0.0, get_top(&root_child2)); + assert_eq!(10.0, get_width(&root_child2)); + assert_eq!(100.0, get_height(&root_child2)); } #[test] @@ -148,47 +148,47 @@ mod tests { layout!(&mut root); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(100.0, get_width(&mut root)); - assert_eq!(100.0, get_height(&mut root)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(100.0, get_width(&root)); + assert_eq!(100.0, get_height(&root)); - assert_eq!(0.0, get_left(&mut root_child0)); - assert_eq!(0.0, get_top(&mut root_child0)); - assert_eq!(100.0, get_width(&mut root_child0)); - assert_eq!(10.0, get_height(&mut root_child0)); + assert_eq!(0.0, get_left(&root_child0)); + assert_eq!(0.0, get_top(&root_child0)); + assert_eq!(100.0, get_width(&root_child0)); + assert_eq!(10.0, get_height(&root_child0)); - assert_eq!(0.0, get_left(&mut root_child1)); - assert_eq!(10.0, get_top(&mut root_child1)); - assert_eq!(100.0, get_width(&mut root_child1)); - assert_eq!(10.0, get_height(&mut root_child1)); + assert_eq!(0.0, get_left(&root_child1)); + assert_eq!(10.0, get_top(&root_child1)); + assert_eq!(100.0, get_width(&root_child1)); + assert_eq!(10.0, get_height(&root_child1)); - assert_eq!(0.0, get_left(&mut root_child2)); - assert_eq!(20.0, get_top(&mut root_child2)); - assert_eq!(100.0, get_width(&mut root_child2)); - assert_eq!(10.0, get_height(&mut root_child2)); + assert_eq!(0.0, get_left(&root_child2)); + assert_eq!(20.0, get_top(&root_child2)); + assert_eq!(100.0, get_width(&root_child2)); + assert_eq!(10.0, get_height(&root_child2)); layout!(&mut root, std::f64::NAN, std::f64::NAN, Direction::RTL); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(100.0, get_width(&mut root)); - assert_eq!(100.0, get_height(&mut root)); - - assert_eq!(0.0, get_left(&mut root_child0)); - assert_eq!(0.0, get_top(&mut root_child0)); - assert_eq!(100.0, get_width(&mut root_child0)); - assert_eq!(10.0, get_height(&mut root_child0)); - - assert_eq!(0.0, get_left(&mut root_child1)); - assert_eq!(10.0, get_top(&mut root_child1)); - assert_eq!(100.0, get_width(&mut root_child1)); - assert_eq!(10.0, get_height(&mut root_child1)); - - assert_eq!(0.0, get_left(&mut root_child2)); - assert_eq!(20.0, get_top(&mut root_child2)); - assert_eq!(100.0, get_width(&mut root_child2)); - assert_eq!(10.0, get_height(&mut root_child2)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(100.0, get_width(&root)); + assert_eq!(100.0, get_height(&root)); + + assert_eq!(0.0, get_left(&root_child0)); + assert_eq!(0.0, get_top(&root_child0)); + assert_eq!(100.0, get_width(&root_child0)); + assert_eq!(10.0, get_height(&root_child0)); + + assert_eq!(0.0, get_left(&root_child1)); + assert_eq!(10.0, get_top(&root_child1)); + assert_eq!(100.0, get_width(&root_child1)); + assert_eq!(10.0, get_height(&root_child1)); + + assert_eq!(0.0, get_left(&root_child2)); + assert_eq!(20.0, get_top(&root_child2)); + assert_eq!(100.0, get_width(&root_child2)); + assert_eq!(10.0, get_height(&root_child2)); } #[test] @@ -212,47 +212,47 @@ mod tests { layout!(&mut root); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(100.0, get_width(&mut root)); - assert_eq!(100.0, get_height(&mut root)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(100.0, get_width(&root)); + assert_eq!(100.0, get_height(&root)); - assert_eq!(0.0, get_left(&mut root_child0)); - assert_eq!(0.0, get_top(&mut root_child0)); - assert_eq!(10.0, get_width(&mut root_child0)); - assert_eq!(100.0, get_height(&mut root_child0)); + assert_eq!(0.0, get_left(&root_child0)); + assert_eq!(0.0, get_top(&root_child0)); + assert_eq!(10.0, get_width(&root_child0)); + assert_eq!(100.0, get_height(&root_child0)); - assert_eq!(10.0, get_left(&mut root_child1)); - assert_eq!(0.0, get_top(&mut root_child1)); - assert_eq!(10.0, get_width(&mut root_child1)); - assert_eq!(100.0, get_height(&mut root_child1)); + assert_eq!(10.0, get_left(&root_child1)); + assert_eq!(0.0, get_top(&root_child1)); + assert_eq!(10.0, get_width(&root_child1)); + assert_eq!(100.0, get_height(&root_child1)); - assert_eq!(20.0, get_left(&mut root_child2)); - assert_eq!(0.0, get_top(&mut root_child2)); - assert_eq!(10.0, get_width(&mut root_child2)); - assert_eq!(100.0, get_height(&mut root_child2)); + assert_eq!(20.0, get_left(&root_child2)); + assert_eq!(0.0, get_top(&root_child2)); + assert_eq!(10.0, get_width(&root_child2)); + assert_eq!(100.0, get_height(&root_child2)); layout!(&mut root, std::f64::NAN, std::f64::NAN, Direction::RTL); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(100.0, get_width(&mut root)); - assert_eq!(100.0, get_height(&mut root)); - - assert_eq!(90.0, get_left(&mut root_child0)); - assert_eq!(0.0, get_top(&mut root_child0)); - assert_eq!(10.0, get_width(&mut root_child0)); - assert_eq!(100.0, get_height(&mut root_child0)); - - assert_eq!(80.0, get_left(&mut root_child1)); - assert_eq!(0.0, get_top(&mut root_child1)); - assert_eq!(10.0, get_width(&mut root_child1)); - assert_eq!(100.0, get_height(&mut root_child1)); - - assert_eq!(70.0, get_left(&mut root_child2)); - assert_eq!(0.0, get_top(&mut root_child2)); - assert_eq!(10.0, get_width(&mut root_child2)); - assert_eq!(100.0, get_height(&mut root_child2)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(100.0, get_width(&root)); + assert_eq!(100.0, get_height(&root)); + + assert_eq!(90.0, get_left(&root_child0)); + assert_eq!(0.0, get_top(&root_child0)); + assert_eq!(10.0, get_width(&root_child0)); + assert_eq!(100.0, get_height(&root_child0)); + + assert_eq!(80.0, get_left(&root_child1)); + assert_eq!(0.0, get_top(&root_child1)); + assert_eq!(10.0, get_width(&root_child1)); + assert_eq!(100.0, get_height(&root_child1)); + + assert_eq!(70.0, get_left(&root_child2)); + assert_eq!(0.0, get_top(&root_child2)); + assert_eq!(10.0, get_width(&root_child2)); + assert_eq!(100.0, get_height(&root_child2)); } #[test] @@ -276,47 +276,47 @@ mod tests { layout!(&mut root); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(100.0, get_width(&mut root)); - assert_eq!(100.0, get_height(&mut root)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(100.0, get_width(&root)); + assert_eq!(100.0, get_height(&root)); - assert_eq!(0.0, get_left(&mut root_child0)); - assert_eq!(90.0, get_top(&mut root_child0)); - assert_eq!(100.0, get_width(&mut root_child0)); - assert_eq!(10.0, get_height(&mut root_child0)); + assert_eq!(0.0, get_left(&root_child0)); + assert_eq!(90.0, get_top(&root_child0)); + assert_eq!(100.0, get_width(&root_child0)); + assert_eq!(10.0, get_height(&root_child0)); - assert_eq!(0.0, get_left(&mut root_child1)); - assert_eq!(80.0, get_top(&mut root_child1)); - assert_eq!(100.0, get_width(&mut root_child1)); - assert_eq!(10.0, get_height(&mut root_child1)); + assert_eq!(0.0, get_left(&root_child1)); + assert_eq!(80.0, get_top(&root_child1)); + assert_eq!(100.0, get_width(&root_child1)); + assert_eq!(10.0, get_height(&root_child1)); - assert_eq!(0.0, get_left(&mut root_child2)); - assert_eq!(70.0, get_top(&mut root_child2)); - assert_eq!(100.0, get_width(&mut root_child2)); - assert_eq!(10.0, get_height(&mut root_child2)); + assert_eq!(0.0, get_left(&root_child2)); + assert_eq!(70.0, get_top(&root_child2)); + assert_eq!(100.0, get_width(&root_child2)); + assert_eq!(10.0, get_height(&root_child2)); layout!(&mut root, std::f64::NAN, std::f64::NAN, Direction::RTL); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(100.0, get_width(&mut root)); - assert_eq!(100.0, get_height(&mut root)); - - assert_eq!(0.0, get_left(&mut root_child0)); - assert_eq!(90.0, get_top(&mut root_child0)); - assert_eq!(100.0, get_width(&mut root_child0)); - assert_eq!(10.0, get_height(&mut root_child0)); - - assert_eq!(0.0, get_left(&mut root_child1)); - assert_eq!(80.0, get_top(&mut root_child1)); - assert_eq!(100.0, get_width(&mut root_child1)); - assert_eq!(10.0, get_height(&mut root_child1)); - - assert_eq!(0.0, get_left(&mut root_child2)); - assert_eq!(70.0, get_top(&mut root_child2)); - assert_eq!(100.0, get_width(&mut root_child2)); - assert_eq!(10.0, get_height(&mut root_child2)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(100.0, get_width(&root)); + assert_eq!(100.0, get_height(&root)); + + assert_eq!(0.0, get_left(&root_child0)); + assert_eq!(90.0, get_top(&root_child0)); + assert_eq!(100.0, get_width(&root_child0)); + assert_eq!(10.0, get_height(&root_child0)); + + assert_eq!(0.0, get_left(&root_child1)); + assert_eq!(80.0, get_top(&root_child1)); + assert_eq!(100.0, get_width(&root_child1)); + assert_eq!(10.0, get_height(&root_child1)); + + assert_eq!(0.0, get_left(&root_child2)); + assert_eq!(70.0, get_top(&root_child2)); + assert_eq!(100.0, get_width(&root_child2)); + assert_eq!(10.0, get_height(&root_child2)); } #[test] fn flex_direction_row_reverse() { @@ -339,46 +339,46 @@ mod tests { layout!(&mut root); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(100.0, get_width(&mut root)); - assert_eq!(100.0, get_height(&mut root)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(100.0, get_width(&root)); + assert_eq!(100.0, get_height(&root)); - assert_eq!(90.0, get_left(&mut root_child0)); - assert_eq!(0.0, get_top(&mut root_child0)); - assert_eq!(10.0, get_width(&mut root_child0)); - assert_eq!(100.0, get_height(&mut root_child0)); + assert_eq!(90.0, get_left(&root_child0)); + assert_eq!(0.0, get_top(&root_child0)); + assert_eq!(10.0, get_width(&root_child0)); + assert_eq!(100.0, get_height(&root_child0)); - assert_eq!(80.0, get_left(&mut root_child1)); - assert_eq!(0.0, get_top(&mut root_child1)); - assert_eq!(10.0, get_width(&mut root_child1)); - assert_eq!(100.0, get_height(&mut root_child1)); + assert_eq!(80.0, get_left(&root_child1)); + assert_eq!(0.0, get_top(&root_child1)); + assert_eq!(10.0, get_width(&root_child1)); + assert_eq!(100.0, get_height(&root_child1)); - assert_eq!(70.0, get_left(&mut root_child2)); - assert_eq!(0.0, get_top(&mut root_child2)); - assert_eq!(10.0, get_width(&mut root_child2)); - assert_eq!(100.0, get_height(&mut root_child2)); + assert_eq!(70.0, get_left(&root_child2)); + assert_eq!(0.0, get_top(&root_child2)); + assert_eq!(10.0, get_width(&root_child2)); + assert_eq!(100.0, get_height(&root_child2)); layout!(&mut root, std::f64::NAN, std::f64::NAN, Direction::RTL); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(100.0, get_width(&mut root)); - assert_eq!(100.0, get_height(&mut root)); - - assert_eq!(0.0, get_left(&mut root_child0)); - assert_eq!(0.0, get_top(&mut root_child0)); - assert_eq!(10.0, get_width(&mut root_child0)); - assert_eq!(100.0, get_height(&mut root_child0)); - - assert_eq!(10.0, get_left(&mut root_child1)); - assert_eq!(0.0, get_top(&mut root_child1)); - assert_eq!(10.0, get_width(&mut root_child1)); - assert_eq!(100.0, get_height(&mut root_child1)); - - assert_eq!(20.0, get_left(&mut root_child2)); - assert_eq!(0.0, get_top(&mut root_child2)); - assert_eq!(10.0, get_width(&mut root_child2)); - assert_eq!(100.0, get_height(&mut root_child2)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(100.0, get_width(&root)); + assert_eq!(100.0, get_height(&root)); + + assert_eq!(0.0, get_left(&root_child0)); + assert_eq!(0.0, get_top(&root_child0)); + assert_eq!(10.0, get_width(&root_child0)); + assert_eq!(100.0, get_height(&root_child0)); + + assert_eq!(10.0, get_left(&root_child1)); + assert_eq!(0.0, get_top(&root_child1)); + assert_eq!(10.0, get_width(&root_child1)); + assert_eq!(100.0, get_height(&root_child1)); + + assert_eq!(20.0, get_left(&root_child2)); + assert_eq!(0.0, get_top(&root_child2)); + assert_eq!(10.0, get_width(&root_child2)); + assert_eq!(100.0, get_height(&root_child2)); } } diff --git a/tests/flex_test.rs b/tests/flex_test.rs index 7e260cd..cbccc80 100644 --- a/tests/flex_test.rs +++ b/tests/flex_test.rs @@ -18,37 +18,37 @@ mod tests { insert_child(&mut root, &mut root_child1, 1); do_layout(&mut root, std::f64::NAN, std::f64::NAN, Direction::LTR); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(100.0, get_width(&mut root)); - assert_eq!(100.0, get_height(&mut root)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(100.0, get_width(&root)); + assert_eq!(100.0, get_height(&root)); - assert_eq!(0.0, get_left(&mut root_child0)); - assert_eq!(0.0, get_top(&mut root_child0)); - assert_eq!(100.0, get_width(&mut root_child0)); - assert_eq!(75.0, get_height(&mut root_child0)); + assert_eq!(0.0, get_left(&root_child0)); + assert_eq!(0.0, get_top(&root_child0)); + assert_eq!(100.0, get_width(&root_child0)); + assert_eq!(75.0, get_height(&root_child0)); - assert_eq!(0.0, get_left(&mut root_child1)); - assert_eq!(75.0, get_top(&mut root_child1)); - assert_eq!(100.0, get_width(&mut root_child1)); - assert_eq!(25.0, get_height(&mut root_child1)); + assert_eq!(0.0, get_left(&root_child1)); + assert_eq!(75.0, get_top(&root_child1)); + assert_eq!(100.0, get_width(&root_child1)); + assert_eq!(25.0, get_height(&root_child1)); layout!(&mut root); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(100.0, get_width(&mut root)); - assert_eq!(100.0, get_height(&mut root)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(100.0, get_width(&root)); + assert_eq!(100.0, get_height(&root)); - assert_eq!(0.0, get_left(&mut root_child0)); - assert_eq!(0.0, get_top(&mut root_child0)); - assert_eq!(100.0, get_width(&mut root_child0)); - assert_eq!(75.0, get_height(&mut root_child0)); + assert_eq!(0.0, get_left(&root_child0)); + assert_eq!(0.0, get_top(&root_child0)); + assert_eq!(100.0, get_width(&root_child0)); + assert_eq!(75.0, get_height(&root_child0)); - assert_eq!(0.0, get_left(&mut root_child1)); - assert_eq!(75.0, get_top(&mut root_child1)); - assert_eq!(100.0, get_width(&mut root_child1)); - assert_eq!(25.0, get_height(&mut root_child1)); + assert_eq!(0.0, get_left(&root_child1)); + assert_eq!(75.0, get_top(&root_child1)); + assert_eq!(100.0, get_width(&root_child1)); + assert_eq!(25.0, get_height(&root_child1)); } #[test] @@ -67,37 +67,37 @@ mod tests { insert_child(&mut root, &mut root_child1, 1); layout!(&mut root); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(100.0, get_width(&mut root)); - assert_eq!(100.0, get_height(&mut root)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(100.0, get_width(&root)); + assert_eq!(100.0, get_height(&root)); - assert_eq!(0.0, get_left(&mut root_child0)); - assert_eq!(0.0, get_top(&mut root_child0)); - assert_eq!(75.0, get_width(&mut root_child0)); - assert_eq!(100.0, get_height(&mut root_child0)); + assert_eq!(0.0, get_left(&root_child0)); + assert_eq!(0.0, get_top(&root_child0)); + assert_eq!(75.0, get_width(&root_child0)); + assert_eq!(100.0, get_height(&root_child0)); - assert_eq!(75.0, get_left(&mut root_child1)); - assert_eq!(0.0, get_top(&mut root_child1)); - assert_eq!(25.0, get_width(&mut root_child1)); - assert_eq!(100.0, get_height(&mut root_child1)); + assert_eq!(75.0, get_left(&root_child1)); + assert_eq!(0.0, get_top(&root_child1)); + assert_eq!(25.0, get_width(&root_child1)); + assert_eq!(100.0, get_height(&root_child1)); do_layout(&mut root, std::f64::NAN, std::f64::NAN, Direction::RTL); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(100.0, get_width(&mut root)); - assert_eq!(100.0, get_height(&mut root)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(100.0, get_width(&root)); + assert_eq!(100.0, get_height(&root)); - assert_eq!(25.0, get_left(&mut root_child0)); - assert_eq!(0.0, get_top(&mut root_child0)); - assert_eq!(75.0, get_width(&mut root_child0)); - assert_eq!(100.0, get_height(&mut root_child0)); + assert_eq!(25.0, get_left(&root_child0)); + assert_eq!(0.0, get_top(&root_child0)); + assert_eq!(75.0, get_width(&root_child0)); + assert_eq!(100.0, get_height(&root_child0)); - assert_eq!(0.0, get_left(&mut root_child1)); - assert_eq!(0.0, get_top(&mut root_child1)); - assert_eq!(25.0, get_width(&mut root_child1)); - assert_eq!(100.0, get_height(&mut root_child1)); + assert_eq!(0.0, get_left(&root_child1)); + assert_eq!(0.0, get_top(&root_child1)); + assert_eq!(25.0, get_width(&root_child1)); + assert_eq!(100.0, get_height(&root_child1)); } #[test] @@ -117,37 +117,37 @@ mod tests { layout!(&mut root); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(100.0, get_width(&mut root)); - assert_eq!(100.0, get_height(&mut root)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(100.0, get_width(&root)); + assert_eq!(100.0, get_height(&root)); - assert_eq!(0.0, get_left(&mut root_child0)); - assert_eq!(0.0, get_top(&mut root_child0)); - assert_eq!(100.0, get_width(&mut root_child0)); - assert_eq!(50.0, get_height(&mut root_child0)); + assert_eq!(0.0, get_left(&root_child0)); + assert_eq!(0.0, get_top(&root_child0)); + assert_eq!(100.0, get_width(&root_child0)); + assert_eq!(50.0, get_height(&root_child0)); - assert_eq!(0.0, get_left(&mut root_child1)); - assert_eq!(50.0, get_top(&mut root_child1)); - assert_eq!(100.0, get_width(&mut root_child1)); - assert_eq!(50.0, get_height(&mut root_child1)); + assert_eq!(0.0, get_left(&root_child1)); + assert_eq!(50.0, get_top(&root_child1)); + assert_eq!(100.0, get_width(&root_child1)); + assert_eq!(50.0, get_height(&root_child1)); do_layout(&mut root, std::f64::NAN, std::f64::NAN, Direction::RTL); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(100.0, get_width(&mut root)); - assert_eq!(100.0, get_height(&mut root)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(100.0, get_width(&root)); + assert_eq!(100.0, get_height(&root)); - assert_eq!(0.0, get_left(&mut root_child0)); - assert_eq!(0.0, get_top(&mut root_child0)); - assert_eq!(100.0, get_width(&mut root_child0)); - assert_eq!(50.0, get_height(&mut root_child0)); + assert_eq!(0.0, get_left(&root_child0)); + assert_eq!(0.0, get_top(&root_child0)); + assert_eq!(100.0, get_width(&root_child0)); + assert_eq!(50.0, get_height(&root_child0)); - assert_eq!(0.0, get_left(&mut root_child1)); - assert_eq!(50.0, get_top(&mut root_child1)); - assert_eq!(100.0, get_width(&mut root_child1)); - assert_eq!(50.0, get_height(&mut root_child1)); + assert_eq!(0.0, get_left(&root_child1)); + assert_eq!(50.0, get_top(&root_child1)); + assert_eq!(100.0, get_width(&root_child1)); + assert_eq!(50.0, get_height(&root_child1)); } #[test] @@ -168,37 +168,37 @@ mod tests { layout!(&mut root); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(100.0, get_width(&mut root)); - assert_eq!(100.0, get_height(&mut root)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(100.0, get_width(&root)); + assert_eq!(100.0, get_height(&root)); - assert_eq!(0.0, get_left(&mut root_child0)); - assert_eq!(0.0, get_top(&mut root_child0)); - assert_eq!(50.0, get_width(&mut root_child0)); - assert_eq!(100.0, get_height(&mut root_child0)); + assert_eq!(0.0, get_left(&root_child0)); + assert_eq!(0.0, get_top(&root_child0)); + assert_eq!(50.0, get_width(&root_child0)); + assert_eq!(100.0, get_height(&root_child0)); - assert_eq!(50.0, get_left(&mut root_child1)); - assert_eq!(0.0, get_top(&mut root_child1)); - assert_eq!(50.0, get_width(&mut root_child1)); - assert_eq!(100.0, get_height(&mut root_child1)); + assert_eq!(50.0, get_left(&root_child1)); + assert_eq!(0.0, get_top(&root_child1)); + assert_eq!(50.0, get_width(&root_child1)); + assert_eq!(100.0, get_height(&root_child1)); do_layout(&mut root, std::f64::NAN, std::f64::NAN, Direction::RTL); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(100.0, get_width(&mut root)); - assert_eq!(100.0, get_height(&mut root)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(100.0, get_width(&root)); + assert_eq!(100.0, get_height(&root)); - assert_eq!(50.0, get_left(&mut root_child0)); - assert_eq!(0.0, get_top(&mut root_child0)); - assert_eq!(50.0, get_width(&mut root_child0)); - assert_eq!(100.0, get_height(&mut root_child0)); + assert_eq!(50.0, get_left(&root_child0)); + assert_eq!(0.0, get_top(&root_child0)); + assert_eq!(50.0, get_width(&root_child0)); + assert_eq!(100.0, get_height(&root_child0)); - assert_eq!(0.0, get_left(&mut root_child1)); - assert_eq!(0.0, get_top(&mut root_child1)); - assert_eq!(50.0, get_width(&mut root_child1)); - assert_eq!(100.0, get_height(&mut root_child1)); + assert_eq!(0.0, get_left(&root_child1)); + assert_eq!(0.0, get_top(&root_child1)); + assert_eq!(50.0, get_width(&root_child1)); + assert_eq!(100.0, get_height(&root_child1)); } #[test] @@ -224,47 +224,47 @@ mod tests { layout!(&mut root); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(50.0, get_width(&mut root)); - assert_eq!(75.0, get_height(&mut root)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(50.0, get_width(&root)); + assert_eq!(75.0, get_height(&root)); - assert_eq!(0.0, get_left(&mut root_child0)); - assert_eq!(0.0, get_top(&mut root_child0)); - assert_eq!(50.0, get_width(&mut root_child0)); - assert_eq!(50.0, get_height(&mut root_child0)); + assert_eq!(0.0, get_left(&root_child0)); + assert_eq!(0.0, get_top(&root_child0)); + assert_eq!(50.0, get_width(&root_child0)); + assert_eq!(50.0, get_height(&root_child0)); - assert_eq!(0.0, get_left(&mut root_child1)); - assert_eq!(50.0, get_top(&mut root_child1)); - assert_eq!(50.0, get_width(&mut root_child1)); - assert_eq!(0.0, get_height(&mut root_child1)); + assert_eq!(0.0, get_left(&root_child1)); + assert_eq!(50.0, get_top(&root_child1)); + assert_eq!(50.0, get_width(&root_child1)); + assert_eq!(0.0, get_height(&root_child1)); - assert_eq!(0.0, get_left(&mut root_child2)); - assert_eq!(50.0, get_top(&mut root_child2)); - assert_eq!(50.0, get_width(&mut root_child2)); - assert_eq!(50.0, get_height(&mut root_child2)); + assert_eq!(0.0, get_left(&root_child2)); + assert_eq!(50.0, get_top(&root_child2)); + assert_eq!(50.0, get_width(&root_child2)); + assert_eq!(50.0, get_height(&root_child2)); do_layout(&mut root, std::f64::NAN, std::f64::NAN, Direction::RTL); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(50.0, get_width(&mut root)); - assert_eq!(75.0, get_height(&mut root)); - - assert_eq!(0.0, get_left(&mut root_child0)); - assert_eq!(0.0, get_top(&mut root_child0)); - assert_eq!(50.0, get_width(&mut root_child0)); - assert_eq!(50.0, get_height(&mut root_child0)); - - assert_eq!(0.0, get_left(&mut root_child1)); - assert_eq!(50.0, get_top(&mut root_child1)); - assert_eq!(50.0, get_width(&mut root_child1)); - assert_eq!(0.0, get_height(&mut root_child1)); - - assert_eq!(0.0, get_left(&mut root_child2)); - assert_eq!(50.0, get_top(&mut root_child2)); - assert_eq!(50.0, get_width(&mut root_child2)); - assert_eq!(50.0, get_height(&mut root_child2)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(50.0, get_width(&root)); + assert_eq!(75.0, get_height(&root)); + + assert_eq!(0.0, get_left(&root_child0)); + assert_eq!(0.0, get_top(&root_child0)); + assert_eq!(50.0, get_width(&root_child0)); + assert_eq!(50.0, get_height(&root_child0)); + + assert_eq!(0.0, get_left(&root_child1)); + assert_eq!(50.0, get_top(&root_child1)); + assert_eq!(50.0, get_width(&root_child1)); + assert_eq!(0.0, get_height(&root_child1)); + + assert_eq!(0.0, get_left(&root_child2)); + assert_eq!(50.0, get_top(&root_child2)); + assert_eq!(50.0, get_width(&root_child2)); + assert_eq!(50.0, get_height(&root_child2)); } #[test] @@ -291,47 +291,47 @@ mod tests { layout!(&mut root); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(100.0, get_width(&mut root)); - assert_eq!(100.0, get_height(&mut root)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(100.0, get_width(&root)); + assert_eq!(100.0, get_height(&root)); - assert_eq!(0.0, get_left(&mut root_child0)); - assert_eq!(0.0, get_top(&mut root_child0)); - assert_eq!(100.0, get_width(&mut root_child0)); - assert_eq!(60.0, get_height(&mut root_child0)); + assert_eq!(0.0, get_left(&root_child0)); + assert_eq!(0.0, get_top(&root_child0)); + assert_eq!(100.0, get_width(&root_child0)); + assert_eq!(60.0, get_height(&root_child0)); - assert_eq!(0.0, get_left(&mut root_child1)); - assert_eq!(60.0, get_top(&mut root_child1)); - assert_eq!(100.0, get_width(&mut root_child1)); - assert_eq!(20.0, get_height(&mut root_child1)); + assert_eq!(0.0, get_left(&root_child1)); + assert_eq!(60.0, get_top(&root_child1)); + assert_eq!(100.0, get_width(&root_child1)); + assert_eq!(20.0, get_height(&root_child1)); - assert_eq!(0.0, get_left(&mut root_child2)); - assert_eq!(80.0, get_top(&mut root_child2)); - assert_eq!(100.0, get_width(&mut root_child2)); - assert_eq!(20.0, get_height(&mut root_child2)); + assert_eq!(0.0, get_left(&root_child2)); + assert_eq!(80.0, get_top(&root_child2)); + assert_eq!(100.0, get_width(&root_child2)); + assert_eq!(20.0, get_height(&root_child2)); do_layout(&mut root, std::f64::NAN, std::f64::NAN, Direction::RTL); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(100.0, get_width(&mut root)); - assert_eq!(100.0, get_height(&mut root)); - - assert_eq!(0.0, get_left(&mut root_child0)); - assert_eq!(0.0, get_top(&mut root_child0)); - assert_eq!(100.0, get_width(&mut root_child0)); - assert_eq!(60.0, get_height(&mut root_child0)); - - assert_eq!(0.0, get_left(&mut root_child1)); - assert_eq!(60.0, get_top(&mut root_child1)); - assert_eq!(100.0, get_width(&mut root_child1)); - assert_eq!(20.0, get_height(&mut root_child1)); - - assert_eq!(0.0, get_left(&mut root_child2)); - assert_eq!(80.0, get_top(&mut root_child2)); - assert_eq!(100.0, get_width(&mut root_child2)); - assert_eq!(20.0, get_height(&mut root_child2)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(100.0, get_width(&root)); + assert_eq!(100.0, get_height(&root)); + + assert_eq!(0.0, get_left(&root_child0)); + assert_eq!(0.0, get_top(&root_child0)); + assert_eq!(100.0, get_width(&root_child0)); + assert_eq!(60.0, get_height(&root_child0)); + + assert_eq!(0.0, get_left(&root_child1)); + assert_eq!(60.0, get_top(&root_child1)); + assert_eq!(100.0, get_width(&root_child1)); + assert_eq!(20.0, get_height(&root_child1)); + + assert_eq!(0.0, get_left(&root_child2)); + assert_eq!(80.0, get_top(&root_child2)); + assert_eq!(100.0, get_width(&root_child2)); + assert_eq!(20.0, get_height(&root_child2)); } #[test] @@ -350,37 +350,37 @@ mod tests { layout!(&mut root); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(100.0, get_width(&mut root)); - assert_eq!(100.0, get_height(&mut root)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(100.0, get_width(&root)); + assert_eq!(100.0, get_height(&root)); - assert_eq!(0.0, get_left(&mut root_child0)); - assert_eq!(0.0, get_top(&mut root_child0)); - assert_eq!(100.0, get_width(&mut root_child0)); - assert_eq!(0.0, get_height(&mut root_child0)); + assert_eq!(0.0, get_left(&root_child0)); + assert_eq!(0.0, get_top(&root_child0)); + assert_eq!(100.0, get_width(&root_child0)); + assert_eq!(0.0, get_height(&root_child0)); - assert_eq!(0.0, get_left(&mut root_child0_child0)); - assert_eq!(0.0, get_top(&mut root_child0_child0)); - assert_eq!(100.0, get_width(&mut root_child0_child0)); - assert_eq!(0.0, get_height(&mut root_child0_child0)); + assert_eq!(0.0, get_left(&root_child0_child0)); + assert_eq!(0.0, get_top(&root_child0_child0)); + assert_eq!(100.0, get_width(&root_child0_child0)); + assert_eq!(0.0, get_height(&root_child0_child0)); do_layout(&mut root, std::f64::NAN, std::f64::NAN, Direction::RTL); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(100.0, get_width(&mut root)); - assert_eq!(100.0, get_height(&mut root)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(100.0, get_width(&root)); + assert_eq!(100.0, get_height(&root)); - assert_eq!(0.0, get_left(&mut root_child0)); - assert_eq!(0.0, get_top(&mut root_child0)); - assert_eq!(100.0, get_width(&mut root_child0)); - assert_eq!(0.0, get_height(&mut root_child0)); + assert_eq!(0.0, get_left(&root_child0)); + assert_eq!(0.0, get_top(&root_child0)); + assert_eq!(100.0, get_width(&root_child0)); + assert_eq!(0.0, get_height(&root_child0)); - assert_eq!(0.0, get_left(&mut root_child0_child0)); - assert_eq!(0.0, get_top(&mut root_child0_child0)); - assert_eq!(100.0, get_width(&mut root_child0_child0)); - assert_eq!(0.0, get_height(&mut root_child0_child0)); + assert_eq!(0.0, get_left(&root_child0_child0)); + assert_eq!(0.0, get_top(&root_child0_child0)); + assert_eq!(100.0, get_width(&root_child0_child0)); + assert_eq!(0.0, get_height(&root_child0_child0)); } #[test] @@ -404,46 +404,46 @@ mod tests { layout!(&mut root); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(200.0, get_width(&mut root)); - assert_eq!(500.0, get_height(&mut root)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(200.0, get_width(&root)); + assert_eq!(500.0, get_height(&root)); - assert_eq!(0.0, get_left(&mut root_child0)); - assert_eq!(0.0, get_top(&mut root_child0)); - assert_eq!(200.0, get_width(&mut root_child0)); - assert_eq!(132.0, get_height(&mut root_child0)); + assert_eq!(0.0, get_left(&root_child0)); + assert_eq!(0.0, get_top(&root_child0)); + assert_eq!(200.0, get_width(&root_child0)); + assert_eq!(132.0, get_height(&root_child0)); - assert_eq!(0.0, get_left(&mut root_child1)); - assert_eq!(132.0, get_top(&mut root_child1)); - assert_eq!(200.0, get_width(&mut root_child1)); - assert_eq!(92.0, get_height(&mut root_child1)); + assert_eq!(0.0, get_left(&root_child1)); + assert_eq!(132.0, get_top(&root_child1)); + assert_eq!(200.0, get_width(&root_child1)); + assert_eq!(92.0, get_height(&root_child1)); - assert_eq!(0.0, get_left(&mut root_child2)); - assert_eq!(224.0, get_top(&mut root_child2)); - assert_eq!(200.0, get_width(&mut root_child2)); - assert_eq!(184.0, get_height(&mut root_child2)); + assert_eq!(0.0, get_left(&root_child2)); + assert_eq!(224.0, get_top(&root_child2)); + assert_eq!(200.0, get_width(&root_child2)); + assert_eq!(184.0, get_height(&root_child2)); do_layout(&mut root, std::f64::NAN, std::f64::NAN, Direction::RTL); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(200.0, get_width(&mut root)); - assert_eq!(500.0, get_height(&mut root)); - - assert_eq!(0.0, get_left(&mut root_child0)); - assert_eq!(0.0, get_top(&mut root_child0)); - assert_eq!(200.0, get_width(&mut root_child0)); - assert_eq!(132.0, get_height(&mut root_child0)); - - assert_eq!(0.0, get_left(&mut root_child1)); - assert_eq!(132.0, get_top(&mut root_child1)); - assert_eq!(200.0, get_width(&mut root_child1)); - assert_eq!(92.0, get_height(&mut root_child1)); - - assert_eq!(0.0, get_left(&mut root_child2)); - assert_eq!(224.0, get_top(&mut root_child2)); - assert_eq!(200.0, get_width(&mut root_child2)); - assert_eq!(184.0, get_height(&mut root_child2)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(200.0, get_width(&root)); + assert_eq!(500.0, get_height(&root)); + + assert_eq!(0.0, get_left(&root_child0)); + assert_eq!(0.0, get_top(&root_child0)); + assert_eq!(200.0, get_width(&root_child0)); + assert_eq!(132.0, get_height(&root_child0)); + + assert_eq!(0.0, get_left(&root_child1)); + assert_eq!(132.0, get_top(&root_child1)); + assert_eq!(200.0, get_width(&root_child1)); + assert_eq!(92.0, get_height(&root_child1)); + + assert_eq!(0.0, get_left(&root_child2)); + assert_eq!(224.0, get_top(&root_child2)); + assert_eq!(200.0, get_width(&root_child2)); + assert_eq!(184.0, get_height(&root_child2)); } } diff --git a/tests/flex_wrap_test.rs b/tests/flex_wrap_test.rs index 9d50cb6..0dd1852 100644 --- a/tests/flex_wrap_test.rs +++ b/tests/flex_wrap_test.rs @@ -31,57 +31,57 @@ mod tests { layout!(&mut root); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(60.0, get_width(&mut root)); - assert_eq!(100.0, get_height(&mut root)); - - assert_eq!(0.0, get_left(&mut root_child0)); - assert_eq!(0.0, get_top(&mut root_child0)); - assert_eq!(30.0, get_width(&mut root_child0)); - assert_eq!(30.0, get_height(&mut root_child0)); - - assert_eq!(0.0, get_left(&mut root_child1)); - assert_eq!(30.0, get_top(&mut root_child1)); - assert_eq!(30.0, get_width(&mut root_child1)); - assert_eq!(30.0, get_height(&mut root_child1)); - - assert_eq!(0.0, get_left(&mut root_child2)); - assert_eq!(60.0, get_top(&mut root_child2)); - assert_eq!(30.0, get_width(&mut root_child2)); - assert_eq!(30.0, get_height(&mut root_child2)); - - assert_eq!(30.0, get_left(&mut root_child3)); - assert_eq!(0.0, get_top(&mut root_child3)); - assert_eq!(30.0, get_width(&mut root_child3)); - assert_eq!(30.0, get_height(&mut root_child3)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(60.0, get_width(&root)); + assert_eq!(100.0, get_height(&root)); + + assert_eq!(0.0, get_left(&root_child0)); + assert_eq!(0.0, get_top(&root_child0)); + assert_eq!(30.0, get_width(&root_child0)); + assert_eq!(30.0, get_height(&root_child0)); + + assert_eq!(0.0, get_left(&root_child1)); + assert_eq!(30.0, get_top(&root_child1)); + assert_eq!(30.0, get_width(&root_child1)); + assert_eq!(30.0, get_height(&root_child1)); + + assert_eq!(0.0, get_left(&root_child2)); + assert_eq!(60.0, get_top(&root_child2)); + assert_eq!(30.0, get_width(&root_child2)); + assert_eq!(30.0, get_height(&root_child2)); + + assert_eq!(30.0, get_left(&root_child3)); + assert_eq!(0.0, get_top(&root_child3)); + assert_eq!(30.0, get_width(&root_child3)); + assert_eq!(30.0, get_height(&root_child3)); layout!(&mut root, std::f64::NAN, std::f64::NAN, Direction::RTL); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(60.0, get_width(&mut root)); - assert_eq!(100.0, get_height(&mut root)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(60.0, get_width(&root)); + assert_eq!(100.0, get_height(&root)); - assert_eq!(30.0, get_left(&mut root_child0)); - assert_eq!(0.0, get_top(&mut root_child0)); - assert_eq!(30.0, get_width(&mut root_child0)); - assert_eq!(30.0, get_height(&mut root_child0)); + assert_eq!(30.0, get_left(&root_child0)); + assert_eq!(0.0, get_top(&root_child0)); + assert_eq!(30.0, get_width(&root_child0)); + assert_eq!(30.0, get_height(&root_child0)); - assert_eq!(30.0, get_left(&mut root_child1)); - assert_eq!(30.0, get_top(&mut root_child1)); - assert_eq!(30.0, get_width(&mut root_child1)); - assert_eq!(30.0, get_height(&mut root_child1)); + assert_eq!(30.0, get_left(&root_child1)); + assert_eq!(30.0, get_top(&root_child1)); + assert_eq!(30.0, get_width(&root_child1)); + assert_eq!(30.0, get_height(&root_child1)); - assert_eq!(30.0, get_left(&mut root_child2)); - assert_eq!(60.0, get_top(&mut root_child2)); - assert_eq!(30.0, get_width(&mut root_child2)); - assert_eq!(30.0, get_height(&mut root_child2)); + assert_eq!(30.0, get_left(&root_child2)); + assert_eq!(60.0, get_top(&root_child2)); + assert_eq!(30.0, get_width(&root_child2)); + assert_eq!(30.0, get_height(&root_child2)); - assert_eq!(0.0, get_left(&mut root_child3)); - assert_eq!(0.0, get_top(&mut root_child3)); - assert_eq!(30.0, get_width(&mut root_child3)); - assert_eq!(30.0, get_height(&mut root_child3)); + assert_eq!(0.0, get_left(&root_child3)); + assert_eq!(0.0, get_top(&root_child3)); + assert_eq!(30.0, get_width(&root_child3)); + assert_eq!(30.0, get_height(&root_child3)); } @@ -114,57 +114,57 @@ mod tests { layout!(&mut root); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(100.0, get_width(&mut root)); - assert_eq!(60.0, get_height(&mut root)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(100.0, get_width(&root)); + assert_eq!(60.0, get_height(&root)); - assert_eq!(0.0, get_left(&mut root_child0)); - assert_eq!(0.0, get_top(&mut root_child0)); - assert_eq!(30.0, get_width(&mut root_child0)); - assert_eq!(30.0, get_height(&mut root_child0)); + assert_eq!(0.0, get_left(&root_child0)); + assert_eq!(0.0, get_top(&root_child0)); + assert_eq!(30.0, get_width(&root_child0)); + assert_eq!(30.0, get_height(&root_child0)); - assert_eq!(30.0, get_left(&mut root_child1)); - assert_eq!(0.0, get_top(&mut root_child1)); - assert_eq!(30.0, get_width(&mut root_child1)); - assert_eq!(30.0, get_height(&mut root_child1)); + assert_eq!(30.0, get_left(&root_child1)); + assert_eq!(0.0, get_top(&root_child1)); + assert_eq!(30.0, get_width(&root_child1)); + assert_eq!(30.0, get_height(&root_child1)); - assert_eq!(60.0, get_left(&mut root_child2)); - assert_eq!(0.0, get_top(&mut root_child2)); - assert_eq!(30.0, get_width(&mut root_child2)); - assert_eq!(30.0, get_height(&mut root_child2)); + assert_eq!(60.0, get_left(&root_child2)); + assert_eq!(0.0, get_top(&root_child2)); + assert_eq!(30.0, get_width(&root_child2)); + assert_eq!(30.0, get_height(&root_child2)); - assert_eq!(0.0, get_left(&mut root_child3)); - assert_eq!(30.0, get_top(&mut root_child3)); - assert_eq!(30.0, get_width(&mut root_child3)); - assert_eq!(30.0, get_height(&mut root_child3)); + assert_eq!(0.0, get_left(&root_child3)); + assert_eq!(30.0, get_top(&root_child3)); + assert_eq!(30.0, get_width(&root_child3)); + assert_eq!(30.0, get_height(&root_child3)); layout!(&mut root, std::f64::NAN, std::f64::NAN, Direction::RTL); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(100.0, get_width(&mut root)); - assert_eq!(60.0, get_height(&mut root)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(100.0, get_width(&root)); + assert_eq!(60.0, get_height(&root)); - assert_eq!(70.0, get_left(&mut root_child0)); - assert_eq!(0.0, get_top(&mut root_child0)); - assert_eq!(30.0, get_width(&mut root_child0)); - assert_eq!(30.0, get_height(&mut root_child0)); + assert_eq!(70.0, get_left(&root_child0)); + assert_eq!(0.0, get_top(&root_child0)); + assert_eq!(30.0, get_width(&root_child0)); + assert_eq!(30.0, get_height(&root_child0)); - assert_eq!(40.0, get_left(&mut root_child1)); - assert_eq!(0.0, get_top(&mut root_child1)); - assert_eq!(30.0, get_width(&mut root_child1)); - assert_eq!(30.0, get_height(&mut root_child1)); + assert_eq!(40.0, get_left(&root_child1)); + assert_eq!(0.0, get_top(&root_child1)); + assert_eq!(30.0, get_width(&root_child1)); + assert_eq!(30.0, get_height(&root_child1)); - assert_eq!(10.0, get_left(&mut root_child2)); - assert_eq!(0.0, get_top(&mut root_child2)); - assert_eq!(30.0, get_width(&mut root_child2)); - assert_eq!(30.0, get_height(&mut root_child2)); + assert_eq!(10.0, get_left(&root_child2)); + assert_eq!(0.0, get_top(&root_child2)); + assert_eq!(30.0, get_width(&root_child2)); + assert_eq!(30.0, get_height(&root_child2)); - assert_eq!(70.0, get_left(&mut root_child3)); - assert_eq!(30.0, get_top(&mut root_child3)); - assert_eq!(30.0, get_width(&mut root_child3)); - assert_eq!(30.0, get_height(&mut root_child3)); + assert_eq!(70.0, get_left(&root_child3)); + assert_eq!(30.0, get_top(&root_child3)); + assert_eq!(30.0, get_width(&root_child3)); + assert_eq!(30.0, get_height(&root_child3)); } @@ -198,57 +198,57 @@ mod tests { layout!(&mut root); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(100.0, get_width(&mut root)); - assert_eq!(60.0, get_height(&mut root)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(100.0, get_width(&root)); + assert_eq!(60.0, get_height(&root)); - assert_eq!(0.0, get_left(&mut root_child0)); - assert_eq!(20.0, get_top(&mut root_child0)); - assert_eq!(30.0, get_width(&mut root_child0)); - assert_eq!(10.0, get_height(&mut root_child0)); + assert_eq!(0.0, get_left(&root_child0)); + assert_eq!(20.0, get_top(&root_child0)); + assert_eq!(30.0, get_width(&root_child0)); + assert_eq!(10.0, get_height(&root_child0)); - assert_eq!(30.0, get_left(&mut root_child1)); - assert_eq!(10.0, get_top(&mut root_child1)); - assert_eq!(30.0, get_width(&mut root_child1)); - assert_eq!(20.0, get_height(&mut root_child1)); + assert_eq!(30.0, get_left(&root_child1)); + assert_eq!(10.0, get_top(&root_child1)); + assert_eq!(30.0, get_width(&root_child1)); + assert_eq!(20.0, get_height(&root_child1)); - assert_eq!(60.0, get_left(&mut root_child2)); - assert_eq!(0.0, get_top(&mut root_child2)); - assert_eq!(30.0, get_width(&mut root_child2)); - assert_eq!(30.0, get_height(&mut root_child2)); + assert_eq!(60.0, get_left(&root_child2)); + assert_eq!(0.0, get_top(&root_child2)); + assert_eq!(30.0, get_width(&root_child2)); + assert_eq!(30.0, get_height(&root_child2)); - assert_eq!(0.0, get_left(&mut root_child3)); - assert_eq!(30.0, get_top(&mut root_child3)); - assert_eq!(30.0, get_width(&mut root_child3)); - assert_eq!(30.0, get_height(&mut root_child3)); + assert_eq!(0.0, get_left(&root_child3)); + assert_eq!(30.0, get_top(&root_child3)); + assert_eq!(30.0, get_width(&root_child3)); + assert_eq!(30.0, get_height(&root_child3)); layout!(&mut root, std::f64::NAN, std::f64::NAN, Direction::RTL); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(100.0, get_width(&mut root)); - assert_eq!(60.0, get_height(&mut root)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(100.0, get_width(&root)); + assert_eq!(60.0, get_height(&root)); - assert_eq!(70.0, get_left(&mut root_child0)); - assert_eq!(20.0, get_top(&mut root_child0)); - assert_eq!(30.0, get_width(&mut root_child0)); - assert_eq!(10.0, get_height(&mut root_child0)); + assert_eq!(70.0, get_left(&root_child0)); + assert_eq!(20.0, get_top(&root_child0)); + assert_eq!(30.0, get_width(&root_child0)); + assert_eq!(10.0, get_height(&root_child0)); - assert_eq!(40.0, get_left(&mut root_child1)); - assert_eq!(10.0, get_top(&mut root_child1)); - assert_eq!(30.0, get_width(&mut root_child1)); - assert_eq!(20.0, get_height(&mut root_child1)); + assert_eq!(40.0, get_left(&root_child1)); + assert_eq!(10.0, get_top(&root_child1)); + assert_eq!(30.0, get_width(&root_child1)); + assert_eq!(20.0, get_height(&root_child1)); - assert_eq!(10.0, get_left(&mut root_child2)); - assert_eq!(0.0, get_top(&mut root_child2)); - assert_eq!(30.0, get_width(&mut root_child2)); - assert_eq!(30.0, get_height(&mut root_child2)); + assert_eq!(10.0, get_left(&root_child2)); + assert_eq!(0.0, get_top(&root_child2)); + assert_eq!(30.0, get_width(&root_child2)); + assert_eq!(30.0, get_height(&root_child2)); - assert_eq!(70.0, get_left(&mut root_child3)); - assert_eq!(30.0, get_top(&mut root_child3)); - assert_eq!(30.0, get_width(&mut root_child3)); - assert_eq!(30.0, get_height(&mut root_child3)); + assert_eq!(70.0, get_left(&root_child3)); + assert_eq!(30.0, get_top(&root_child3)); + assert_eq!(30.0, get_width(&root_child3)); + assert_eq!(30.0, get_height(&root_child3)); } @@ -282,57 +282,57 @@ mod tests { layout!(&mut root); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(100.0, get_width(&mut root)); - assert_eq!(60.0, get_height(&mut root)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(100.0, get_width(&root)); + assert_eq!(60.0, get_height(&root)); - assert_eq!(0.0, get_left(&mut root_child0)); - assert_eq!(10.0, get_top(&mut root_child0)); - assert_eq!(30.0, get_width(&mut root_child0)); - assert_eq!(10.0, get_height(&mut root_child0)); + assert_eq!(0.0, get_left(&root_child0)); + assert_eq!(10.0, get_top(&root_child0)); + assert_eq!(30.0, get_width(&root_child0)); + assert_eq!(10.0, get_height(&root_child0)); - assert_eq!(30.0, get_left(&mut root_child1)); - assert_eq!(5.0, get_top(&mut root_child1)); - assert_eq!(30.0, get_width(&mut root_child1)); - assert_eq!(20.0, get_height(&mut root_child1)); + assert_eq!(30.0, get_left(&root_child1)); + assert_eq!(5.0, get_top(&root_child1)); + assert_eq!(30.0, get_width(&root_child1)); + assert_eq!(20.0, get_height(&root_child1)); - assert_eq!(60.0, get_left(&mut root_child2)); - assert_eq!(0.0, get_top(&mut root_child2)); - assert_eq!(30.0, get_width(&mut root_child2)); - assert_eq!(30.0, get_height(&mut root_child2)); + assert_eq!(60.0, get_left(&root_child2)); + assert_eq!(0.0, get_top(&root_child2)); + assert_eq!(30.0, get_width(&root_child2)); + assert_eq!(30.0, get_height(&root_child2)); - assert_eq!(0.0, get_left(&mut root_child3)); - assert_eq!(30.0, get_top(&mut root_child3)); - assert_eq!(30.0, get_width(&mut root_child3)); - assert_eq!(30.0, get_height(&mut root_child3)); + assert_eq!(0.0, get_left(&root_child3)); + assert_eq!(30.0, get_top(&root_child3)); + assert_eq!(30.0, get_width(&root_child3)); + assert_eq!(30.0, get_height(&root_child3)); layout!(&mut root, std::f64::NAN, std::f64::NAN, Direction::RTL); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(100.0, get_width(&mut root)); - assert_eq!(60.0, get_height(&mut root)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(100.0, get_width(&root)); + assert_eq!(60.0, get_height(&root)); - assert_eq!(70.0, get_left(&mut root_child0)); - assert_eq!(10.0, get_top(&mut root_child0)); - assert_eq!(30.0, get_width(&mut root_child0)); - assert_eq!(10.0, get_height(&mut root_child0)); + assert_eq!(70.0, get_left(&root_child0)); + assert_eq!(10.0, get_top(&root_child0)); + assert_eq!(30.0, get_width(&root_child0)); + assert_eq!(10.0, get_height(&root_child0)); - assert_eq!(40.0, get_left(&mut root_child1)); - assert_eq!(5.0, get_top(&mut root_child1)); - assert_eq!(30.0, get_width(&mut root_child1)); - assert_eq!(20.0, get_height(&mut root_child1)); + assert_eq!(40.0, get_left(&root_child1)); + assert_eq!(5.0, get_top(&root_child1)); + assert_eq!(30.0, get_width(&root_child1)); + assert_eq!(20.0, get_height(&root_child1)); - assert_eq!(10.0, get_left(&mut root_child2)); - assert_eq!(0.0, get_top(&mut root_child2)); - assert_eq!(30.0, get_width(&mut root_child2)); - assert_eq!(30.0, get_height(&mut root_child2)); + assert_eq!(10.0, get_left(&root_child2)); + assert_eq!(0.0, get_top(&root_child2)); + assert_eq!(30.0, get_width(&root_child2)); + assert_eq!(30.0, get_height(&root_child2)); - assert_eq!(70.0, get_left(&mut root_child3)); - assert_eq!(30.0, get_top(&mut root_child3)); - assert_eq!(30.0, get_width(&mut root_child3)); - assert_eq!(30.0, get_height(&mut root_child3)); + assert_eq!(70.0, get_left(&root_child3)); + assert_eq!(30.0, get_top(&root_child3)); + assert_eq!(30.0, get_width(&root_child3)); + assert_eq!(30.0, get_height(&root_child3)); } @@ -357,37 +357,37 @@ mod tests { layout!(&mut root); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(100.0, get_width(&mut root)); - assert_eq!(100.0, get_height(&mut root)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(100.0, get_width(&root)); + assert_eq!(100.0, get_height(&root)); - assert_eq!(0.0, get_left(&mut root_child0)); - assert_eq!(0.0, get_top(&mut root_child0)); - assert_eq!(55.0, get_width(&mut root_child0)); - assert_eq!(50.0, get_height(&mut root_child0)); + assert_eq!(0.0, get_left(&root_child0)); + assert_eq!(0.0, get_top(&root_child0)); + assert_eq!(55.0, get_width(&root_child0)); + assert_eq!(50.0, get_height(&root_child0)); - assert_eq!(0.0, get_left(&mut root_child1)); - assert_eq!(50.0, get_top(&mut root_child1)); - assert_eq!(55.0, get_width(&mut root_child1)); - assert_eq!(50.0, get_height(&mut root_child1)); + assert_eq!(0.0, get_left(&root_child1)); + assert_eq!(50.0, get_top(&root_child1)); + assert_eq!(55.0, get_width(&root_child1)); + assert_eq!(50.0, get_height(&root_child1)); layout!(&mut root, std::f64::NAN, std::f64::NAN, Direction::RTL); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(100.0, get_width(&mut root)); - assert_eq!(100.0, get_height(&mut root)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(100.0, get_width(&root)); + assert_eq!(100.0, get_height(&root)); - assert_eq!(45.0, get_left(&mut root_child0)); - assert_eq!(0.0, get_top(&mut root_child0)); - assert_eq!(55.0, get_width(&mut root_child0)); - assert_eq!(50.0, get_height(&mut root_child0)); + assert_eq!(45.0, get_left(&root_child0)); + assert_eq!(0.0, get_top(&root_child0)); + assert_eq!(55.0, get_width(&root_child0)); + assert_eq!(50.0, get_height(&root_child0)); - assert_eq!(45.0, get_left(&mut root_child1)); - assert_eq!(50.0, get_top(&mut root_child1)); - assert_eq!(55.0, get_width(&mut root_child1)); - assert_eq!(50.0, get_height(&mut root_child1)); + assert_eq!(45.0, get_left(&root_child1)); + assert_eq!(50.0, get_top(&root_child1)); + assert_eq!(55.0, get_width(&root_child1)); + assert_eq!(50.0, get_height(&root_child1)); } @@ -417,57 +417,57 @@ mod tests { layout!(&mut root); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(100.0, get_width(&mut root)); - assert_eq!(200.0, get_height(&mut root)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(100.0, get_width(&root)); + assert_eq!(200.0, get_height(&root)); - assert_eq!(0.0, get_left(&mut root_child0)); - assert_eq!(0.0, get_top(&mut root_child0)); - assert_eq!(100.0, get_width(&mut root_child0)); - assert_eq!(100.0, get_height(&mut root_child0)); + assert_eq!(0.0, get_left(&root_child0)); + assert_eq!(0.0, get_top(&root_child0)); + assert_eq!(100.0, get_width(&root_child0)); + assert_eq!(100.0, get_height(&root_child0)); - assert_eq!(0.0, get_left(&mut root_child0_child0)); - assert_eq!(0.0, get_top(&mut root_child0_child0)); - assert_eq!(100.0, get_width(&mut root_child0_child0)); - assert_eq!(100.0, get_height(&mut root_child0_child0)); + assert_eq!(0.0, get_left(&root_child0_child0)); + assert_eq!(0.0, get_top(&root_child0_child0)); + assert_eq!(100.0, get_width(&root_child0_child0)); + assert_eq!(100.0, get_height(&root_child0_child0)); - assert_eq!(0.0, get_left(&mut root_child0_child0_child0)); - assert_eq!(0.0, get_top(&mut root_child0_child0_child0)); - assert_eq!(100.0, get_width(&mut root_child0_child0_child0)); - assert_eq!(100.0, get_height(&mut root_child0_child0_child0)); + assert_eq!(0.0, get_left(&root_child0_child0_child0)); + assert_eq!(0.0, get_top(&root_child0_child0_child0)); + assert_eq!(100.0, get_width(&root_child0_child0_child0)); + assert_eq!(100.0, get_height(&root_child0_child0_child0)); - assert_eq!(0.0, get_left(&mut root_child1)); - assert_eq!(100.0, get_top(&mut root_child1)); - assert_eq!(100.0, get_width(&mut root_child1)); - assert_eq!(100.0, get_height(&mut root_child1)); + assert_eq!(0.0, get_left(&root_child1)); + assert_eq!(100.0, get_top(&root_child1)); + assert_eq!(100.0, get_width(&root_child1)); + assert_eq!(100.0, get_height(&root_child1)); layout!(&mut root, std::f64::NAN, std::f64::NAN, Direction::RTL); - assert_eq!(0.0, get_left(&mut root)); - assert_eq!(0.0, get_top(&mut root)); - assert_eq!(100.0, get_width(&mut root)); - assert_eq!(200.0, get_height(&mut root)); + assert_eq!(0.0, get_left(&root)); + assert_eq!(0.0, get_top(&root)); + assert_eq!(100.0, get_width(&root)); + assert_eq!(200.0, get_height(&root)); - assert_eq!(0.0, get_left(&mut root_child0)); - assert_eq!(0.0, get_top(&mut root_child0)); - assert_eq!(100.0, get_width(&mut root_child0)); - assert_eq!(100.0, get_height(&mut root_child0)); + assert_eq!(0.0, get_left(&root_child0)); + assert_eq!(0.0, get_top(&root_child0)); + assert_eq!(100.0, get_width(&root_child0)); + assert_eq!(100.0, get_height(&root_child0)); - assert_eq!(0.0, get_left(&mut root_child0_child0)); - assert_eq!(0.0, get_top(&mut root_child0_child0)); - assert_eq!(100.0, get_width(&mut root_child0_child0)); - assert_eq!(100.0, get_height(&mut root_child0_child0)); + assert_eq!(0.0, get_left(&root_child0_child0)); + assert_eq!(0.0, get_top(&root_child0_child0)); + assert_eq!(100.0, get_width(&root_child0_child0)); + assert_eq!(100.0, get_height(&root_child0_child0)); - assert_eq!(0.0, get_left(&mut root_child0_child0_child0)); - assert_eq!(0.0, get_top(&mut root_child0_child0_child0)); - assert_eq!(100.0, get_width(&mut root_child0_child0_child0)); - assert_eq!(100.0, get_height(&mut root_child0_child0_child0)); + assert_eq!(0.0, get_left(&root_child0_child0_child0)); + assert_eq!(0.0, get_top(&root_child0_child0_child0)); + assert_eq!(100.0, get_width(&root_child0_child0_child0)); + assert_eq!(100.0, get_height(&root_child0_child0_child0)); - assert_eq!(0.0, get_left(&mut root_child1)); - assert_eq!(100.0, get_top(&mut root_child1)); - assert_eq!(100.0, get_width(&mut root_child1)); - assert_eq!(100.0, get_height(&mut root_child1)); + assert_eq!(0.0, get_left(&root_child1)); + assert_eq!(100.0, get_top(&root_child1)); + assert_eq!(100.0, get_width(&root_child1)); + assert_eq!(100.0, get_height(&root_child1)); } @@ -489,37 +489,37 @@ mod tests { layout!(&mut root); - assert_eq!(get_left(&mut root), 0.0); - assert_eq!(get_top(&mut root), 0.0); - assert_eq!(get_width(&mut root), 150.0); - assert_eq!(get_height(&mut root), 100.0); + assert_eq!(get_left(&root), 0.0); + assert_eq!(get_top(&root), 0.0); + assert_eq!(get_width(&root), 150.0); + assert_eq!(get_height(&root), 100.0); - assert_eq!(get_left(&mut root_child0), 0.0); - assert_eq!(get_top(&mut root_child0), 0.0); - assert_eq!(get_width(&mut root_child0), 50.0); - assert_eq!(get_height(&mut root_child0), 100.0); + assert_eq!(get_left(&root_child0), 0.0); + assert_eq!(get_top(&root_child0), 0.0); + assert_eq!(get_width(&root_child0), 50.0); + assert_eq!(get_height(&root_child0), 100.0); - assert_eq!(get_left(&mut root_child1), 50.0); - assert_eq!(get_top(&mut root_child1), 0.0); - assert_eq!(get_width(&mut root_child1), 50.0); - assert_eq!(get_height(&mut root_child1), 100.0); + assert_eq!(get_left(&root_child1), 50.0); + assert_eq!(get_top(&root_child1), 0.0); + assert_eq!(get_width(&root_child1), 50.0); + assert_eq!(get_height(&root_child1), 100.0); layout!(&mut root, std::f64::NAN, std::f64::NAN, Direction::RTL); - assert_eq!(get_left(&mut root), 0.0); - assert_eq!(get_top(&mut root), 0.0); - assert_eq!(get_width(&mut root), 150.0); - assert_eq!(get_height(&mut root), 100.0); + assert_eq!(get_left(&root), 0.0); + assert_eq!(get_top(&root), 0.0); + assert_eq!(get_width(&root), 150.0); + assert_eq!(get_height(&root), 100.0); - assert_eq!(get_left(&mut root_child0), 100.0); - assert_eq!(get_top(&mut root_child0), 0.0); - assert_eq!(get_width(&mut root_child0), 50.0); - assert_eq!(get_height(&mut root_child0), 100.0); + assert_eq!(get_left(&root_child0), 100.0); + assert_eq!(get_top(&root_child0), 0.0); + assert_eq!(get_width(&root_child0), 50.0); + assert_eq!(get_height(&root_child0), 100.0); - assert_eq!(get_left(&mut root_child1), 50.0); - assert_eq!(get_top(&mut root_child1), 0.0); - assert_eq!(get_width(&mut root_child1), 50.0); - assert_eq!(get_height(&mut root_child1), 100.0); + assert_eq!(get_left(&root_child1), 50.0); + assert_eq!(get_top(&root_child1), 0.0); + assert_eq!(get_width(&root_child1), 50.0); + assert_eq!(get_height(&root_child1), 100.0); } @@ -557,67 +557,67 @@ mod tests { layout!(&mut root); - assert_eq!(get_left(&mut root), 0.0); - assert_eq!(get_top(&mut root), 0.0); - assert_eq!(get_width(&mut root), 100.0); - assert_eq!(get_height(&mut root), 80.0); + assert_eq!(get_left(&root), 0.0); + assert_eq!(get_top(&root), 0.0); + assert_eq!(get_width(&root), 100.0); + assert_eq!(get_height(&root), 80.0); - assert_eq!(get_left(&mut root_child0), 0.0); - assert_eq!(get_top(&mut root_child0), 70.0); - assert_eq!(get_width(&mut root_child0), 30.0); - assert_eq!(get_height(&mut root_child0), 10.0); + assert_eq!(get_left(&root_child0), 0.0); + assert_eq!(get_top(&root_child0), 70.0); + assert_eq!(get_width(&root_child0), 30.0); + assert_eq!(get_height(&root_child0), 10.0); - assert_eq!(get_left(&mut root_child1), 30.0); - assert_eq!(get_top(&mut root_child1), 60.0); - assert_eq!(get_width(&mut root_child1), 30.0); - assert_eq!(get_height(&mut root_child1), 20.0); + assert_eq!(get_left(&root_child1), 30.0); + assert_eq!(get_top(&root_child1), 60.0); + assert_eq!(get_width(&root_child1), 30.0); + assert_eq!(get_height(&root_child1), 20.0); - assert_eq!(get_left(&mut root_child2), 60.0); - assert_eq!(get_top(&mut root_child2), 50.0); - assert_eq!(get_width(&mut root_child2), 30.0); - assert_eq!(get_height(&mut root_child2), 30.0); + assert_eq!(get_left(&root_child2), 60.0); + assert_eq!(get_top(&root_child2), 50.0); + assert_eq!(get_width(&root_child2), 30.0); + assert_eq!(get_height(&root_child2), 30.0); - assert_eq!(get_left(&mut root_child3), 0.0); - assert_eq!(get_top(&mut root_child3), 10.0); - assert_eq!(get_width(&mut root_child3), 30.0); - assert_eq!(get_height(&mut root_child3), 40.0); + assert_eq!(get_left(&root_child3), 0.0); + assert_eq!(get_top(&root_child3), 10.0); + assert_eq!(get_width(&root_child3), 30.0); + assert_eq!(get_height(&root_child3), 40.0); - assert_eq!(get_left(&mut root_child4), 30.0); - assert_eq!(get_top(&mut root_child4), 0.0); - assert_eq!(get_width(&mut root_child4), 30.0); - assert_eq!(get_height(&mut root_child4), 50.0); + assert_eq!(get_left(&root_child4), 30.0); + assert_eq!(get_top(&root_child4), 0.0); + assert_eq!(get_width(&root_child4), 30.0); + assert_eq!(get_height(&root_child4), 50.0); layout!(&mut root, std::f64::NAN, std::f64::NAN, Direction::RTL); - assert_eq!(get_left(&mut root), 0.0); - assert_eq!(get_top(&mut root), 0.0); - assert_eq!(get_width(&mut root), 100.0); - assert_eq!(get_height(&mut root), 80.0); - - assert_eq!(get_left(&mut root_child0), 70.0); - assert_eq!(get_top(&mut root_child0), 70.0); - assert_eq!(get_width(&mut root_child0), 30.0); - assert_eq!(get_height(&mut root_child0), 10.0); - - assert_eq!(get_left(&mut root_child1), 40.0); - assert_eq!(get_top(&mut root_child1), 60.0); - assert_eq!(get_width(&mut root_child1), 30.0); - assert_eq!(get_height(&mut root_child1), 20.0); - - assert_eq!(get_left(&mut root_child2), 10.0); - assert_eq!(get_top(&mut root_child2), 50.0); - assert_eq!(get_width(&mut root_child2), 30.0); - assert_eq!(get_height(&mut root_child2), 30.0); - - assert_eq!(get_left(&mut root_child3), 70.0); - assert_eq!(get_top(&mut root_child3), 10.0); - assert_eq!(get_width(&mut root_child3), 30.0); - assert_eq!(get_height(&mut root_child3), 40.0); - - assert_eq!(get_left(&mut root_child4), 40.0); - assert_eq!(get_top(&mut root_child4), 0.0); - assert_eq!(get_width(&mut root_child4), 30.0); - assert_eq!(get_height(&mut root_child4), 50.0); + assert_eq!(get_left(&root), 0.0); + assert_eq!(get_top(&root), 0.0); + assert_eq!(get_width(&root), 100.0); + assert_eq!(get_height(&root), 80.0); + + assert_eq!(get_left(&root_child0), 70.0); + assert_eq!(get_top(&root_child0), 70.0); + assert_eq!(get_width(&root_child0), 30.0); + assert_eq!(get_height(&root_child0), 10.0); + + assert_eq!(get_left(&root_child1), 40.0); + assert_eq!(get_top(&root_child1), 60.0); + assert_eq!(get_width(&root_child1), 30.0); + assert_eq!(get_height(&root_child1), 20.0); + + assert_eq!(get_left(&root_child2), 10.0); + assert_eq!(get_top(&root_child2), 50.0); + assert_eq!(get_width(&root_child2), 30.0); + assert_eq!(get_height(&root_child2), 30.0); + + assert_eq!(get_left(&root_child3), 70.0); + assert_eq!(get_top(&root_child3), 10.0); + assert_eq!(get_width(&root_child3), 30.0); + assert_eq!(get_height(&root_child3), 40.0); + + assert_eq!(get_left(&root_child4), 40.0); + assert_eq!(get_top(&root_child4), 0.0); + assert_eq!(get_width(&root_child4), 30.0); + assert_eq!(get_height(&root_child4), 50.0); } #[test] @@ -655,67 +655,67 @@ mod tests { layout!(&mut root); - assert_eq!(get_left(&mut root), 0.0); - assert_eq!(get_top(&mut root), 0.0); - assert_eq!(get_width(&mut root), 100.0); - assert_eq!(get_height(&mut root), 80.0); + assert_eq!(get_left(&root), 0.0); + assert_eq!(get_top(&root), 0.0); + assert_eq!(get_width(&root), 100.0); + assert_eq!(get_height(&root), 80.0); - assert_eq!(get_left(&mut root_child0), 0.0); - assert_eq!(get_top(&mut root_child0), 70.0); - assert_eq!(get_width(&mut root_child0), 30.0); - assert_eq!(get_height(&mut root_child0), 10.0); + assert_eq!(get_left(&root_child0), 0.0); + assert_eq!(get_top(&root_child0), 70.0); + assert_eq!(get_width(&root_child0), 30.0); + assert_eq!(get_height(&root_child0), 10.0); - assert_eq!(get_left(&mut root_child1), 30.0); - assert_eq!(get_top(&mut root_child1), 60.0); - assert_eq!(get_width(&mut root_child1), 30.0); - assert_eq!(get_height(&mut root_child1), 20.0); + assert_eq!(get_left(&root_child1), 30.0); + assert_eq!(get_top(&root_child1), 60.0); + assert_eq!(get_width(&root_child1), 30.0); + assert_eq!(get_height(&root_child1), 20.0); - assert_eq!(get_left(&mut root_child2), 60.0); - assert_eq!(get_top(&mut root_child2), 50.0); - assert_eq!(get_width(&mut root_child2), 30.0); - assert_eq!(get_height(&mut root_child2), 30.0); + assert_eq!(get_left(&root_child2), 60.0); + assert_eq!(get_top(&root_child2), 50.0); + assert_eq!(get_width(&root_child2), 30.0); + assert_eq!(get_height(&root_child2), 30.0); - assert_eq!(get_left(&mut root_child3), 0.0); - assert_eq!(get_top(&mut root_child3), 10.0); - assert_eq!(get_width(&mut root_child3), 30.0); - assert_eq!(get_height(&mut root_child3), 40.0); + assert_eq!(get_left(&root_child3), 0.0); + assert_eq!(get_top(&root_child3), 10.0); + assert_eq!(get_width(&root_child3), 30.0); + assert_eq!(get_height(&root_child3), 40.0); - assert_eq!(get_left(&mut root_child4), 30.0); - assert_eq!(get_top(&mut root_child4), 0.0); - assert_eq!(get_width(&mut root_child4), 30.0); - assert_eq!(get_height(&mut root_child4), 50.0); + assert_eq!(get_left(&root_child4), 30.0); + assert_eq!(get_top(&root_child4), 0.0); + assert_eq!(get_width(&root_child4), 30.0); + assert_eq!(get_height(&root_child4), 50.0); layout!(&mut root, std::f64::NAN, std::f64::NAN, Direction::RTL); - assert_eq!(get_left(&mut root), 0.0); - assert_eq!(get_top(&mut root), 0.0); - assert_eq!(get_width(&mut root), 100.0); - assert_eq!(get_height(&mut root), 80.0); - - assert_eq!(get_left(&mut root_child0), 70.0); - assert_eq!(get_top(&mut root_child0), 70.0); - assert_eq!(get_width(&mut root_child0), 30.0); - assert_eq!(get_height(&mut root_child0), 10.0); - - assert_eq!(get_left(&mut root_child1), 40.0); - assert_eq!(get_top(&mut root_child1), 60.0); - assert_eq!(get_width(&mut root_child1), 30.0); - assert_eq!(get_height(&mut root_child1), 20.0); - - assert_eq!(get_left(&mut root_child2), 10.0); - assert_eq!(get_top(&mut root_child2), 50.0); - assert_eq!(get_width(&mut root_child2), 30.0); - assert_eq!(get_height(&mut root_child2), 30.0); - - assert_eq!(get_left(&mut root_child3), 70.0); - assert_eq!(get_top(&mut root_child3), 10.0); - assert_eq!(get_width(&mut root_child3), 30.0); - assert_eq!(get_height(&mut root_child3), 40.0); - - assert_eq!(get_left(&mut root_child4), 40.0); - assert_eq!(get_top(&mut root_child4), 0.0); - assert_eq!(get_width(&mut root_child4), 30.0); - assert_eq!(get_height(&mut root_child4), 50.0); + assert_eq!(get_left(&root), 0.0); + assert_eq!(get_top(&root), 0.0); + assert_eq!(get_width(&root), 100.0); + assert_eq!(get_height(&root), 80.0); + + assert_eq!(get_left(&root_child0), 70.0); + assert_eq!(get_top(&root_child0), 70.0); + assert_eq!(get_width(&root_child0), 30.0); + assert_eq!(get_height(&root_child0), 10.0); + + assert_eq!(get_left(&root_child1), 40.0); + assert_eq!(get_top(&root_child1), 60.0); + assert_eq!(get_width(&root_child1), 30.0); + assert_eq!(get_height(&root_child1), 20.0); + + assert_eq!(get_left(&root_child2), 10.0); + assert_eq!(get_top(&root_child2), 50.0); + assert_eq!(get_width(&root_child2), 30.0); + assert_eq!(get_height(&root_child2), 30.0); + + assert_eq!(get_left(&root_child3), 70.0); + assert_eq!(get_top(&root_child3), 10.0); + assert_eq!(get_width(&root_child3), 30.0); + assert_eq!(get_height(&root_child3), 40.0); + + assert_eq!(get_left(&root_child4), 40.0); + assert_eq!(get_top(&root_child4), 0.0); + assert_eq!(get_width(&root_child4), 30.0); + assert_eq!(get_height(&root_child4), 50.0); } #[test] @@ -752,67 +752,67 @@ mod tests { layout!(&mut root); - assert_eq!(get_left(&mut root), 0.0); - assert_eq!(get_top(&mut root), 0.0); - assert_eq!(get_width(&mut root), 300.0); - assert_eq!(get_height(&mut root), 50.0); + assert_eq!(get_left(&root), 0.0); + assert_eq!(get_top(&root), 0.0); + assert_eq!(get_width(&root), 300.0); + assert_eq!(get_height(&root), 50.0); - assert_eq!(get_left(&mut root_child0), 0.0); - assert_eq!(get_top(&mut root_child0), 40.0); - assert_eq!(get_width(&mut root_child0), 30.0); - assert_eq!(get_height(&mut root_child0), 10.0); + assert_eq!(get_left(&root_child0), 0.0); + assert_eq!(get_top(&root_child0), 40.0); + assert_eq!(get_width(&root_child0), 30.0); + assert_eq!(get_height(&root_child0), 10.0); - assert_eq!(get_left(&mut root_child1), 30.0); - assert_eq!(get_top(&mut root_child1), 30.0); - assert_eq!(get_width(&mut root_child1), 30.0); - assert_eq!(get_height(&mut root_child1), 20.0); + assert_eq!(get_left(&root_child1), 30.0); + assert_eq!(get_top(&root_child1), 30.0); + assert_eq!(get_width(&root_child1), 30.0); + assert_eq!(get_height(&root_child1), 20.0); - assert_eq!(get_left(&mut root_child2), 60.0); - assert_eq!(get_top(&mut root_child2), 20.0); - assert_eq!(get_width(&mut root_child2), 30.0); - assert_eq!(get_height(&mut root_child2), 30.0); + assert_eq!(get_left(&root_child2), 60.0); + assert_eq!(get_top(&root_child2), 20.0); + assert_eq!(get_width(&root_child2), 30.0); + assert_eq!(get_height(&root_child2), 30.0); - assert_eq!(get_left(&mut root_child3), 90.0); - assert_eq!(get_top(&mut root_child3), 10.0); - assert_eq!(get_width(&mut root_child3), 30.0); - assert_eq!(get_height(&mut root_child3), 40.0); + assert_eq!(get_left(&root_child3), 90.0); + assert_eq!(get_top(&root_child3), 10.0); + assert_eq!(get_width(&root_child3), 30.0); + assert_eq!(get_height(&root_child3), 40.0); - assert_eq!(get_left(&mut root_child4), 120.0); - assert_eq!(get_top(&mut root_child4), 0.0); - assert_eq!(get_width(&mut root_child4), 30.0); - assert_eq!(get_height(&mut root_child4), 50.0); + assert_eq!(get_left(&root_child4), 120.0); + assert_eq!(get_top(&root_child4), 0.0); + assert_eq!(get_width(&root_child4), 30.0); + assert_eq!(get_height(&root_child4), 50.0); layout!(&mut root, std::f64::NAN, std::f64::NAN, Direction::RTL); - assert_eq!(get_left(&mut root), 0.0); - assert_eq!(get_top(&mut root), 0.0); - assert_eq!(get_width(&mut root), 300.0); - assert_eq!(get_height(&mut root), 50.0); - - assert_eq!(get_left(&mut root_child0), 270.0); - assert_eq!(get_top(&mut root_child0), 40.0); - assert_eq!(get_width(&mut root_child0), 30.0); - assert_eq!(get_height(&mut root_child0), 10.0); - - assert_eq!(get_left(&mut root_child1), 240.0); - assert_eq!(get_top(&mut root_child1), 30.0); - assert_eq!(get_width(&mut root_child1), 30.0); - assert_eq!(get_height(&mut root_child1), 20.0); - - assert_eq!(get_left(&mut root_child2), 210.0); - assert_eq!(get_top(&mut root_child2), 20.0); - assert_eq!(get_width(&mut root_child2), 30.0); - assert_eq!(get_height(&mut root_child2), 30.0); - - assert_eq!(get_left(&mut root_child3), 180.0); - assert_eq!(get_top(&mut root_child3), 10.0); - assert_eq!(get_width(&mut root_child3), 30.0); - assert_eq!(get_height(&mut root_child3), 40.0); - - assert_eq!(get_left(&mut root_child4), 150.0); - assert_eq!(get_top(&mut root_child4), 0.0); - assert_eq!(get_width(&mut root_child4), 30.0); - assert_eq!(get_height(&mut root_child4), 50.0); + assert_eq!(get_left(&root), 0.0); + assert_eq!(get_top(&root), 0.0); + assert_eq!(get_width(&root), 300.0); + assert_eq!(get_height(&root), 50.0); + + assert_eq!(get_left(&root_child0), 270.0); + assert_eq!(get_top(&root_child0), 40.0); + assert_eq!(get_width(&root_child0), 30.0); + assert_eq!(get_height(&root_child0), 10.0); + + assert_eq!(get_left(&root_child1), 240.0); + assert_eq!(get_top(&root_child1), 30.0); + assert_eq!(get_width(&root_child1), 30.0); + assert_eq!(get_height(&root_child1), 20.0); + + assert_eq!(get_left(&root_child2), 210.0); + assert_eq!(get_top(&root_child2), 20.0); + assert_eq!(get_width(&root_child2), 30.0); + assert_eq!(get_height(&root_child2), 30.0); + + assert_eq!(get_left(&root_child3), 180.0); + assert_eq!(get_top(&root_child3), 10.0); + assert_eq!(get_width(&root_child3), 30.0); + assert_eq!(get_height(&root_child3), 40.0); + + assert_eq!(get_left(&root_child4), 150.0); + assert_eq!(get_top(&root_child4), 0.0); + assert_eq!(get_width(&root_child4), 30.0); + assert_eq!(get_height(&root_child4), 50.0); } #[test] @@ -850,67 +850,67 @@ mod tests { layout!(&mut root); - assert_eq!(get_left(&mut root), 0.0); - assert_eq!(get_top(&mut root), 0.0); - assert_eq!(get_width(&mut root), 100.0); - assert_eq!(get_height(&mut root), 80.0); + assert_eq!(get_left(&root), 0.0); + assert_eq!(get_top(&root), 0.0); + assert_eq!(get_width(&root), 100.0); + assert_eq!(get_height(&root), 80.0); - assert_eq!(get_left(&mut root_child0), 0.0); - assert_eq!(get_top(&mut root_child0), 70.0); - assert_eq!(get_width(&mut root_child0), 30.0); - assert_eq!(get_height(&mut root_child0), 10.0); + assert_eq!(get_left(&root_child0), 0.0); + assert_eq!(get_top(&root_child0), 70.0); + assert_eq!(get_width(&root_child0), 30.0); + assert_eq!(get_height(&root_child0), 10.0); - assert_eq!(get_left(&mut root_child1), 30.0); - assert_eq!(get_top(&mut root_child1), 60.0); - assert_eq!(get_width(&mut root_child1), 30.0); - assert_eq!(get_height(&mut root_child1), 20.0); + assert_eq!(get_left(&root_child1), 30.0); + assert_eq!(get_top(&root_child1), 60.0); + assert_eq!(get_width(&root_child1), 30.0); + assert_eq!(get_height(&root_child1), 20.0); - assert_eq!(get_left(&mut root_child2), 60.0); - assert_eq!(get_top(&mut root_child2), 50.0); - assert_eq!(get_width(&mut root_child2), 30.0); - assert_eq!(get_height(&mut root_child2), 30.0); + assert_eq!(get_left(&root_child2), 60.0); + assert_eq!(get_top(&root_child2), 50.0); + assert_eq!(get_width(&root_child2), 30.0); + assert_eq!(get_height(&root_child2), 30.0); - assert_eq!(get_left(&mut root_child3), 0.0); - assert_eq!(get_top(&mut root_child3), 10.0); - assert_eq!(get_width(&mut root_child3), 30.0); - assert_eq!(get_height(&mut root_child3), 40.0); + assert_eq!(get_left(&root_child3), 0.0); + assert_eq!(get_top(&root_child3), 10.0); + assert_eq!(get_width(&root_child3), 30.0); + assert_eq!(get_height(&root_child3), 40.0); - assert_eq!(get_left(&mut root_child4), 30.0); - assert_eq!(get_top(&mut root_child4), 0.0); - assert_eq!(get_width(&mut root_child4), 30.0); - assert_eq!(get_height(&mut root_child4), 50.0); + assert_eq!(get_left(&root_child4), 30.0); + assert_eq!(get_top(&root_child4), 0.0); + assert_eq!(get_width(&root_child4), 30.0); + assert_eq!(get_height(&root_child4), 50.0); layout!(&mut root, std::f64::NAN, std::f64::NAN, Direction::RTL); - assert_eq!(get_left(&mut root), 0.0); - assert_eq!(get_top(&mut root), 0.0); - assert_eq!(get_width(&mut root), 100.0); - assert_eq!(get_height(&mut root), 80.0); - - assert_eq!(get_left(&mut root_child0), 70.0); - assert_eq!(get_top(&mut root_child0), 70.0); - assert_eq!(get_width(&mut root_child0), 30.0); - assert_eq!(get_height(&mut root_child0), 10.0); - - assert_eq!(get_left(&mut root_child1), 40.0); - assert_eq!(get_top(&mut root_child1), 60.0); - assert_eq!(get_width(&mut root_child1), 30.0); - assert_eq!(get_height(&mut root_child1), 20.0); - - assert_eq!(get_left(&mut root_child2), 10.0); - assert_eq!(get_top(&mut root_child2), 50.0); - assert_eq!(get_width(&mut root_child2), 30.0); - assert_eq!(get_height(&mut root_child2), 30.0); - - assert_eq!(get_left(&mut root_child3), 70.0); - assert_eq!(get_top(&mut root_child3), 10.0); - assert_eq!(get_width(&mut root_child3), 30.0); - assert_eq!(get_height(&mut root_child3), 40.0); - - assert_eq!(get_left(&mut root_child4), 40.0); - assert_eq!(get_top(&mut root_child4), 0.0); - assert_eq!(get_width(&mut root_child4), 30.0); - assert_eq!(get_height(&mut root_child4), 50.0); + assert_eq!(get_left(&root), 0.0); + assert_eq!(get_top(&root), 0.0); + assert_eq!(get_width(&root), 100.0); + assert_eq!(get_height(&root), 80.0); + + assert_eq!(get_left(&root_child0), 70.0); + assert_eq!(get_top(&root_child0), 70.0); + assert_eq!(get_width(&root_child0), 30.0); + assert_eq!(get_height(&root_child0), 10.0); + + assert_eq!(get_left(&root_child1), 40.0); + assert_eq!(get_top(&root_child1), 60.0); + assert_eq!(get_width(&root_child1), 30.0); + assert_eq!(get_height(&root_child1), 20.0); + + assert_eq!(get_left(&root_child2), 10.0); + assert_eq!(get_top(&root_child2), 50.0); + assert_eq!(get_width(&root_child2), 30.0); + assert_eq!(get_height(&root_child2), 30.0); + + assert_eq!(get_left(&root_child3), 70.0); + assert_eq!(get_top(&root_child3), 10.0); + assert_eq!(get_width(&root_child3), 30.0); + assert_eq!(get_height(&root_child3), 40.0); + + assert_eq!(get_left(&root_child4), 40.0); + assert_eq!(get_top(&root_child4), 0.0); + assert_eq!(get_width(&root_child4), 30.0); + assert_eq!(get_height(&root_child4), 50.0); } #[test] @@ -948,67 +948,67 @@ mod tests { layout!(&mut root); - assert_eq!(get_left(&mut root), 0.0); - assert_eq!(get_top(&mut root), 0.0); - assert_eq!(get_width(&mut root), 100.0); - assert_eq!(get_height(&mut root), 80.0); + assert_eq!(get_left(&root), 0.0); + assert_eq!(get_top(&root), 0.0); + assert_eq!(get_width(&root), 100.0); + assert_eq!(get_height(&root), 80.0); - assert_eq!(get_left(&mut root_child0), 0.0); - assert_eq!(get_top(&mut root_child0), 70.0); - assert_eq!(get_width(&mut root_child0), 30.0); - assert_eq!(get_height(&mut root_child0), 10.0); + assert_eq!(get_left(&root_child0), 0.0); + assert_eq!(get_top(&root_child0), 70.0); + assert_eq!(get_width(&root_child0), 30.0); + assert_eq!(get_height(&root_child0), 10.0); - assert_eq!(get_left(&mut root_child1), 30.0); - assert_eq!(get_top(&mut root_child1), 60.0); - assert_eq!(get_width(&mut root_child1), 30.0); - assert_eq!(get_height(&mut root_child1), 20.0); + assert_eq!(get_left(&root_child1), 30.0); + assert_eq!(get_top(&root_child1), 60.0); + assert_eq!(get_width(&root_child1), 30.0); + assert_eq!(get_height(&root_child1), 20.0); - assert_eq!(get_left(&mut root_child2), 60.0); - assert_eq!(get_top(&mut root_child2), 50.0); - assert_eq!(get_width(&mut root_child2), 30.0); - assert_eq!(get_height(&mut root_child2), 30.0); + assert_eq!(get_left(&root_child2), 60.0); + assert_eq!(get_top(&root_child2), 50.0); + assert_eq!(get_width(&root_child2), 30.0); + assert_eq!(get_height(&root_child2), 30.0); - assert_eq!(get_left(&mut root_child3), 0.0); - assert_eq!(get_top(&mut root_child3), 10.0); - assert_eq!(get_width(&mut root_child3), 30.0); - assert_eq!(get_height(&mut root_child3), 40.0); + assert_eq!(get_left(&root_child3), 0.0); + assert_eq!(get_top(&root_child3), 10.0); + assert_eq!(get_width(&root_child3), 30.0); + assert_eq!(get_height(&root_child3), 40.0); - assert_eq!(get_left(&mut root_child4), 30.0); - assert_eq!(get_top(&mut root_child4), 0.0); - assert_eq!(get_width(&mut root_child4), 30.0); - assert_eq!(get_height(&mut root_child4), 50.0); + assert_eq!(get_left(&root_child4), 30.0); + assert_eq!(get_top(&root_child4), 0.0); + assert_eq!(get_width(&root_child4), 30.0); + assert_eq!(get_height(&root_child4), 50.0); layout!(&mut root, std::f64::NAN, std::f64::NAN, Direction::RTL); - assert_eq!(get_left(&mut root), 0.0); - assert_eq!(get_top(&mut root), 0.0); - assert_eq!(get_width(&mut root), 100.0); - assert_eq!(get_height(&mut root), 80.0); - - assert_eq!(get_left(&mut root_child0), 70.0); - assert_eq!(get_top(&mut root_child0), 70.0); - assert_eq!(get_width(&mut root_child0), 30.0); - assert_eq!(get_height(&mut root_child0), 10.0); - - assert_eq!(get_left(&mut root_child1), 40.0); - assert_eq!(get_top(&mut root_child1), 60.0); - assert_eq!(get_width(&mut root_child1), 30.0); - assert_eq!(get_height(&mut root_child1), 20.0); - - assert_eq!(get_left(&mut root_child2), 10.0); - assert_eq!(get_top(&mut root_child2), 50.0); - assert_eq!(get_width(&mut root_child2), 30.0); - assert_eq!(get_height(&mut root_child2), 30.0); - - assert_eq!(get_left(&mut root_child3), 70.0); - assert_eq!(get_top(&mut root_child3), 10.0); - assert_eq!(get_width(&mut root_child3), 30.0); - assert_eq!(get_height(&mut root_child3), 40.0); - - assert_eq!(get_left(&mut root_child4), 40.0); - assert_eq!(get_top(&mut root_child4), 0.0); - assert_eq!(get_width(&mut root_child4), 30.0); - assert_eq!(get_height(&mut root_child4), 50.0); + assert_eq!(get_left(&root), 0.0); + assert_eq!(get_top(&root), 0.0); + assert_eq!(get_width(&root), 100.0); + assert_eq!(get_height(&root), 80.0); + + assert_eq!(get_left(&root_child0), 70.0); + assert_eq!(get_top(&root_child0), 70.0); + assert_eq!(get_width(&root_child0), 30.0); + assert_eq!(get_height(&root_child0), 10.0); + + assert_eq!(get_left(&root_child1), 40.0); + assert_eq!(get_top(&root_child1), 60.0); + assert_eq!(get_width(&root_child1), 30.0); + assert_eq!(get_height(&root_child1), 20.0); + + assert_eq!(get_left(&root_child2), 10.0); + assert_eq!(get_top(&root_child2), 50.0); + assert_eq!(get_width(&root_child2), 30.0); + assert_eq!(get_height(&root_child2), 30.0); + + assert_eq!(get_left(&root_child3), 70.0); + assert_eq!(get_top(&root_child3), 10.0); + assert_eq!(get_width(&root_child3), 30.0); + assert_eq!(get_height(&root_child3), 40.0); + + assert_eq!(get_left(&root_child4), 40.0); + assert_eq!(get_top(&root_child4), 0.0); + assert_eq!(get_width(&root_child4), 30.0); + assert_eq!(get_height(&root_child4), 50.0); } #[test] @@ -1046,67 +1046,67 @@ mod tests { layout!(&mut root); - assert_eq!(get_left(&mut root), 0.0); - assert_eq!(get_top(&mut root), 0.0); - assert_eq!(get_width(&mut root), 200.0); - assert_eq!(get_height(&mut root), 100.0); + assert_eq!(get_left(&root), 0.0); + assert_eq!(get_top(&root), 0.0); + assert_eq!(get_width(&root), 200.0); + assert_eq!(get_height(&root), 100.0); - assert_eq!(get_left(&mut root_child0), 170.0); - assert_eq!(get_top(&mut root_child0), 0.0); - assert_eq!(get_width(&mut root_child0), 30.0); - assert_eq!(get_height(&mut root_child0), 10.0); + assert_eq!(get_left(&root_child0), 170.0); + assert_eq!(get_top(&root_child0), 0.0); + assert_eq!(get_width(&root_child0), 30.0); + assert_eq!(get_height(&root_child0), 10.0); - assert_eq!(get_left(&mut root_child1), 170.0); - assert_eq!(get_top(&mut root_child1), 10.0); - assert_eq!(get_width(&mut root_child1), 30.0); - assert_eq!(get_height(&mut root_child1), 20.0); + assert_eq!(get_left(&root_child1), 170.0); + assert_eq!(get_top(&root_child1), 10.0); + assert_eq!(get_width(&root_child1), 30.0); + assert_eq!(get_height(&root_child1), 20.0); - assert_eq!(get_left(&mut root_child2), 170.0); - assert_eq!(get_top(&mut root_child2), 30.0); - assert_eq!(get_width(&mut root_child2), 30.0); - assert_eq!(get_height(&mut root_child2), 30.0); + assert_eq!(get_left(&root_child2), 170.0); + assert_eq!(get_top(&root_child2), 30.0); + assert_eq!(get_width(&root_child2), 30.0); + assert_eq!(get_height(&root_child2), 30.0); - assert_eq!(get_left(&mut root_child3), 170.0); - assert_eq!(get_top(&mut root_child3), 60.0); - assert_eq!(get_width(&mut root_child3), 30.0); - assert_eq!(get_height(&mut root_child3), 40.0); + assert_eq!(get_left(&root_child3), 170.0); + assert_eq!(get_top(&root_child3), 60.0); + assert_eq!(get_width(&root_child3), 30.0); + assert_eq!(get_height(&root_child3), 40.0); - assert_eq!(get_left(&mut root_child4), 140.0); - assert_eq!(get_top(&mut root_child4), 0.0); - assert_eq!(get_width(&mut root_child4), 30.0); - assert_eq!(get_height(&mut root_child4), 50.0); + assert_eq!(get_left(&root_child4), 140.0); + assert_eq!(get_top(&root_child4), 0.0); + assert_eq!(get_width(&root_child4), 30.0); + assert_eq!(get_height(&root_child4), 50.0); layout!(&mut root, std::f64::NAN, std::f64::NAN, Direction::RTL); - assert_eq!(get_left(&mut root), 0.0); - assert_eq!(get_top(&mut root), 0.0); - assert_eq!(get_width(&mut root), 200.0); - assert_eq!(get_height(&mut root), 100.0); - - assert_eq!(get_left(&mut root_child0), 0.0); - assert_eq!(get_top(&mut root_child0), 0.0); - assert_eq!(get_width(&mut root_child0), 30.0); - assert_eq!(get_height(&mut root_child0), 10.0); - - assert_eq!(get_left(&mut root_child1), 0.0); - assert_eq!(get_top(&mut root_child1), 10.0); - assert_eq!(get_width(&mut root_child1), 30.0); - assert_eq!(get_height(&mut root_child1), 20.0); - - assert_eq!(get_left(&mut root_child2), 0.0); - assert_eq!(get_top(&mut root_child2), 30.0); - assert_eq!(get_width(&mut root_child2), 30.0); - assert_eq!(get_height(&mut root_child2), 30.0); - - assert_eq!(get_left(&mut root_child3), 0.0); - assert_eq!(get_top(&mut root_child3), 60.0); - assert_eq!(get_width(&mut root_child3), 30.0); - assert_eq!(get_height(&mut root_child3), 40.0); - - assert_eq!(get_left(&mut root_child4), 30.0); - assert_eq!(get_top(&mut root_child4), 0.0); - assert_eq!(get_width(&mut root_child4), 30.0); - assert_eq!(get_height(&mut root_child4), 50.0); + assert_eq!(get_left(&root), 0.0); + assert_eq!(get_top(&root), 0.0); + assert_eq!(get_width(&root), 200.0); + assert_eq!(get_height(&root), 100.0); + + assert_eq!(get_left(&root_child0), 0.0); + assert_eq!(get_top(&root_child0), 0.0); + assert_eq!(get_width(&root_child0), 30.0); + assert_eq!(get_height(&root_child0), 10.0); + + assert_eq!(get_left(&root_child1), 0.0); + assert_eq!(get_top(&root_child1), 10.0); + assert_eq!(get_width(&root_child1), 30.0); + assert_eq!(get_height(&root_child1), 20.0); + + assert_eq!(get_left(&root_child2), 0.0); + assert_eq!(get_top(&root_child2), 30.0); + assert_eq!(get_width(&root_child2), 30.0); + assert_eq!(get_height(&root_child2), 30.0); + + assert_eq!(get_left(&root_child3), 0.0); + assert_eq!(get_top(&root_child3), 60.0); + assert_eq!(get_width(&root_child3), 30.0); + assert_eq!(get_height(&root_child3), 40.0); + + assert_eq!(get_left(&root_child4), 30.0); + assert_eq!(get_top(&root_child4), 0.0); + assert_eq!(get_width(&root_child4), 30.0); + assert_eq!(get_height(&root_child4), 50.0); } #[test] fn wrapped_row_within_align_items_center() { @@ -1132,47 +1132,47 @@ mod tests { layout!(&mut root); - assert_eq!(get_left(&mut root), 0.0); - assert_eq!(get_top(&mut root), 0.0); - assert_eq!(get_width(&mut root), 200.0); - assert_eq!(get_height(&mut root), 200.0); + assert_eq!(get_left(&root), 0.0); + assert_eq!(get_top(&root), 0.0); + assert_eq!(get_width(&root), 200.0); + assert_eq!(get_height(&root), 200.0); - assert_eq!(get_left(&mut root_child0), 0.0); - assert_eq!(get_top(&mut root_child0), 0.0); - assert_eq!(get_width(&mut root_child0), 200.0); - assert_eq!(get_height(&mut root_child0), 160.0); + assert_eq!(get_left(&root_child0), 0.0); + assert_eq!(get_top(&root_child0), 0.0); + assert_eq!(get_width(&root_child0), 200.0); + assert_eq!(get_height(&root_child0), 160.0); - assert_eq!(get_left(&mut root_child0_child0), 0.0); - assert_eq!(get_top(&mut root_child0_child0), 0.0); - assert_eq!(get_width(&mut root_child0_child0), 150.0); - assert_eq!(get_height(&mut root_child0_child0), 80.0); + assert_eq!(get_left(&root_child0_child0), 0.0); + assert_eq!(get_top(&root_child0_child0), 0.0); + assert_eq!(get_width(&root_child0_child0), 150.0); + assert_eq!(get_height(&root_child0_child0), 80.0); - assert_eq!(get_left(&mut root_child0_child1), 0.0); - assert_eq!(get_top(&mut root_child0_child1), 80.0); - assert_eq!(get_width(&mut root_child0_child1), 80.0); - assert_eq!(get_height(&mut root_child0_child1), 80.0); + assert_eq!(get_left(&root_child0_child1), 0.0); + assert_eq!(get_top(&root_child0_child1), 80.0); + assert_eq!(get_width(&root_child0_child1), 80.0); + assert_eq!(get_height(&root_child0_child1), 80.0); layout!(&mut root, std::f64::NAN, std::f64::NAN, Direction::RTL); - assert_eq!(get_left(&mut root), 0.0); - assert_eq!(get_top(&mut root), 0.0); - assert_eq!(get_width(&mut root), 200.0); - assert_eq!(get_height(&mut root), 200.0); - - assert_eq!(get_left(&mut root_child0), 0.0); - assert_eq!(get_top(&mut root_child0), 0.0); - assert_eq!(get_width(&mut root_child0), 200.0); - assert_eq!(get_height(&mut root_child0), 160.0); - - assert_eq!(get_left(&mut root_child0_child0), 50.0); - assert_eq!(get_top(&mut root_child0_child0), 0.0); - assert_eq!(get_width(&mut root_child0_child0), 150.0); - assert_eq!(get_height(&mut root_child0_child0), 80.0); - - assert_eq!(get_left(&mut root_child0_child1), 120.0); - assert_eq!(get_top(&mut root_child0_child1), 80.0); - assert_eq!(get_width(&mut root_child0_child1), 80.0); - assert_eq!(get_height(&mut root_child0_child1), 80.0); + assert_eq!(get_left(&root), 0.0); + assert_eq!(get_top(&root), 0.0); + assert_eq!(get_width(&root), 200.0); + assert_eq!(get_height(&root), 200.0); + + assert_eq!(get_left(&root_child0), 0.0); + assert_eq!(get_top(&root_child0), 0.0); + assert_eq!(get_width(&root_child0), 200.0); + assert_eq!(get_height(&root_child0), 160.0); + + assert_eq!(get_left(&root_child0_child0), 50.0); + assert_eq!(get_top(&root_child0_child0), 0.0); + assert_eq!(get_width(&root_child0_child0), 150.0); + assert_eq!(get_height(&root_child0_child0), 80.0); + + assert_eq!(get_left(&root_child0_child1), 120.0); + assert_eq!(get_top(&root_child0_child1), 80.0); + assert_eq!(get_width(&root_child0_child1), 80.0); + assert_eq!(get_height(&root_child0_child1), 80.0); } #[test] @@ -1199,47 +1199,47 @@ mod tests { layout!(&mut root); - assert_eq!(get_left(&mut root), 0.0); - assert_eq!(get_top(&mut root), 0.0); - assert_eq!(get_width(&mut root), 200.0); - assert_eq!(get_height(&mut root), 200.0); + assert_eq!(get_left(&root), 0.0); + assert_eq!(get_top(&root), 0.0); + assert_eq!(get_width(&root), 200.0); + assert_eq!(get_height(&root), 200.0); - assert_eq!(get_left(&mut root_child0), 0.0); - assert_eq!(get_top(&mut root_child0), 0.0); - assert_eq!(get_width(&mut root_child0), 200.0); - assert_eq!(get_height(&mut root_child0), 160.0); + assert_eq!(get_left(&root_child0), 0.0); + assert_eq!(get_top(&root_child0), 0.0); + assert_eq!(get_width(&root_child0), 200.0); + assert_eq!(get_height(&root_child0), 160.0); - assert_eq!(get_left(&mut root_child0_child0), 0.0); - assert_eq!(get_top(&mut root_child0_child0), 0.0); - assert_eq!(get_width(&mut root_child0_child0), 150.0); - assert_eq!(get_height(&mut root_child0_child0), 80.0); + assert_eq!(get_left(&root_child0_child0), 0.0); + assert_eq!(get_top(&root_child0_child0), 0.0); + assert_eq!(get_width(&root_child0_child0), 150.0); + assert_eq!(get_height(&root_child0_child0), 80.0); - assert_eq!(get_left(&mut root_child0_child1), 0.0); - assert_eq!(get_top(&mut root_child0_child1), 80.0); - assert_eq!(get_width(&mut root_child0_child1), 80.0); - assert_eq!(get_height(&mut root_child0_child1), 80.0); + assert_eq!(get_left(&root_child0_child1), 0.0); + assert_eq!(get_top(&root_child0_child1), 80.0); + assert_eq!(get_width(&root_child0_child1), 80.0); + assert_eq!(get_height(&root_child0_child1), 80.0); layout!(&mut root, std::f64::NAN, std::f64::NAN, Direction::RTL); - assert_eq!(get_left(&mut root), 0.0); - assert_eq!(get_top(&mut root), 0.0); - assert_eq!(get_width(&mut root), 200.0); - assert_eq!(get_height(&mut root), 200.0); - - assert_eq!(get_left(&mut root_child0), 0.0); - assert_eq!(get_top(&mut root_child0), 0.0); - assert_eq!(get_width(&mut root_child0), 200.0); - assert_eq!(get_height(&mut root_child0), 160.0); - - assert_eq!(get_left(&mut root_child0_child0), 50.0); - assert_eq!(get_top(&mut root_child0_child0), 0.0); - assert_eq!(get_width(&mut root_child0_child0), 150.0); - assert_eq!(get_height(&mut root_child0_child0), 80.0); - - assert_eq!(get_left(&mut root_child0_child1), 120.0); - assert_eq!(get_top(&mut root_child0_child1), 80.0); - assert_eq!(get_width(&mut root_child0_child1), 80.0); - assert_eq!(get_height(&mut root_child0_child1), 80.0); + assert_eq!(get_left(&root), 0.0); + assert_eq!(get_top(&root), 0.0); + assert_eq!(get_width(&root), 200.0); + assert_eq!(get_height(&root), 200.0); + + assert_eq!(get_left(&root_child0), 0.0); + assert_eq!(get_top(&root_child0), 0.0); + assert_eq!(get_width(&root_child0), 200.0); + assert_eq!(get_height(&root_child0), 160.0); + + assert_eq!(get_left(&root_child0_child0), 50.0); + assert_eq!(get_top(&root_child0_child0), 0.0); + assert_eq!(get_width(&root_child0_child0), 150.0); + assert_eq!(get_height(&root_child0_child0), 80.0); + + assert_eq!(get_left(&root_child0_child1), 120.0); + assert_eq!(get_top(&root_child0_child1), 80.0); + assert_eq!(get_width(&root_child0_child1), 80.0); + assert_eq!(get_height(&root_child0_child1), 80.0); } #[test] @@ -1266,47 +1266,47 @@ mod tests { layout!(&mut root); - assert_eq!(get_left(&mut root), 0.0); - assert_eq!(get_top(&mut root), 0.0); - assert_eq!(get_width(&mut root), 200.0); - assert_eq!(get_height(&mut root), 200.0); + assert_eq!(get_left(&root), 0.0); + assert_eq!(get_top(&root), 0.0); + assert_eq!(get_width(&root), 200.0); + assert_eq!(get_height(&root), 200.0); - assert_eq!(get_left(&mut root_child0), 0.0); - assert_eq!(get_top(&mut root_child0), 0.0); - assert_eq!(get_width(&mut root_child0), 200.0); - assert_eq!(get_height(&mut root_child0), 160.0); + assert_eq!(get_left(&root_child0), 0.0); + assert_eq!(get_top(&root_child0), 0.0); + assert_eq!(get_width(&root_child0), 200.0); + assert_eq!(get_height(&root_child0), 160.0); - assert_eq!(get_left(&mut root_child0_child0), 0.0); - assert_eq!(get_top(&mut root_child0_child0), 0.0); - assert_eq!(get_width(&mut root_child0_child0), 150.0); - assert_eq!(get_height(&mut root_child0_child0), 80.0); + assert_eq!(get_left(&root_child0_child0), 0.0); + assert_eq!(get_top(&root_child0_child0), 0.0); + assert_eq!(get_width(&root_child0_child0), 150.0); + assert_eq!(get_height(&root_child0_child0), 80.0); - assert_eq!(get_left(&mut root_child0_child1), 0.0); - assert_eq!(get_top(&mut root_child0_child1), 80.0); - assert_eq!(get_width(&mut root_child0_child1), 80.0); - assert_eq!(get_height(&mut root_child0_child1), 80.0); + assert_eq!(get_left(&root_child0_child1), 0.0); + assert_eq!(get_top(&root_child0_child1), 80.0); + assert_eq!(get_width(&root_child0_child1), 80.0); + assert_eq!(get_height(&root_child0_child1), 80.0); layout!(&mut root, std::f64::NAN, std::f64::NAN, Direction::RTL); - assert_eq!(get_left(&mut root), 0.0); - assert_eq!(get_top(&mut root), 0.0); - assert_eq!(get_width(&mut root), 200.0); - assert_eq!(get_height(&mut root), 200.0); - - assert_eq!(get_left(&mut root_child0), 0.0); - assert_eq!(get_top(&mut root_child0), 0.0); - assert_eq!(get_width(&mut root_child0), 200.0); - assert_eq!(get_height(&mut root_child0), 160.0); - - assert_eq!(get_left(&mut root_child0_child0), 50.0); - assert_eq!(get_top(&mut root_child0_child0), 0.0); - assert_eq!(get_width(&mut root_child0_child0), 150.0); - assert_eq!(get_height(&mut root_child0_child0), 80.0); - - assert_eq!(get_left(&mut root_child0_child1), 120.0); - assert_eq!(get_top(&mut root_child0_child1), 80.0); - assert_eq!(get_width(&mut root_child0_child1), 80.0); - assert_eq!(get_height(&mut root_child0_child1), 80.0); + assert_eq!(get_left(&root), 0.0); + assert_eq!(get_top(&root), 0.0); + assert_eq!(get_width(&root), 200.0); + assert_eq!(get_height(&root), 200.0); + + assert_eq!(get_left(&root_child0), 0.0); + assert_eq!(get_top(&root_child0), 0.0); + assert_eq!(get_width(&root_child0), 200.0); + assert_eq!(get_height(&root_child0), 160.0); + + assert_eq!(get_left(&root_child0_child0), 50.0); + assert_eq!(get_top(&root_child0_child0), 0.0); + assert_eq!(get_width(&root_child0_child0), 150.0); + assert_eq!(get_height(&root_child0_child0), 80.0); + + assert_eq!(get_left(&root_child0_child1), 120.0); + assert_eq!(get_top(&root_child0_child1), 80.0); + assert_eq!(get_width(&root_child0_child1), 80.0); + assert_eq!(get_height(&root_child0_child1), 80.0); } #[test] @@ -1341,47 +1341,47 @@ mod tests { layout!(&mut root); - assert_eq!(get_left(&mut root), 0.0); - assert_eq!(get_top(&mut root), 0.0); - assert_eq!(get_width(&mut root), 700.0); - assert_eq!(get_height(&mut root), 500.0); + assert_eq!(get_left(&root), 0.0); + assert_eq!(get_top(&root), 0.0); + assert_eq!(get_width(&root), 700.0); + assert_eq!(get_height(&root), 500.0); - assert_eq!(get_left(&mut root_child0), 250.0); - assert_eq!(get_top(&mut root_child0), 30.0); - assert_eq!(get_width(&mut root_child0), 100.0); - assert_eq!(get_height(&mut root_child0), 200.0); + assert_eq!(get_left(&root_child0), 250.0); + assert_eq!(get_top(&root_child0), 30.0); + assert_eq!(get_width(&root_child0), 100.0); + assert_eq!(get_height(&root_child0), 200.0); - assert_eq!(get_left(&mut root_child1), 200.0); - assert_eq!(get_top(&mut root_child1), 250.0); - assert_eq!(get_width(&mut root_child1), 200.0); - assert_eq!(get_height(&mut root_child1), 200.0); + assert_eq!(get_left(&root_child1), 200.0); + assert_eq!(get_top(&root_child1), 250.0); + assert_eq!(get_width(&root_child1), 200.0); + assert_eq!(get_height(&root_child1), 200.0); - assert_eq!(get_left(&mut root_child2), 420.0); - assert_eq!(get_top(&mut root_child2), 200.0); - assert_eq!(get_width(&mut root_child2), 100.0); - assert_eq!(get_height(&mut root_child2), 100.0); + assert_eq!(get_left(&root_child2), 420.0); + assert_eq!(get_top(&root_child2), 200.0); + assert_eq!(get_width(&root_child2), 100.0); + assert_eq!(get_height(&root_child2), 100.0); layout!(&mut root, std::f64::NAN, std::f64::NAN, Direction::RTL); - assert_eq!(get_left(&mut root), 0.0); - assert_eq!(get_top(&mut root), 0.0); - assert_eq!(get_width(&mut root), 700.0); - assert_eq!(get_height(&mut root), 500.0); - - assert_eq!(get_left(&mut root_child0), 350.0); - assert_eq!(get_top(&mut root_child0), 30.0); - assert_eq!(get_width(&mut root_child0), 100.0); - assert_eq!(get_height(&mut root_child0), 200.0); - - assert_eq!(get_left(&mut root_child1), 300.0); - assert_eq!(get_top(&mut root_child1), 250.0); - assert_eq!(get_width(&mut root_child1), 200.0); - assert_eq!(get_height(&mut root_child1), 200.0); - - assert_eq!(get_left(&mut root_child2), 180.0); - assert_eq!(get_top(&mut root_child2), 200.0); - assert_eq!(get_width(&mut root_child2), 100.0); - assert_eq!(get_height(&mut root_child2), 100.0); + assert_eq!(get_left(&root), 0.0); + assert_eq!(get_top(&root), 0.0); + assert_eq!(get_width(&root), 700.0); + assert_eq!(get_height(&root), 500.0); + + assert_eq!(get_left(&root_child0), 350.0); + assert_eq!(get_top(&root_child0), 30.0); + assert_eq!(get_width(&root_child0), 100.0); + assert_eq!(get_height(&root_child0), 200.0); + + assert_eq!(get_left(&root_child1), 300.0); + assert_eq!(get_top(&root_child1), 250.0); + assert_eq!(get_width(&root_child1), 200.0); + assert_eq!(get_height(&root_child1), 200.0); + + assert_eq!(get_left(&root_child2), 180.0); + assert_eq!(get_top(&root_child2), 200.0); + assert_eq!(get_width(&root_child2), 100.0); + assert_eq!(get_height(&root_child2), 100.0); } #[test] @@ -1422,47 +1422,47 @@ mod tests { layout!(&mut root); - assert_eq!(get_left(&mut root), 0.0); - assert_eq!(get_top(&mut root), 0.0); - assert_eq!(get_width(&mut root), 700.0); - assert_eq!(get_height(&mut root), 500.0); + assert_eq!(get_left(&root), 0.0); + assert_eq!(get_top(&root), 0.0); + assert_eq!(get_width(&root), 700.0); + assert_eq!(get_height(&root), 500.0); - assert_eq!(get_left(&mut root_child0), 300.0); - assert_eq!(get_top(&mut root_child0), 0.0); - assert_eq!(get_width(&mut root_child0), 100.0); - assert_eq!(get_height(&mut root_child0), 180.0); + assert_eq!(get_left(&root_child0), 300.0); + assert_eq!(get_top(&root_child0), 0.0); + assert_eq!(get_width(&root_child0), 100.0); + assert_eq!(get_height(&root_child0), 180.0); - assert_eq!(get_left(&mut root_child1), 250.0); - assert_eq!(get_top(&mut root_child1), 200.0); - assert_eq!(get_width(&mut root_child1), 200.0); - assert_eq!(get_height(&mut root_child1), 180.0); + assert_eq!(get_left(&root_child1), 250.0); + assert_eq!(get_top(&root_child1), 200.0); + assert_eq!(get_width(&root_child1), 200.0); + assert_eq!(get_height(&root_child1), 180.0); - assert_eq!(get_left(&mut root_child2), 300.0); - assert_eq!(get_top(&mut root_child2), 400.0); - assert_eq!(get_width(&mut root_child2), 100.0); - assert_eq!(get_height(&mut root_child2), 100.0); + assert_eq!(get_left(&root_child2), 300.0); + assert_eq!(get_top(&root_child2), 400.0); + assert_eq!(get_width(&root_child2), 100.0); + assert_eq!(get_height(&root_child2), 100.0); layout!(&mut root, std::f64::NAN, std::f64::NAN, Direction::RTL); - assert_eq!(get_left(&mut root), 0.0); - assert_eq!(get_top(&mut root), 0.0); - assert_eq!(get_width(&mut root), 700.0); - assert_eq!(get_height(&mut root), 500.0); - - assert_eq!(get_left(&mut root_child0), 300.0); - assert_eq!(get_top(&mut root_child0), 0.0); - assert_eq!(get_width(&mut root_child0), 100.0); - assert_eq!(get_height(&mut root_child0), 180.0); - - assert_eq!(get_left(&mut root_child1), 250.0); - assert_eq!(get_top(&mut root_child1), 200.0); - assert_eq!(get_width(&mut root_child1), 200.0); - assert_eq!(get_height(&mut root_child1), 180.0); - - assert_eq!(get_left(&mut root_child2), 300.0); - assert_eq!(get_top(&mut root_child2), 400.0); - assert_eq!(get_width(&mut root_child2), 100.0); - assert_eq!(get_height(&mut root_child2), 100.0); + assert_eq!(get_left(&root), 0.0); + assert_eq!(get_top(&root), 0.0); + assert_eq!(get_width(&root), 700.0); + assert_eq!(get_height(&root), 500.0); + + assert_eq!(get_left(&root_child0), 300.0); + assert_eq!(get_top(&root_child0), 0.0); + assert_eq!(get_width(&root_child0), 100.0); + assert_eq!(get_height(&root_child0), 180.0); + + assert_eq!(get_left(&root_child1), 250.0); + assert_eq!(get_top(&root_child1), 200.0); + assert_eq!(get_width(&root_child1), 200.0); + assert_eq!(get_height(&root_child1), 180.0); + + assert_eq!(get_left(&root_child2), 300.0); + assert_eq!(get_top(&root_child2), 400.0); + assert_eq!(get_width(&root_child2), 100.0); + assert_eq!(get_height(&root_child2), 100.0); } #[test] @@ -1496,35 +1496,35 @@ mod tests { layout!(&mut root); - assert_eq!(get_left(&mut root), 0.0); - assert_eq!(get_top(&mut root), 0.0); - assert_eq!(get_width(&mut root), 500.0); - assert_eq!(get_height(&mut root), 500.0); - - assert_eq!(get_left(&mut root_child0), 0.0); - assert_eq!(get_top(&mut root_child0), 0.0); - assert_eq!(get_width(&mut root_child0), 85.0); - assert_eq!(get_height(&mut root_child0), 80.0); - - assert_eq!(get_left(&mut root_child0_child0), 0.0); - assert_eq!(get_top(&mut root_child0_child0), 0.0); - assert_eq!(get_width(&mut root_child0_child0), 40.0); - assert_eq!(get_height(&mut root_child0_child0), 40.0); - - assert_eq!(get_left(&mut root_child0_child0_child0), 0.0); - assert_eq!(get_top(&mut root_child0_child0_child0), 0.0); - assert_eq!(get_width(&mut root_child0_child0_child0), 40.0); - assert_eq!(get_height(&mut root_child0_child0_child0), 40.0); - - assert_eq!(get_left(&mut root_child0_child1), 0.0); - assert_eq!(get_top(&mut root_child0_child1), 40.0); - assert_eq!(get_width(&mut root_child0_child1), 40.0); - assert_eq!(get_height(&mut root_child0_child1), 40.0); - - assert_eq!(get_left(&mut root_child0_child1_child0), 0.0); - assert_eq!(get_top(&mut root_child0_child1_child0), 0.0); - assert_eq!(get_width(&mut root_child0_child1_child0), 40.0); - assert_eq!(get_height(&mut root_child0_child1_child0), 40.0); + assert_eq!(get_left(&root), 0.0); + assert_eq!(get_top(&root), 0.0); + assert_eq!(get_width(&root), 500.0); + assert_eq!(get_height(&root), 500.0); + + assert_eq!(get_left(&root_child0), 0.0); + assert_eq!(get_top(&root_child0), 0.0); + assert_eq!(get_width(&root_child0), 85.0); + assert_eq!(get_height(&root_child0), 80.0); + + assert_eq!(get_left(&root_child0_child0), 0.0); + assert_eq!(get_top(&root_child0_child0), 0.0); + assert_eq!(get_width(&root_child0_child0), 40.0); + assert_eq!(get_height(&root_child0_child0), 40.0); + + assert_eq!(get_left(&root_child0_child0_child0), 0.0); + assert_eq!(get_top(&root_child0_child0_child0), 0.0); + assert_eq!(get_width(&root_child0_child0_child0), 40.0); + assert_eq!(get_height(&root_child0_child0_child0), 40.0); + + assert_eq!(get_left(&root_child0_child1), 0.0); + assert_eq!(get_top(&root_child0_child1), 40.0); + assert_eq!(get_width(&root_child0_child1), 40.0); + assert_eq!(get_height(&root_child0_child1), 40.0); + + assert_eq!(get_left(&root_child0_child1_child0), 0.0); + assert_eq!(get_top(&root_child0_child1_child0), 0.0); + assert_eq!(get_width(&root_child0_child1_child0), 40.0); + assert_eq!(get_height(&root_child0_child1_child0), 40.0); } #[test] @@ -1558,67 +1558,67 @@ mod tests { layout!(&mut root); - assert_eq!(get_left(&mut root), 0.0); - assert_eq!(get_top(&mut root), 0.0); - assert_eq!(get_width(&mut root), 500.0); - assert_eq!(get_height(&mut root), 500.0); + assert_eq!(get_left(&root), 0.0); + assert_eq!(get_top(&root), 0.0); + assert_eq!(get_width(&root), 500.0); + assert_eq!(get_height(&root), 500.0); - assert_eq!(get_left(&mut root_child0), 0.0); - assert_eq!(get_top(&mut root_child0), 0.0); - assert_eq!(get_width(&mut root_child0), 70.0); - assert_eq!(get_height(&mut root_child0), 90.0); + assert_eq!(get_left(&root_child0), 0.0); + assert_eq!(get_top(&root_child0), 0.0); + assert_eq!(get_width(&root_child0), 70.0); + assert_eq!(get_height(&root_child0), 90.0); - assert_eq!(get_left(&mut root_child0_child0), 0.0); - assert_eq!(get_top(&mut root_child0_child0), 0.0); - assert_eq!(get_width(&mut root_child0_child0), 40.0); - assert_eq!(get_height(&mut root_child0_child0), 40.0); + assert_eq!(get_left(&root_child0_child0), 0.0); + assert_eq!(get_top(&root_child0_child0), 0.0); + assert_eq!(get_width(&root_child0_child0), 40.0); + assert_eq!(get_height(&root_child0_child0), 40.0); - assert_eq!(get_left(&mut root_child0_child0_child0), 0.0); - assert_eq!(get_top(&mut root_child0_child0_child0), 0.0); - assert_eq!(get_width(&mut root_child0_child0_child0), 40.0); - assert_eq!(get_height(&mut root_child0_child0_child0), 40.0); + assert_eq!(get_left(&root_child0_child0_child0), 0.0); + assert_eq!(get_top(&root_child0_child0_child0), 0.0); + assert_eq!(get_width(&root_child0_child0_child0), 40.0); + assert_eq!(get_height(&root_child0_child0_child0), 40.0); - assert_eq!(get_left(&mut root_child0_child1), 0.0); - assert_eq!(get_top(&mut root_child0_child1), 50.0); - assert_eq!(get_width(&mut root_child0_child1), 40.0); - assert_eq!(get_height(&mut root_child0_child1), 40.0); + assert_eq!(get_left(&root_child0_child1), 0.0); + assert_eq!(get_top(&root_child0_child1), 50.0); + assert_eq!(get_width(&root_child0_child1), 40.0); + assert_eq!(get_height(&root_child0_child1), 40.0); - assert_eq!(get_left(&mut root_child0_child1_child0), 0.0); - assert_eq!(get_top(&mut root_child0_child1_child0), 0.0); - assert_eq!(get_width(&mut root_child0_child1_child0), 40.0); - assert_eq!(get_height(&mut root_child0_child1_child0), 40.0); + assert_eq!(get_left(&root_child0_child1_child0), 0.0); + assert_eq!(get_top(&root_child0_child1_child0), 0.0); + assert_eq!(get_width(&root_child0_child1_child0), 40.0); + assert_eq!(get_height(&root_child0_child1_child0), 40.0); layout!(&mut root, std::f64::NAN, std::f64::NAN, Direction::RTL); - assert_eq!(get_left(&mut root), 0.0); - assert_eq!(get_top(&mut root), 0.0); - assert_eq!(get_width(&mut root), 500.0); - assert_eq!(get_height(&mut root), 500.0); - - assert_eq!(get_left(&mut root_child0), 430.0); - assert_eq!(get_top(&mut root_child0), 0.0); - assert_eq!(get_width(&mut root_child0), 70.0); - assert_eq!(get_height(&mut root_child0), 90.0); - - assert_eq!(get_left(&mut root_child0_child0), 30.0); - assert_eq!(get_top(&mut root_child0_child0), 0.0); - assert_eq!(get_width(&mut root_child0_child0), 40.0); - assert_eq!(get_height(&mut root_child0_child0), 40.0); - - assert_eq!(get_left(&mut root_child0_child0_child0), 0.0); - assert_eq!(get_top(&mut root_child0_child0_child0), 0.0); - assert_eq!(get_width(&mut root_child0_child0_child0), 40.0); - assert_eq!(get_height(&mut root_child0_child0_child0), 40.0); - - assert_eq!(get_left(&mut root_child0_child1), 30.0); - assert_eq!(get_top(&mut root_child0_child1), 50.0); - assert_eq!(get_width(&mut root_child0_child1), 40.0); - assert_eq!(get_height(&mut root_child0_child1), 40.0); - - assert_eq!(get_left(&mut root_child0_child1_child0), 0.0); - assert_eq!(get_top(&mut root_child0_child1_child0), 0.0); - assert_eq!(get_width(&mut root_child0_child1_child0), 40.0); - assert_eq!(get_height(&mut root_child0_child1_child0), 40.0); + assert_eq!(get_left(&root), 0.0); + assert_eq!(get_top(&root), 0.0); + assert_eq!(get_width(&root), 500.0); + assert_eq!(get_height(&root), 500.0); + + assert_eq!(get_left(&root_child0), 430.0); + assert_eq!(get_top(&root_child0), 0.0); + assert_eq!(get_width(&root_child0), 70.0); + assert_eq!(get_height(&root_child0), 90.0); + + assert_eq!(get_left(&root_child0_child0), 30.0); + assert_eq!(get_top(&root_child0_child0), 0.0); + assert_eq!(get_width(&root_child0_child0), 40.0); + assert_eq!(get_height(&root_child0_child0), 40.0); + + assert_eq!(get_left(&root_child0_child0_child0), 0.0); + assert_eq!(get_top(&root_child0_child0_child0), 0.0); + assert_eq!(get_width(&root_child0_child0_child0), 40.0); + assert_eq!(get_height(&root_child0_child0_child0), 40.0); + + assert_eq!(get_left(&root_child0_child1), 30.0); + assert_eq!(get_top(&root_child0_child1), 50.0); + assert_eq!(get_width(&root_child0_child1), 40.0); + assert_eq!(get_height(&root_child0_child1), 40.0); + + assert_eq!(get_left(&root_child0_child1_child0), 0.0); + assert_eq!(get_top(&root_child0_child1_child0), 0.0); + assert_eq!(get_width(&root_child0_child1_child0), 40.0); + assert_eq!(get_height(&root_child0_child1_child0), 40.0); } } diff --git a/tests/layout_macro_test.rs b/tests/layout_macro_test.rs index d30c076..4c5038e 100644 --- a/tests/layout_macro_test.rs +++ b/tests/layout_macro_test.rs @@ -10,9 +10,9 @@ mod tests { taitank_safe::set_direction(&mut node, taitank_safe::Direction::LTR); taitank_safe::layout!(&mut node); - assert_eq!(taitank_safe::get_left(&mut node), 0.0); - assert_eq!(taitank_safe::get_top(&mut node), 0.0); - assert_eq!(taitank_safe::get_width(&mut node), 100.0); - assert_eq!(taitank_safe::get_height(&mut node), 100.0); + assert_eq!(taitank_safe::get_left(&node), 0.0); + assert_eq!(taitank_safe::get_top(&node), 0.0); + assert_eq!(taitank_safe::get_width(&node), 100.0); + assert_eq!(taitank_safe::get_height(&node), 100.0); } }